fix autoeat sneaking
This commit is contained in:
parent
c7a00e80eb
commit
6d69b1646d
1 changed files with 16 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
|||
package com.baseband.client.feature.world;
|
||||
|
||||
import com.baseband.client.event.events.PacketEvent;
|
||||
import com.baseband.client.registry.annotation.Config;
|
||||
import com.baseband.client.event.events.BaritoneEvent;
|
||||
import com.baseband.client.mixins.IMinecraft;
|
||||
|
@ -11,6 +12,9 @@ import net.minecraft.item.ItemAppleGold;
|
|||
import net.minecraft.item.ItemChorusFruit;
|
||||
import net.minecraft.item.ItemFood;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.network.play.client.CPacketAnimation;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItem;
|
||||
import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.FoodStats;
|
||||
|
||||
|
@ -45,7 +49,6 @@ public class AutoEat extends Feature {
|
|||
lastSlot = -1;
|
||||
}
|
||||
eating = false;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), false);
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), false);
|
||||
return;
|
||||
}
|
||||
|
@ -58,7 +61,6 @@ public class AutoEat extends Feature {
|
|||
}
|
||||
mc.player.setActiveHand(EnumHand.OFF_HAND);
|
||||
eating = true;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), true);
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true);
|
||||
((IMinecraft) mc).rightClick();
|
||||
} else {
|
||||
|
@ -70,7 +72,7 @@ public class AutoEat extends Feature {
|
|||
lastSlot = mc.player.inventory.currentItem;
|
||||
mc.player.inventory.currentItem = i;
|
||||
eating = true;
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindSneak.getKeyCode(), true);
|
||||
mc.player.setActiveHand(EnumHand.MAIN_HAND);
|
||||
KeyBinding.setKeyBindState(mc.gameSettings.keyBindUseItem.getKeyCode(), true);
|
||||
((IMinecraft) mc).rightClick();
|
||||
return;
|
||||
|
@ -85,6 +87,17 @@ public class AutoEat extends Feature {
|
|||
}
|
||||
}
|
||||
|
||||
public void onPacket(PacketEvent.Send event) {
|
||||
if(!eating)
|
||||
return;
|
||||
if(event.getPacket() instanceof CPacketPlayerTryUseItemOnBlock) {
|
||||
mc.player.connection.sendPacket(new CPacketPlayerTryUseItem(((CPacketPlayerTryUseItemOnBlock) event.getPacket()).getHand()));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if(event.getPacket() instanceof CPacketAnimation) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private boolean isValid(ItemStack stack, int currentHunger) {
|
||||
|
|
Loading…
Add table
Reference in a new issue