use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project meteor-rejects by AntiCope.
the class GhostCommand method execute.
private void execute(int radius) {
ClientPlayNetworkHandler conn = mc.getNetworkHandler();
if (conn == null)
return;
BlockPos pos = mc.player.getBlockPos();
for (int dx = -radius; dx <= radius; dx++) for (int dy = -radius; dy <= radius; dy++) for (int dz = -radius; dz <= radius; dz++) {
PlayerActionC2SPacket packet = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, new BlockPos(pos.getX() + dx, pos.getY() + dy, pos.getZ() + dz), Direction.UP);
conn.sendPacket(packet);
}
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project BleachHack by BleachDrinker420.
the class AutoTool method onPacketSend.
@BleachSubscribe
public void onPacketSend(EventPacket.Send event) {
if (event.getPacket() instanceof PlayerActionC2SPacket) {
PlayerActionC2SPacket p = (PlayerActionC2SPacket) event.getPacket();
if (p.getAction() == Action.START_DESTROY_BLOCK) {
if (mc.player.isCreative() || mc.player.isSpectator())
return;
queueSlot = -1;
lastSlot = mc.player.getInventory().selectedSlot;
int slot = getBestSlot(p.getPos());
if (slot != mc.player.getInventory().selectedSlot) {
if (slot < 9) {
mc.player.getInventory().selectedSlot = slot;
mc.player.networkHandler.sendPacket(new UpdateSelectedSlotC2SPacket(slot));
} else if (mc.player.playerScreenHandler == mc.player.currentScreenHandler) {
boolean itemInHand = !mc.player.getInventory().getMainHandStack().isEmpty();
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, slot, 0, SlotActionType.PICKUP, mc.player);
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, 36 + mc.player.getInventory().selectedSlot, 0, SlotActionType.PICKUP, mc.player);
if (itemInHand)
mc.interactionManager.clickSlot(mc.player.currentScreenHandler.syncId, slot, 0, SlotActionType.PICKUP, mc.player);
}
}
} else if (p.getAction() == Action.STOP_DESTROY_BLOCK) {
if (getSetting(1).asToggle().getState()) {
ItemStack handSlot = mc.player.getMainHandStack();
if (getSetting(0).asToggle().getState() && handSlot.isDamageable() && handSlot.getMaxDamage() - handSlot.getDamage() < 2 && queueSlot == mc.player.getInventory().selectedSlot) {
queueSlot = mc.player.getInventory().selectedSlot == 0 ? 1 : mc.player.getInventory().selectedSlot - 1;
} else if (lastSlot >= 0 && lastSlot <= 8 && lastSlot != mc.player.getInventory().selectedSlot) {
queueSlot = lastSlot;
}
}
}
}
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket 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.PlayerActionC2SPacket in project SeedcrackerX by 19MisterX98.
the class BlockUpdateQueue method tick.
public void tick() {
if (blocksAndAction.isEmpty())
return;
Pair<Thread, ArrayList<BlockPos>> current = blocksAndAction.peek();
ArrayList<BlockPos> currentBlocks = current.getRight();
for (int i = 0; i < 5; i++) {
if (currentBlocks.isEmpty()) {
current.getLeft().start();
blocksAndAction.remove();
if (blocksAndAction.isEmpty()) {
return;
} else {
current = blocksAndAction.peek();
currentBlocks = current.getRight();
}
}
if (MinecraftClient.getInstance().getNetworkHandler() == null) {
blocksAndAction.clear();
return;
}
PlayerActionC2SPacket p = new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.ABORT_DESTROY_BLOCK, currentBlocks.remove(0), Direction.DOWN);
MinecraftClient.getInstance().getNetworkHandler().sendPacket(p);
}
}
use of net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket in project orion by AntiCope.
the class AutoCityPlus method mine.
private void mine(BlockPos blockPos) {
if (!instant.get())
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.START_DESTROY_BLOCK, blockPos, Direction.UP));
mc.player.swingHand(Hand.MAIN_HAND);
mc.getNetworkHandler().sendPacket(new PlayerActionC2SPacket(PlayerActionC2SPacket.Action.STOP_DESTROY_BLOCK, blockPos, Direction.UP));
}
Aggregations