From 529befc718dc1a5f986ede9dc3630cf9fcd58a1c Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Tue, 11 Apr 2023 16:53:28 +0700 Subject: [PATCH] add cool feature !!!! --- .../chomens_bot/plugins/CorePlugin.java | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CorePlugin.java b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CorePlugin.java index 3d0b12ae..ed38f82c 100644 --- a/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CorePlugin.java +++ b/src/main/java/land/chipmunk/chayapak/chomens_bot/plugins/CorePlugin.java @@ -109,6 +109,28 @@ public class CorePlugin extends PositionPlugin.PositionListener { return future; } + public void runPlaceBlock (String command) { + if (!ready) return; + + Map tag = new HashMap<>(); + Map blockEntityTag = new HashMap<>(); + blockEntityTag.put("Command", new StringTag("Command", command)); + blockEntityTag.put("auto", new ByteTag("auto", (byte) 1)); + blockEntityTag.put("TrackOutput", new ByteTag("TrackOutput", (byte) 1)); + tag.put("BlockEntityTag", new CompoundTag("BlockEntityTag", blockEntityTag)); + + final Vector3i temporaryBlockPosition = Vector3i.from( + bot.position().position().getX(), + bot.position().position().getY() - 1, + bot.position().position().getZ() + ); + + final Session session = bot.session(); + session.send(new ServerboundSetCreativeModeSlotPacket(36, new ItemStack(kaboom ? 466 /* repeating command block id */ : 347 /* command block id */, 64, new CompoundTag("", tag)))); + session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0)); + session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.UP, Hand.MAIN_HAND, 0.5f, 0.5f, 0.5f, false, 1)); + } + public void packetReceived (ClientboundTagQueryPacket packet) { transactions.get(packet.getTransactionId()).complete(packet.getNbt()); } @@ -184,23 +206,7 @@ public class CorePlugin extends PositionPlugin.PositionListener { // bot.chat().send(command); - Map tag = new HashMap<>(); - Map blockEntityTag = new HashMap<>(); - blockEntityTag.put("Command", new StringTag("Command", command)); - blockEntityTag.put("auto", new ByteTag("auto", (byte) 1)); - blockEntityTag.put("TrackOutput", new ByteTag("TrackOutput", (byte) 1)); - tag.put("BlockEntityTag", new CompoundTag("BlockEntityTag", blockEntityTag)); - - final Vector3i temporaryBlockPosition = Vector3i.from( - bot.position().position().getX(), - bot.position().position().getY() - 1, - bot.position().position().getZ() - ); - - final Session session = bot.session(); - session.send(new ServerboundSetCreativeModeSlotPacket(36, new ItemStack(kaboom ? 466 /* repeating command block id */ : 347 /* command block id */, 64, new CompoundTag("", tag)))); - session.send(new ServerboundPlayerActionPacket(PlayerAction.START_DIGGING, temporaryBlockPosition, Direction.NORTH, 0)); - session.send(new ServerboundUseItemOnPacket(temporaryBlockPosition, Direction.UP, Hand.MAIN_HAND, 0.5f, 0.5f, 0.5f, false, 1)); + runPlaceBlock(command); } public static class Listener {