From 1c8c8ff35f2d2eae0789d6cc106a2626971f64af Mon Sep 17 00:00:00 2001 From: ThebestkillerTBK <2593828650@qq.com> Date: Thu, 2 Feb 2023 14:35:52 +0800 Subject: [PATCH] Scaffold Radius, also fixed buggy BlockUtils placement when bpt > 1 --- .../systems/modules/movement/Scaffold.java | 80 +++++++++++++++---- .../meteorclient/utils/world/BlockUtils.java | 13 ++- 2 files changed, 72 insertions(+), 21 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java index bbe8df751d..ddf18d376b 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/movement/Scaffold.java @@ -53,6 +53,14 @@ public class Scaffold extends Module { .build() ); + private final Setting cancelVelocity = sgGeneral.add(new BoolSetting.Builder() + .name("cancel-velocity") + .description("Whether or not to cancel velocity when towering.") + .defaultValue(false) + .visible(fastTower::get) + .build() + ); + private final Setting onlyOnClick = sgGeneral.add(new BoolSetting.Builder() .name("only-on-click") .description("Only places blocks when holding right click.") @@ -98,6 +106,25 @@ public class Scaffold extends Module { .build() ); + private final Setting range = sgGeneral.add(new DoubleSetting.Builder() + .name("range") + .description("Scaffold radius.") + .defaultValue(3) + .min(0) + .max(6) + .visible(() -> !airPlace.get()) + .build() + ); + + private final Setting blocksPerTick = sgGeneral.add(new IntSetting.Builder() + .name("blocks-per-tick") + .description("How many blocks to place in one tick.") + .defaultValue(3) + .min(1) + .visible(() -> !airPlace.get()) + .build() + ); + // Render private final Setting render = sgRender.add(new BoolSetting.Builder() @@ -196,12 +223,6 @@ private void onTick(TickEvent.Pre event) { bp.set(prevBp.offset(facing)); } - FindItemResult item = InvUtils.findInHotbar(itemStack -> validItem(itemStack, bp)); - if (!item.found()) return; - - - if (item.getHand() == null && !autoSwitch.get()) return; - // Move down if shifting if (mc.options.sneakKey.isPressed() && !mc.options.jumpKey.isPressed()) { if (lastSneakingY - mc.player.getY() < 0.1) { @@ -214,20 +235,36 @@ private void onTick(TickEvent.Pre event) { if (!lastWasSneaking) lastSneakingY = mc.player.getY(); if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && fastTower.get()) { - mc.player.setVelocity(0, 0.42f, 0); + Vec3d vel = mc.player.getVelocity(); + mc.player.setVelocity(cancelVelocity.get() ? 0 : vel.x, 0.42, cancelVelocity.get() ? 0 : vel.z); } - if (BlockUtils.place(bp, item, rotate.get(), 50, renderSwing.get(), true)) { - // Render block if was placed - if (render.get()) - RenderUtils.renderTickingBlock(bp.toImmutable(), sideColor.get(), lineColor.get(), shapeMode.get(), 0, 8, true, false); + if (!airPlace.get()) { + List blocks = new ArrayList<>(); + for (double x = mc.player.getX() - range.get(); x <= mc.player.getX() + range.get(); x = x + 0.5) { + for (double z = mc.player.getZ() - range.get(); z <= mc.player.getZ() + range.get(); z = z + 0.5) { + blocks.add(new BlockPos(x, mc.player.getY() - 0.5, z)); + } + } + + if (!blocks.isEmpty()) { + blocks.sort(Comparator.comparingDouble(PlayerUtils::squaredDistanceTo)); + int counter = 0; + for (BlockPos block : blocks) { + if (place(block)) counter++; - // Move player down so they are on top of the placed block ready to jump again - if (mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && !mc.player.isOnGround() && !mc.world.getBlockState(bp).isAir() && fastTower.get()) { - mc.player.setVelocity(0, -0.28f, 0); + if (counter >= blocksPerTick.get()) { + break; + } + } } } + // Move player down so they are on top of the placed block ready to jump again + if (place(bp) && fastTower.get() && mc.options.jumpKey.isPressed() && !mc.options.sneakKey.isPressed() && !mc.player.isOnGround() && !mc.world.getBlockState(bp).isAir()) { + mc.player.setVelocity(0, -0.28f, 0); + } + if (!mc.world.getBlockState(bp).isAir()) { prevBp.set(bp); } @@ -249,6 +286,21 @@ private boolean validItem(ItemStack itemStack, BlockPos pos) { return !(block instanceof FallingBlock) || !FallingBlock.canFallThrough(mc.world.getBlockState(pos)); } + private boolean place(BlockPos bp) { + FindItemResult item = InvUtils.findInHotbar(itemStack -> validItem(itemStack, bp)); + if (!item.found()) return false; + + if (item.getHand() == null && !autoSwitch.get()) return false; + + if (BlockUtils.place(bp, item, rotate.get(), 50, renderSwing.get(), true)) { + // Render block if was placed + if (render.get()) + RenderUtils.renderTickingBlock(bp.toImmutable(), sideColor.get(), lineColor.get(), shapeMode.get(), 0, 8, true, false); + return true; + } + return false; + } + public enum ListMode { Whitelist, Blacklist diff --git a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java index cdcf597a2b..da8aed1727 100644 --- a/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java +++ b/src/main/java/meteordevelopment/meteorclient/utils/world/BlockUtils.java @@ -7,7 +7,6 @@ import meteordevelopment.meteorclient.MeteorClient; import meteordevelopment.meteorclient.events.world.TickEvent; -import meteordevelopment.meteorclient.mixininterface.IVec3d; import meteordevelopment.meteorclient.utils.PreInit; import meteordevelopment.meteorclient.utils.player.FindItemResult; import meteordevelopment.meteorclient.utils.player.InvUtils; @@ -37,8 +36,6 @@ import static meteordevelopment.meteorclient.MeteorClient.mc; public class BlockUtils { - private static final Vec3d hitPos = new Vec3d(0, 0, 0); - public static boolean breaking; private static boolean breakingThisTick; @@ -82,7 +79,7 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota if (slot < 0 || slot > 8) return false; if (!canPlace(blockPos, checkEntities)) return false; - ((IVec3d) hitPos).set(blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5); + Vec3d hitPos = Vec3d.ofCenter(blockPos); BlockPos neighbour; Direction side = getPlaceSide(blockPos); @@ -97,18 +94,20 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota Direction s = side; + BlockHitResult bhr = new BlockHitResult(hitPos, s, neighbour, false); + if (rotate) { Rotations.rotate(Rotations.getYaw(hitPos), Rotations.getPitch(hitPos), rotationPriority, () -> { InvUtils.swap(slot, swapBack); - place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand); + interact(bhr, hand, swingHand); if (swapBack) InvUtils.swapBack(); }); } else { InvUtils.swap(slot, swapBack); - place(new BlockHitResult(hitPos, s, neighbour, false), hand, swingHand); + interact(bhr, hand, swingHand); if (swapBack) InvUtils.swapBack(); } @@ -117,7 +116,7 @@ public static boolean place(BlockPos blockPos, Hand hand, int slot, boolean rota return true; } - private static void place(BlockHitResult blockHitResult, Hand hand, boolean swing) { + public static void interact(BlockHitResult blockHitResult, Hand hand, boolean swing) { boolean wasSneaking = mc.player.input.sneaking; mc.player.input.sneaking = false;