use of net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket in project BleachHack by BleachDrinker420.
the class AutoEXP method onTick.
@BleachSubscribe
public void onTick(EventTick event) {
if (mc.player.currentScreenHandler != mc.player.playerScreenHandler)
return;
int xpSlot = InventoryUtils.getSlot(true, i -> mc.player.getInventory().getStack(i).getItem() == Items.EXPERIENCE_BOTTLE);
if (xpSlot == -1)
return;
int damage = getSetting(3).asSlider().getValueInt();
double target = getSetting(4).asSlider().getValue();
if (slot != -1) {
if (xpNeeded == 0) {
ItemStack item = slot < 45 ? mc.player.currentScreenHandler.getSlot(slot).getStack() : mc.player.getOffHandStack();
if (item.isDamaged() && item.getMaxDamage() - item.getDamage() <= damage)
return;
for (int i = 1; i <= 4; i++) {
ItemStack stack = mc.player.currentScreenHandler.getSlot(i).getStack();
if (!stack.isEmpty()) {
for (int j = 5; j <= 8; j++) {
if (mc.player.currentScreenHandler.getSlot(j).canInsert(stack)) {
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 0, SlotActionType.PICKUP, mc.player);
return;
}
}
}
}
if (slot >= 46) {
if (slot - 46 != mc.player.getInventory().selectedSlot) {
mc.player.getInventory().selectedSlot = slot - 46;
mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot - 46));
}
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
}
delay = 0;
slot = -1;
return;
}
for (int i = 5; i <= 8; i++) {
if (i != slot && EnchantmentHelper.getLevel(Enchantments.MENDING, mc.player.currentScreenHandler.getSlot(i).getStack()) != 0) {
for (int j = 1; j <= 4; j++) {
ItemStack craftingStack = mc.player.currentScreenHandler.getSlot(j).getStack();
if (!craftingStack.isDamageable()) {
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, i, 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 0, SlotActionType.PICKUP, mc.player);
if (!craftingStack.isEmpty())
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, j, 1, SlotActionType.THROW, mc.player);
return;
}
}
}
}
if (slot > 8 && slot < 45) {
if (slot - 36 != mc.player.getInventory().selectedSlot) {
mc.player.getInventory().selectedSlot = slot - 36;
mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot - 36));
}
mc.player.networkHandler.sendPacket(new PlayerActionC2SPacket(Action.SWAP_ITEM_WITH_OFFHAND, BlockPos.ORIGIN, Direction.DOWN));
// hack
slot += 10;
return;
}
delay++;
if (delay >= getSetting(6).asSlider().getValueInt()) {
delay = 0;
int toThrow = Math.min(getSetting(5).asSlider().getValueInt(), xpNeeded);
if (toThrow != 0) {
mc.player.networkHandler.sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(mc.player.getYaw(), 90, mc.player.isOnGround()));
for (int t = 0; t < toThrow; t++) {
if (InventoryUtils.selectSlot(false, i -> mc.player.getInventory().getStack(i).getItem() == Items.EXPERIENCE_BOTTLE) == Hand.MAIN_HAND) {
// Trying to use without bruh
mc.player.networkHandler.sendPacket(new PlayerInteractItemC2SPacket(Hand.MAIN_HAND));
ItemStack itemStack2 = mc.player.getMainHandStack().use(mc.world, mc.player, Hand.MAIN_HAND).getValue();
if (itemStack2 != mc.player.getMainHandStack()) {
mc.player.setStackInHand(Hand.MAIN_HAND, itemStack2);
}
xpNeeded--;
}
}
}
}
return;
}
IntSet slots = new IntArraySet();
if (getSetting(0).asToggle().getState()) {
slots.add(5);
slots.add(6);
slots.add(7);
slots.add(8);
}
if (getSetting(1).asToggle().getState())
slots.add(36 + mc.player.getInventory().selectedSlot);
if (getSetting(2).asToggle().getState())
slots.add(45);
if (getSetting(0).asToggle().getState()) {
for (int s : slots) {
ItemStack item = mc.player.currentScreenHandler.getSlot(s).getStack();
if (item.isDamageable() && item.getMaxDamage() - item.getDamage() <= damage && item.getMaxDamage() - item.getDamage() < item.getMaxDamage() * target) {
slot = s;
xpNeeded = (int) Math.ceil((item.getMaxDamage() * target - (item.getMaxDamage() - item.getDamage())) / 14d);
return;
}
}
}
}
use of net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket in project meteor-crash-addon by AntiCope.
the class TryUseCrash method onTick.
@EventHandler
private void onTick(TickEvent.Post event) {
BlockHitResult bhr = new BlockHitResult(new Vec3d(.5, .5, .5), Direction.DOWN, mc.player.getBlockPos(), false);
net.minecraft.network.packet.c2s.play.PlayerInteractItemC2SPacket packet = new PlayerInteractItemC2SPacket(Hand.MAIN_HAND);
PlayerInteractBlockC2SPacket packet1 = new PlayerInteractBlockC2SPacket(Hand.MAIN_HAND, bhr);
if (mc.getNetworkHandler() == null)
return;
for (int i = 0; i < packets.get(); i++) {
mc.getNetworkHandler().sendPacket(packet);
mc.getNetworkHandler().sendPacket(packet1);
}
}
Aggregations