make antihunger compatible with elytraflight

This commit is contained in:
Bella 2020-04-01 14:52:03 -04:00
parent 82574ecaf7
commit 5cc3019fc9
No known key found for this signature in database
GPG Key ID: 815562EA23BFE344
1 changed files with 6 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package me.zeroeightsix.kami.module.modules.movement;
import me.zero.alpine.listener.EventHandler;
import me.zero.alpine.listener.Listener;
import me.zeroeightsix.kami.command.Command;
import me.zeroeightsix.kami.event.events.PacketEvent;
import me.zeroeightsix.kami.module.Module;
import me.zeroeightsix.kami.setting.Setting;
@ -9,6 +10,7 @@ import me.zeroeightsix.kami.setting.Settings;
import net.minecraft.network.play.client.CPacketEntityAction;
import net.minecraft.network.play.client.CPacketPlayer;
import static me.zeroeightsix.kami.KamiMod.MODULE_MANAGER;
import static net.minecraft.network.play.client.CPacketEntityAction.Action.START_SPRINTING;
import static net.minecraft.network.play.client.CPacketEntityAction.Action.STOP_SPRINTING;
@ -23,6 +25,10 @@ public class AntiHunger extends Module {
@EventHandler
public Listener<PacketEvent.Send> packetListener = new Listener<>(event -> {
if (MODULE_MANAGER.getModule(ElytraFlight.class).isEnabled() && cancelMovementState.getValue()) {
Command.sendChatMessage(getChatName() + "ElytraFlight is not compatible with the 'Cancel Movement State' option, disabling");
disable();
}
if (event.getPacket() instanceof CPacketEntityAction) {
final CPacketEntityAction packet = (CPacketEntityAction) event.getPacket();
if (cancelMovementState.getValue() && (packet.getAction() == START_SPRINTING || packet.getAction() == STOP_SPRINTING)) {