blob: d98f61f46ee42e9154475f757610a55899faec40 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package ftbsc.bscv.modules.self;
import com.google.auto.service.AutoService;
import ftbsc.bscv.ICommons;
import ftbsc.bscv.api.ILoadable;
import ftbsc.bscv.modules.AbstractModule;
import ftbsc.bscv.patches.PacketPatch.PacketEvent;
import ftbsc.bscv.tools.Setting;
import net.minecraft.network.play.client.CEntityActionPacket;
import net.minecraft.network.play.client.CEntityActionPacket.Action;
import net.minecraft.network.play.client.CPlayerPacket;
import net.minecraftforge.common.ForgeConfigSpec;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@AutoService(ILoadable.class)
public class AntiHunger extends AbstractModule implements ICommons {
public final ForgeConfigSpec.ConfigValue<Boolean> sprint;
public final ForgeConfigSpec.ConfigValue<Boolean> hover;
public AntiHunger() {
super();
this.sprint = Setting.Bool.builder()
.fallback(true)
.name("sprint")
.comment("mask sprint toggle packets")
.build(this);
this.hover = Setting.Bool.builder()
.name("hover")
.comment("mark as not on-ground while walking")
.fallback(true)
.build(this);
}
@SubscribeEvent
public void onPacket(PacketEvent.Outgoing event) {
if (this.sprint.get() && event.packet instanceof CEntityActionPacket) {
CEntityActionPacket packet = (CEntityActionPacket) event.packet;
if (
packet.getAction() == Action.START_SPRINTING ||
packet.getAction() == Action.STOP_SPRINTING
) {
event.setCanceled(true);
}
}
if (
this.hover.get()
&& event.packet instanceof CPlayerPacket
&& MC.player != null
&& MC.player.fallDistance <= 0.f
&& !MC.gameMode.isDestroying()
) {
CPlayerPacket packet = (CPlayerPacket) event.packet;
packet.onGround = false; // ACCESSTRANSFORMER public net.minecraft.network.play.client.CPlayerPacket field_149474_g
}
}
}
|