From d0cdbbf60582dce56d033bf71e41bffa74c99da6 Mon Sep 17 00:00:00 2001 From: Gingerbeard Date: Thu, 5 Jun 2025 09:09:48 -0400 Subject: [PATCH 1/5] Bed Aura rewrite * Overhauled Bed Aura. It now functions more like Crystal Aura in how it places beds. --- .../systems/modules/combat/BedAura.java | 403 ++++++++++++------ 1 file changed, 276 insertions(+), 127 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java index 366a95cf4c..d95331a7d5 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java @@ -11,26 +11,32 @@ import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; import meteordevelopment.meteorclient.systems.modules.Module; -import meteordevelopment.meteorclient.utils.Utils; +import meteordevelopment.meteorclient.systems.modules.Modules; import meteordevelopment.meteorclient.utils.entity.DamageUtils; import meteordevelopment.meteorclient.utils.entity.EntityUtils; import meteordevelopment.meteorclient.utils.entity.SortPriority; import meteordevelopment.meteorclient.utils.entity.TargetUtils; import meteordevelopment.meteorclient.utils.player.*; import meteordevelopment.meteorclient.utils.render.color.SettingColor; +import meteordevelopment.meteorclient.utils.world.BlockIterator; import meteordevelopment.meteorclient.utils.world.BlockUtils; -import meteordevelopment.meteorclient.utils.world.CardinalDirection; import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.BlockState; import net.minecraft.block.BedBlock; -import net.minecraft.block.entity.BedBlockEntity; -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.block.enums.BedPart; import net.minecraft.item.BedItem; +import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.Hand; -import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; import net.minecraft.util.math.Vec3d; +import net.minecraft.util.hit.BlockHitResult; +import net.minecraft.world.RaycastContext; +import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; +import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode; + +import com.google.common.util.concurrent.AtomicDouble; +import java.util.concurrent.atomic.AtomicReference; public class BedAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); @@ -41,12 +47,36 @@ public class BedAura extends Module { // General - private final Setting delay = sgGeneral.add(new IntSetting.Builder() - .name("delay") - .description("The delay between placing beds in ticks.") - .defaultValue(9) - .min(0) - .sliderMax(20) + private final Setting place = sgGeneral.add(new BoolSetting.Builder() + .name("place") + .description("Allows Bed Aura to place beds.") + .defaultValue(true) + .build() + ); + + private final Setting placeRange = sgGeneral.add(new DoubleSetting.Builder() + .name("place-range") + .description("The range at which beds can be placed.") + .defaultValue(4) + .range(0, 6) + .visible(place::get) + .build() + ); + + private final Setting placeWallsRange = sgGeneral.add(new DoubleSetting.Builder() + .name("walls-range") + .description("Range in which to place beds when behind blocks.") + .defaultValue(4) + .range(0, 6) + .visible(place::get) + .build() + ); + + private final Setting airPlace = sgGeneral.add(new BoolSetting.Builder() + .name("air-place") + .description("Allows Bed Aura to place beds in the air.") + .defaultValue(true) + .visible(place::get) .build() ); @@ -54,33 +84,58 @@ public class BedAura extends Module { .name("strict-direction") .description("Only places beds in the direction you are facing.") .defaultValue(false) + .visible(place::get) .build() ); - // Targeting + private final Setting placeDelay = sgGeneral.add(new IntSetting.Builder() + .name("place-delay") + .description("The delay between placing beds in ticks.") + .defaultValue(10) + .range(0, 10) + .visible(place::get) + .build() + ); - private final Setting targetRange = sgTargeting.add(new DoubleSetting.Builder() - .name("target-range") - .description("The range at which players can be targeted.") - .defaultValue(4) + private final Setting breakDelay = sgGeneral.add(new IntSetting.Builder() + .name("break-delay") + .description("The tick delay between exploding beds.") + .defaultValue(2) .min(0) - .sliderMax(5) + .sliderMax(10) + .build() + ); + + private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() + .name("rotate") + .description("Rotates server-side towards the beds being broken.") + .defaultValue(true) .build() ); - private final Setting priority = sgTargeting.add(new EnumSetting.Builder() + // Targeting + + private final Setting targetPriority = sgTargeting.add(new EnumSetting.Builder() .name("target-priority") .description("How to filter targets within range.") .defaultValue(SortPriority.LowestHealth) .build() ); + private final Setting targetRange = sgTargeting.add(new DoubleSetting.Builder() + .name("target-range") + .description("Range in which to target players.") + .defaultValue(10) + .min(0) + .sliderMax(16) + .build() + ); + private final Setting minDamage = sgTargeting.add(new DoubleSetting.Builder() .name("min-damage") .description("The minimum damage to inflict on your target.") .defaultValue(7) .range(0, 36) - .sliderMax(36) .build() ); @@ -89,7 +144,6 @@ public class BedAura extends Module { .description("The maximum damage to inflict on yourself.") .defaultValue(7) .range(0, 36) - .sliderMax(36) .build() ); @@ -100,7 +154,7 @@ public class BedAura extends Module { .build() ); - // Auto move + // Inventory private final Setting autoMove = sgAutoMove.add(new BoolSetting.Builder() .name("auto-move") @@ -121,30 +175,38 @@ public class BedAura extends Module { private final Setting autoSwitch = sgAutoMove.add(new BoolSetting.Builder() .name("auto-switch") - .description("Switches to and from beds automatically.") + .description("Switches to beds automatically.") .defaultValue(true) .build() ); - // Pause - - private final Setting pauseOnEat = sgPause.add(new BoolSetting.Builder() - .name("pause-on-eat") - .description("Pauses while eating.") + private final Setting swapBack = sgAutoMove.add(new BoolSetting.Builder() + .name("swap-back") + .description("Switches to your previous slot after using beds.") .defaultValue(true) + .visible(autoSwitch::get) .build() ); - private final Setting pauseOnDrink = sgPause.add(new BoolSetting.Builder() - .name("pause-on-drink") - .description("Pauses while drinking.") + // Pause + + private final Setting pauseOnUse = sgPause.add(new BoolSetting.Builder() + .name("pause-on-use") + .description("Pauses while using an item.") .defaultValue(true) .build() ); private final Setting pauseOnMine = sgPause.add(new BoolSetting.Builder() .name("pause-on-mine") - .description("Pauses while mining.") + .description("Pauses while mining blocks.") + .defaultValue(true) + .build() + ); + + private final Setting pauseOnCA = sgPause.add(new BoolSetting.Builder() + .name("pause-on-CA") + .description("Pauses while Crystal Aura is placing.") .defaultValue(true) .build() ); @@ -169,13 +231,15 @@ public class BedAura extends Module { .name("shape-mode") .description("How the shapes are rendered.") .defaultValue(ShapeMode.Both) + .visible(render::get) .build() ); private final Setting sideColor = sgRender.add(new ColorSetting.Builder() .name("side-color") .description("The side color for positions to be placed.") - .defaultValue(new SettingColor(15, 255, 211,75)) + .defaultValue(new SettingColor(15, 255, 211, 41)) + .visible(() -> render.get() && shapeMode.get().sides()) .build() ); @@ -183,13 +247,21 @@ public class BedAura extends Module { .name("line-color") .description("The line color for positions to be placed.") .defaultValue(new SettingColor(15, 255, 211)) + .visible(() -> render.get() && shapeMode.get().lines()) .build() ); - private CardinalDirection direction; + private AtomicDouble bestPlaceDamage = new AtomicDouble(0); + private AtomicReference bestPlacePos = new AtomicReference<>(new BlockPos.Mutable()); + private AtomicReference bestPlaceDirection = new AtomicReference<>(Direction.NORTH); + + private AtomicDouble bestBreakDamage = new AtomicDouble(0); + private AtomicReference bestBreakPos = new AtomicReference<>(new BlockPos.Mutable()); + + private BlockPos renderBlockPos; + private Direction renderDirection; + private int placeDelayLeft, breakDelayLeft; private PlayerEntity target; - private BlockPos placePos, breakPos; - private int timer; public BedAura() { super(Categories.Combat, "bed-aura", "Automatically places and explodes beds in the Nether and End."); @@ -197,12 +269,20 @@ public BedAura() { @Override public void onActivate() { - timer = delay.get(); - direction = CardinalDirection.North; + renderBlockPos = null; + renderDirection = Direction.NORTH; + placeDelayLeft = placeDelay.get(); + breakDelayLeft = 0; + target = null; + } + + @Override + public void onDeactivate() { + renderBlockPos = null; } @EventHandler - private void onTick(TickEvent.Post event) { + private void onTick(TickEvent.Pre event) { // Check if beds can explode here if (mc.world.getDimension().bedWorks()) { error("You can't blow up beds in this dimension, disabling."); @@ -211,138 +291,207 @@ private void onTick(TickEvent.Post event) { } // Pause - if (PlayerUtils.shouldPause(pauseOnMine.get(), pauseOnEat.get(), pauseOnDrink.get())) return; + if (shouldPause()) { + renderBlockPos = null; + return; + } // Find a target - target = TargetUtils.getPlayerTarget(targetRange.get(), priority.get()); - if (target == null) { - placePos = null; - breakPos = null; - return; + if (TargetUtils.isBadTarget(target, targetRange.get())) { + renderBlockPos = null; + target = TargetUtils.getPlayerTarget(targetRange.get(), targetPriority.get()); + if (TargetUtils.isBadTarget(target, targetRange.get())) return; } // Auto move if (autoMove.get()) { FindItemResult bed = InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem); - - if (bed.found() && bed.slot() != autoMoveSlot.get() - 1) { + boolean alreadyHasBed = mc.player.getInventory().getStack(autoMoveSlot.get() - 1).getItem() instanceof BedItem; + if (bed.found() && !bed.isHotbar() && !alreadyHasBed) { InvUtils.move().from(bed.slot()).toHotbar(autoMoveSlot.get() - 1); } } - if (breakPos == null) { - placePos = findPlace(target); - } + doBedAura(); + } - // Place bed - if (timer <= 0 && placeBed(placePos)) { - timer = delay.get(); - } - else { - timer--; - } + private void doBedAura() { + bestPlaceDamage.set(0); + bestBreakDamage.set(0); + + // Find best position to place or break the bed + int iteratorRange = (int) Math.ceil(placeRange.get()); + BlockIterator.register(iteratorRange, iteratorRange, (blockPos, blockState) -> { + if (blockState.getBlock() instanceof BedBlock && !isGhostBed(blockPos)) { + setBreakInfo(blockPos, blockState); + } else if (place.get()) { + setPlaceInfo(blockPos); + } + }); - if (breakPos == null) breakPos = findBreak(); - breakBed(breakPos); + // Break or place + BlockIterator.after(() -> { + renderBlockPos = null; + + if (bestBreakDamage.get() > 0) { + breakBed(); + } else if (bestPlaceDamage.get() > 0) { + placeBed(); + } + }); } - private BlockPos findPlace(PlayerEntity target) { - if (!InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem).found()) return null; + private void setPlaceInfo(BlockPos footPos) { + if (!BlockUtils.canPlace(footPos) && !isGhostBed(footPos)) return; - for (int index = 0; index < 3; index++) { - int i = index == 0 ? 1 : index == 1 ? 0 : 2; + // Air place check + if (!airPlace.get() && isAirPlace(footPos)) return; - for (CardinalDirection dir : CardinalDirection.values()) { - if (strictDirection.get() - && dir.toDirection() != mc.player.getHorizontalFacing() - && dir.toDirection().getOpposite() != mc.player.getHorizontalFacing()) continue; + // Check raycast and range + if (isOutOfRange(footPos)) return; - BlockPos centerPos = target.getBlockPos().up(i); + Direction rotateDirection = Direction.fromHorizontalDegrees(Rotations.getYaw(footPos.toCenterPos())); - float headSelfDamage = DamageUtils.bedDamage(mc.player, Utils.vec3d(centerPos)); - float offsetSelfDamage = DamageUtils.bedDamage(mc.player, Utils.vec3d(centerPos.offset(dir.toDirection()))); + for (Direction placeDirection : Direction.HORIZONTAL) { + BlockPos headPos = footPos.offset(placeDirection); + if (!mc.world.getBlockState(headPos).isReplaceable() && !isGhostBed(headPos)) continue; - if (mc.world.getBlockState(centerPos).isReplaceable() - && BlockUtils.canPlace(centerPos.offset(dir.toDirection())) - && DamageUtils.bedDamage(target, Utils.vec3d(centerPos)) >= minDamage.get() - && offsetSelfDamage < maxSelfDamage.get() - && headSelfDamage < maxSelfDamage.get() - && (!antiSuicide.get() || PlayerUtils.getTotalHealth() - headSelfDamage > 0) - && (!antiSuicide.get() || PlayerUtils.getTotalHealth() - offsetSelfDamage > 0)) { - return centerPos.offset((direction = dir).toDirection()); - } + // Match our player's horizontal facing if we are using strict direction + if (strictDirection.get() && placeDirection != rotateDirection) continue; + + float targetDamage = DamageUtils.bedDamage(target, headPos.toCenterPos()); + if (isBestDamage(headPos, targetDamage, bestPlaceDamage.get())) { + bestPlaceDamage.set(targetDamage); + bestPlaceDirection.set(placeDirection); + bestPlacePos.get().set(footPos); } } - - return null; } - private BlockPos findBreak() { - for (BlockEntity blockEntity : Utils.blockEntities()) { - if (!(blockEntity instanceof BedBlockEntity)) continue; + private void setBreakInfo(BlockPos blockPos, BlockState blockState) { + // Check raycast and range + if (isOutOfRange(blockPos)) return; - BlockPos bedPos = blockEntity.getPos(); - Vec3d bedVec = Utils.vec3d(bedPos); + BlockPos otherPos = blockPos.offset(BedBlock.getOppositePartDirection(blockState)); + BlockPos headPos = blockState.get(BedBlock.PART) == BedPart.HEAD ? blockPos : otherPos; - if (PlayerUtils.isWithinReach(bedVec) - && DamageUtils.bedDamage(target, bedVec) >= minDamage.get() - && DamageUtils.bedDamage(mc.player, bedVec) < maxSelfDamage.get() - && (!antiSuicide.get() || PlayerUtils.getTotalHealth() - DamageUtils.bedDamage(mc.player, bedVec) > 0)) { - return bedPos; - } + float targetDamage = DamageUtils.bedDamage(target, headPos.toCenterPos()); + if (isBestDamage(headPos, targetDamage, bestBreakDamage.get())) { + bestBreakDamage.set(targetDamage); + bestBreakPos.get().set(blockPos); } - - return null; } - private boolean placeBed(BlockPos pos) { - if (pos == null) return false; + private boolean isBestDamage(BlockPos headPos, float targetDamage, double bestDamage) { + float selfDamage = DamageUtils.bedDamage(mc.player, headPos.toCenterPos()); + + // Is the bed optimal? + return targetDamage >= minDamage.get() && targetDamage > bestDamage + && (!antiSuicide.get() || selfDamage <= maxSelfDamage.get()) + && (!antiSuicide.get() || PlayerUtils.getTotalHealth() - selfDamage > 0); + } + private void placeBed() { FindItemResult bed = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BedItem); - if (bed.getHand() == null && !autoSwitch.get()) return false; - - double yaw = switch (direction) { - case East -> 90; - case South -> 180; - case West -> -90; - default -> 0; - }; - - Rotations.rotate(yaw, Rotations.getPitch(pos), () -> { - BlockUtils.place(pos, bed, false, 0, swing.get(), true); - breakPos = pos; + if (!bed.found()) return; + + // Set render info + renderBlockPos = bestPlacePos.get(); + renderDirection = bestPlaceDirection.get(); + + if (placeDelayLeft++ < placeDelay.get()) return; + + if (autoSwitch.get()) InvUtils.swap(bed.slot(), swapBack.get()); + + // Get rotation to use depending on what direction we are doing + double yaw = Direction.getHorizontalDegreesOrThrow(bestPlaceDirection.get()); + + // Use legit rotation if strict direction is enabled + if (strictDirection.get()) yaw = Rotations.getYaw(bestPlacePos.get()); + + // Place bed! + Rotations.rotate(yaw, Rotations.getPitch(bestPlacePos.get()), () -> { + BlockUtils.place(bestPlacePos.get(), bed, false, 0, swing.get(), true); }); + if (swapBack.get()) InvUtils.swapBack(); + + placeDelayLeft = 0; + } + + private void breakBed() { + // Set render info + renderBlockPos = bestBreakPos.get(); + renderDirection = BedBlock.getOppositePartDirection(mc.world.getBlockState(renderBlockPos)); + + if (breakDelayLeft++ < breakDelay.get()) return; + + // Stop sneaking so interactions with the bed are successful + if (mc.player.isSneaking()) { + mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.RELEASE_SHIFT_KEY)); + } + + // Break bed! + if (rotate.get()) { + Rotations.rotate(Rotations.getYaw(bestBreakPos.get()), Rotations.getPitch(bestBreakPos.get()), () -> { + BlockUtils.interact(new BlockHitResult(bestBreakPos.get().toCenterPos(), Direction.UP, bestBreakPos.get(), true), Hand.MAIN_HAND, swing.get()); + }); + } else { + BlockUtils.interact(new BlockHitResult(bestBreakPos.get().toCenterPos(), Direction.UP, bestBreakPos.get(), true), Hand.MAIN_HAND, swing.get()); + } + + breakDelayLeft = 0; + } + + private boolean isOutOfRange(BlockPos blockPos) { + Vec3d pos = blockPos.toCenterPos(); + if (!PlayerUtils.isWithin(pos, placeRange.get())) return true; + + RaycastContext raycastContext = new RaycastContext(mc.player.getEyePos(), pos, RaycastContext.ShapeType.COLLIDER, RaycastContext.FluidHandling.NONE, mc.player); + BlockHitResult result = mc.world.raycast(raycastContext); + if (result == null || !result.getBlockPos().equals(blockPos)) + return !PlayerUtils.isWithin(pos, placeWallsRange.get()); + + return false; + } + + private boolean isAirPlace(BlockPos blockPos) { + for (Direction direction : Direction.values()) { + if (!mc.world.getBlockState(blockPos.offset(direction)).isReplaceable()) return false; + } return true; } - private void breakBed(BlockPos pos) { - if (pos == null) return; - breakPos = null; + private boolean isGhostBed(BlockPos blockPos) { + BlockState blockState = mc.world.getBlockState(blockPos); + if (!(blockState.getBlock() instanceof BedBlock)) return false; + + BlockPos otherPos = blockPos.offset(BedBlock.getOppositePartDirection(blockState)); + return !(mc.world.getBlockState(otherPos).getBlock() instanceof BedBlock); + } - if (!(mc.world.getBlockState(pos).getBlock() instanceof BedBlock)) return; + private boolean shouldPause() { + if (pauseOnUse.get() && mc.player.isUsingItem()) return true; - boolean wasSneaking = mc.player.isSneaking(); - if (wasSneaking) mc.player.setSneaking(false); + if (pauseOnMine.get() && mc.interactionManager.isBreakingBlock()) return true; - mc.interactionManager.interactBlock(mc.player, Hand.OFF_HAND, new BlockHitResult(Vec3d.ofCenter(pos), Direction.UP, pos, false)); + CrystalAura CA = Modules.get().get(CrystalAura.class); + if (pauseOnCA.get() && CA.isActive() && CA.kaTimer > 0) return true; - mc.player.setSneaking(wasSneaking); + return false; } @EventHandler private void onRender(Render3DEvent event) { - if (render.get() && placePos != null && breakPos == null) { - int x = placePos.getX(); - int y = placePos.getY(); - int z = placePos.getZ(); - - switch (direction) { - case North -> event.renderer.box(x, y, z, x + 1, y + 0.6, z + 2, sideColor.get(), lineColor.get(), shapeMode.get(), 0); - case South -> event.renderer.box(x, y, z - 1, x + 1, y + 0.6, z + 1, sideColor.get(), lineColor.get(), shapeMode.get(), 0); - case East -> event.renderer.box(x - 1, y, z, x + 1, y + 0.6, z + 1, sideColor.get(), lineColor.get(), shapeMode.get(), 0); - case West -> event.renderer.box(x, y, z, x + 2, y + 0.6, z + 1, sideColor.get(), lineColor.get(), shapeMode.get(), 0); - } + if (!render.get() || renderBlockPos == null) return; + + int x = renderBlockPos.getX(), y = renderBlockPos.getY(), z = renderBlockPos.getZ(); + + switch (renderDirection) { + case Direction.SOUTH -> event.renderer.box(x, y, z, x + 1, y + 0.6, z + 2, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + case Direction.NORTH -> event.renderer.box(x, y, z - 1, x + 1, y + 0.6, z + 1, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + case Direction.WEST -> event.renderer.box(x - 1, y, z, x + 1, y + 0.6, z + 1, sideColor.get(), lineColor.get(), shapeMode.get(), 0); + case Direction.EAST -> event.renderer.box(x, y, z, x + 2, y + 0.6, z + 1, sideColor.get(), lineColor.get(), shapeMode.get(), 0); } } From 001d66e18a93e4ca74456166b6fc0f80a0499856 Mon Sep 17 00:00:00 2001 From: Gingerbeard Date: Thu, 5 Jun 2025 18:49:45 -0400 Subject: [PATCH 2/5] Removed pointless atomics --- .../systems/modules/combat/BedAura.java | 64 +++++++++---------- 1 file changed, 30 insertions(+), 34 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java index d95331a7d5..1c30689afe 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java @@ -35,9 +35,6 @@ import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket; import net.minecraft.network.packet.c2s.play.ClientCommandC2SPacket.Mode; -import com.google.common.util.concurrent.AtomicDouble; -import java.util.concurrent.atomic.AtomicReference; - public class BedAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgTargeting = settings.createGroup("Targeting"); @@ -251,12 +248,12 @@ public class BedAura extends Module { .build() ); - private AtomicDouble bestPlaceDamage = new AtomicDouble(0); - private AtomicReference bestPlacePos = new AtomicReference<>(new BlockPos.Mutable()); - private AtomicReference bestPlaceDirection = new AtomicReference<>(Direction.NORTH); + private double bestPlaceDamage; + private BlockPos.Mutable bestPlacePos = new BlockPos.Mutable(); + private Direction bestPlaceDirection; - private AtomicDouble bestBreakDamage = new AtomicDouble(0); - private AtomicReference bestBreakPos = new AtomicReference<>(new BlockPos.Mutable()); + private double bestBreakDamage; + private BlockPos.Mutable bestBreakPos = new BlockPos.Mutable(); private BlockPos renderBlockPos; private Direction renderDirection; @@ -270,7 +267,6 @@ public BedAura() { @Override public void onActivate() { renderBlockPos = null; - renderDirection = Direction.NORTH; placeDelayLeft = placeDelay.get(); breakDelayLeft = 0; target = null; @@ -316,8 +312,8 @@ private void onTick(TickEvent.Pre event) { } private void doBedAura() { - bestPlaceDamage.set(0); - bestBreakDamage.set(0); + bestPlaceDamage = 0; + bestBreakDamage = 0; // Find best position to place or break the bed int iteratorRange = (int) Math.ceil(placeRange.get()); @@ -333,10 +329,10 @@ private void doBedAura() { BlockIterator.after(() -> { renderBlockPos = null; - if (bestBreakDamage.get() > 0) { - breakBed(); - } else if (bestPlaceDamage.get() > 0) { - placeBed(); + if (bestBreakDamage > 0) { + doBreak(); + } else if (bestPlaceDamage > 0) { + doPlace(); } }); } @@ -360,10 +356,10 @@ private void setPlaceInfo(BlockPos footPos) { if (strictDirection.get() && placeDirection != rotateDirection) continue; float targetDamage = DamageUtils.bedDamage(target, headPos.toCenterPos()); - if (isBestDamage(headPos, targetDamage, bestPlaceDamage.get())) { - bestPlaceDamage.set(targetDamage); - bestPlaceDirection.set(placeDirection); - bestPlacePos.get().set(footPos); + if (isBestDamage(headPos, targetDamage, bestPlaceDamage)) { + bestPlaceDamage = targetDamage; + bestPlaceDirection = placeDirection; + bestPlacePos.set(footPos); } } } @@ -376,9 +372,9 @@ private void setBreakInfo(BlockPos blockPos, BlockState blockState) { BlockPos headPos = blockState.get(BedBlock.PART) == BedPart.HEAD ? blockPos : otherPos; float targetDamage = DamageUtils.bedDamage(target, headPos.toCenterPos()); - if (isBestDamage(headPos, targetDamage, bestBreakDamage.get())) { - bestBreakDamage.set(targetDamage); - bestBreakPos.get().set(blockPos); + if (isBestDamage(headPos, targetDamage, bestBreakDamage)) { + bestBreakDamage = targetDamage; + bestBreakPos.set(blockPos); } } @@ -391,27 +387,27 @@ private boolean isBestDamage(BlockPos headPos, float targetDamage, double bestDa && (!antiSuicide.get() || PlayerUtils.getTotalHealth() - selfDamage > 0); } - private void placeBed() { + private void doPlace() { FindItemResult bed = InvUtils.findInHotbar(itemStack -> itemStack.getItem() instanceof BedItem); if (!bed.found()) return; // Set render info - renderBlockPos = bestPlacePos.get(); - renderDirection = bestPlaceDirection.get(); + renderBlockPos = bestPlacePos; + renderDirection = bestPlaceDirection; if (placeDelayLeft++ < placeDelay.get()) return; if (autoSwitch.get()) InvUtils.swap(bed.slot(), swapBack.get()); // Get rotation to use depending on what direction we are doing - double yaw = Direction.getHorizontalDegreesOrThrow(bestPlaceDirection.get()); + double yaw = Direction.getHorizontalDegreesOrThrow(bestPlaceDirection); // Use legit rotation if strict direction is enabled - if (strictDirection.get()) yaw = Rotations.getYaw(bestPlacePos.get()); + if (strictDirection.get()) yaw = Rotations.getYaw(bestPlacePos); // Place bed! - Rotations.rotate(yaw, Rotations.getPitch(bestPlacePos.get()), () -> { - BlockUtils.place(bestPlacePos.get(), bed, false, 0, swing.get(), true); + Rotations.rotate(yaw, Rotations.getPitch(bestPlacePos), () -> { + BlockUtils.place(bestPlacePos, bed, false, 0, swing.get(), true); }); if (swapBack.get()) InvUtils.swapBack(); @@ -419,9 +415,9 @@ private void placeBed() { placeDelayLeft = 0; } - private void breakBed() { + private void doBreak() { // Set render info - renderBlockPos = bestBreakPos.get(); + renderBlockPos = bestBreakPos; renderDirection = BedBlock.getOppositePartDirection(mc.world.getBlockState(renderBlockPos)); if (breakDelayLeft++ < breakDelay.get()) return; @@ -433,11 +429,11 @@ private void breakBed() { // Break bed! if (rotate.get()) { - Rotations.rotate(Rotations.getYaw(bestBreakPos.get()), Rotations.getPitch(bestBreakPos.get()), () -> { - BlockUtils.interact(new BlockHitResult(bestBreakPos.get().toCenterPos(), Direction.UP, bestBreakPos.get(), true), Hand.MAIN_HAND, swing.get()); + Rotations.rotate(Rotations.getYaw(bestBreakPos), Rotations.getPitch(bestBreakPos), () -> { + BlockUtils.interact(new BlockHitResult(bestBreakPos.toCenterPos(), Direction.UP, bestBreakPos, true), Hand.MAIN_HAND, swing.get()); }); } else { - BlockUtils.interact(new BlockHitResult(bestBreakPos.get().toCenterPos(), Direction.UP, bestBreakPos.get(), true), Hand.MAIN_HAND, swing.get()); + BlockUtils.interact(new BlockHitResult(bestBreakPos.toCenterPos(), Direction.UP, bestBreakPos, true), Hand.MAIN_HAND, swing.get()); } breakDelayLeft = 0; From 27e2804268c0cc536ae1716c3d29db9435cb3025 Mon Sep 17 00:00:00 2001 From: Gingerbeard Date: Sat, 7 Jun 2025 11:43:16 -0400 Subject: [PATCH 3/5] Bed spoofing --- .../systems/modules/combat/BedAura.java | 67 +++++++++++++------ 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java index 1c30689afe..89f06e183e 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java @@ -7,6 +7,7 @@ import meteordevelopment.meteorclient.events.render.Render3DEvent; import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.events.world.BlockUpdateEvent; import meteordevelopment.meteorclient.renderer.ShapeMode; import meteordevelopment.meteorclient.settings.*; import meteordevelopment.meteorclient.systems.modules.Categories; @@ -103,6 +104,20 @@ public class BedAura extends Module { .build() ); + private final Setting spoofPlace = sgGeneral.add(new BoolSetting.Builder() + .name("spoof-place") + .description("Places the entire bed synchronically on your client.") + .defaultValue(true) + .build() + ); + + private final Setting spoofBreak = sgGeneral.add(new BoolSetting.Builder() + .name("spoof-break") + .description("Breaks the entire bed synchronically on your client.") + .defaultValue(true) + .build() + ); + private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() .name("rotate") .description("Rotates server-side towards the beds being broken.") @@ -318,7 +333,7 @@ private void doBedAura() { // Find best position to place or break the bed int iteratorRange = (int) Math.ceil(placeRange.get()); BlockIterator.register(iteratorRange, iteratorRange, (blockPos, blockState) -> { - if (blockState.getBlock() instanceof BedBlock && !isGhostBed(blockPos)) { + if (blockState.getBlock() instanceof BedBlock) { setBreakInfo(blockPos, blockState); } else if (place.get()) { setPlaceInfo(blockPos); @@ -338,7 +353,7 @@ private void doBedAura() { } private void setPlaceInfo(BlockPos footPos) { - if (!BlockUtils.canPlace(footPos) && !isGhostBed(footPos)) return; + if (!BlockUtils.canPlace(footPos)) return; // Air place check if (!airPlace.get() && isAirPlace(footPos)) return; @@ -350,7 +365,7 @@ private void setPlaceInfo(BlockPos footPos) { for (Direction placeDirection : Direction.HORIZONTAL) { BlockPos headPos = footPos.offset(placeDirection); - if (!mc.world.getBlockState(headPos).isReplaceable() && !isGhostBed(headPos)) continue; + if (!mc.world.getBlockState(headPos).isReplaceable()) continue; // Match our player's horizontal facing if we are using strict direction if (strictDirection.get() && placeDirection != rotateDirection) continue; @@ -422,23 +437,25 @@ private void doBreak() { if (breakDelayLeft++ < breakDelay.get()) return; - // Stop sneaking so interactions with the bed are successful - if (mc.player.isSneaking()) { - mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.RELEASE_SHIFT_KEY)); - } - // Break bed! if (rotate.get()) { - Rotations.rotate(Rotations.getYaw(bestBreakPos), Rotations.getPitch(bestBreakPos), () -> { - BlockUtils.interact(new BlockHitResult(bestBreakPos.toCenterPos(), Direction.UP, bestBreakPos, true), Hand.MAIN_HAND, swing.get()); - }); + Rotations.rotate(Rotations.getYaw(bestBreakPos), Rotations.getPitch(bestBreakPos), () -> { doInteract(); }); } else { - BlockUtils.interact(new BlockHitResult(bestBreakPos.toCenterPos(), Direction.UP, bestBreakPos, true), Hand.MAIN_HAND, swing.get()); + doInteract(); } breakDelayLeft = 0; } + private void doInteract() { + // Stop sneaking so interactions with the bed are successful + if (mc.player.isSneaking()) { + mc.player.networkHandler.sendPacket(new ClientCommandC2SPacket(mc.player, Mode.RELEASE_SHIFT_KEY)); + } + + BlockUtils.interact(new BlockHitResult(bestBreakPos.toCenterPos(), BlockUtils.getDirection(bestBreakPos), bestBreakPos, true), Hand.MAIN_HAND, swing.get()); + } + private boolean isOutOfRange(BlockPos blockPos) { Vec3d pos = blockPos.toCenterPos(); if (!PlayerUtils.isWithin(pos, placeRange.get())) return true; @@ -458,14 +475,6 @@ private boolean isAirPlace(BlockPos blockPos) { return true; } - private boolean isGhostBed(BlockPos blockPos) { - BlockState blockState = mc.world.getBlockState(blockPos); - if (!(blockState.getBlock() instanceof BedBlock)) return false; - - BlockPos otherPos = blockPos.offset(BedBlock.getOppositePartDirection(blockState)); - return !(mc.world.getBlockState(otherPos).getBlock() instanceof BedBlock); - } - private boolean shouldPause() { if (pauseOnUse.get() && mc.player.isUsingItem()) return true; @@ -477,6 +486,24 @@ private boolean shouldPause() { return false; } + @EventHandler + private void onBlockUpdate(BlockUpdateEvent event) { + // Spoof placement for instantaneous bed sync + if (spoofPlace.get() && event.newState.getBlock() instanceof BedBlock && event.oldState.isReplaceable()) { + BlockPos otherPos = event.pos.offset(BedBlock.getOppositePartDirection(event.newState)); + if (mc.world.getBlockState(otherPos).isReplaceable()) { + mc.world.setBlockState(otherPos, event.newState.with(BedBlock.PART, BedPart.HEAD), 0); + } + } + // Spoof bed breaking for instantaneous bed sync + if (spoofBreak.get() && event.oldState.getBlock() instanceof BedBlock && event.newState.isReplaceable()) { + BlockPos otherPos = event.pos.offset(BedBlock.getOppositePartDirection(event.oldState)); + if (mc.world.getBlockState(otherPos).getBlock() instanceof BedBlock) { + mc.world.setBlockState(otherPos, mc.world.getFluidState(otherPos).getBlockState(), 0); + } + } + } + @EventHandler private void onRender(Render3DEvent event) { if (!render.get() || renderBlockPos == null) return; From 72b2c4eac652e766841416c23a9b943628a5e899 Mon Sep 17 00:00:00 2001 From: Gingerbeard Date: Sat, 7 Jun 2025 22:04:18 -0400 Subject: [PATCH 4/5] Fixed Bed Aura automove and autoswitch --- .../systems/modules/combat/BedAura.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java index 89f06e183e..8aa3097d27 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java @@ -39,7 +39,7 @@ public class BedAura extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); private final SettingGroup sgTargeting = settings.createGroup("Targeting"); - private final SettingGroup sgAutoMove = settings.createGroup("Inventory"); + private final SettingGroup sgInventory = settings.createGroup("Inventory"); private final SettingGroup sgPause = settings.createGroup("Pause"); private final SettingGroup sgRender = settings.createGroup("Render"); @@ -89,7 +89,7 @@ public class BedAura extends Module { private final Setting placeDelay = sgGeneral.add(new IntSetting.Builder() .name("place-delay") .description("The delay between placing beds in ticks.") - .defaultValue(10) + .defaultValue(5) .range(0, 10) .visible(place::get) .build() @@ -98,7 +98,7 @@ public class BedAura extends Module { private final Setting breakDelay = sgGeneral.add(new IntSetting.Builder() .name("break-delay") .description("The tick delay between exploding beds.") - .defaultValue(2) + .defaultValue(0) .min(0) .sliderMax(10) .build() @@ -168,14 +168,14 @@ public class BedAura extends Module { // Inventory - private final Setting autoMove = sgAutoMove.add(new BoolSetting.Builder() + private final Setting autoMove = sgInventory.add(new BoolSetting.Builder() .name("auto-move") .description("Moves beds into a selected hotbar slot.") .defaultValue(false) .build() ); - private final Setting autoMoveSlot = sgAutoMove.add(new IntSetting.Builder() + private final Setting autoMoveSlot = sgInventory.add(new IntSetting.Builder() .name("auto-move-slot") .description("The slot auto move moves beds to.") .defaultValue(9) @@ -185,14 +185,14 @@ public class BedAura extends Module { .build() ); - private final Setting autoSwitch = sgAutoMove.add(new BoolSetting.Builder() + private final Setting autoSwitch = sgInventory.add(new BoolSetting.Builder() .name("auto-switch") .description("Switches to beds automatically.") .defaultValue(true) .build() ); - private final Setting swapBack = sgAutoMove.add(new BoolSetting.Builder() + private final Setting swapBack = sgInventory.add(new BoolSetting.Builder() .name("swap-back") .description("Switches to your previous slot after using beds.") .defaultValue(true) @@ -314,12 +314,12 @@ private void onTick(TickEvent.Pre event) { if (TargetUtils.isBadTarget(target, targetRange.get())) return; } - // Auto move + // Auto move beds from inventory if (autoMove.get()) { FindItemResult bed = InvUtils.find(itemStack -> itemStack.getItem() instanceof BedItem); boolean alreadyHasBed = mc.player.getInventory().getStack(autoMoveSlot.get() - 1).getItem() instanceof BedItem; if (bed.found() && !bed.isHotbar() && !alreadyHasBed) { - InvUtils.move().from(bed.slot()).toHotbar(autoMoveSlot.get() - 1); + InvUtils.quickSwap().fromId(autoMoveSlot.get() - 1).to(bed.slot()); } } @@ -414,6 +414,8 @@ private void doPlace() { if (autoSwitch.get()) InvUtils.swap(bed.slot(), swapBack.get()); + if (!mc.player.isHolding(itemStack -> itemStack.getItem() instanceof BedItem)) return; + // Get rotation to use depending on what direction we are doing double yaw = Direction.getHorizontalDegreesOrThrow(bestPlaceDirection); @@ -422,12 +424,9 @@ private void doPlace() { // Place bed! Rotations.rotate(yaw, Rotations.getPitch(bestPlacePos), () -> { - BlockUtils.place(bestPlacePos, bed, false, 0, swing.get(), true); + BlockUtils.place(bestPlacePos, bed, false, 0, swing.get(), true, swapBack.get()); + placeDelayLeft = 0; }); - - if (swapBack.get()) InvUtils.swapBack(); - - placeDelayLeft = 0; } private void doBreak() { @@ -443,8 +442,6 @@ private void doBreak() { } else { doInteract(); } - - breakDelayLeft = 0; } private void doInteract() { @@ -454,6 +451,7 @@ private void doInteract() { } BlockUtils.interact(new BlockHitResult(bestBreakPos.toCenterPos(), BlockUtils.getDirection(bestBreakPos), bestBreakPos, true), Hand.MAIN_HAND, swing.get()); + breakDelayLeft = 0; } private boolean isOutOfRange(BlockPos blockPos) { From 56e747f4588b670a883a6a4534f71dd1a59457f8 Mon Sep 17 00:00:00 2001 From: Gingerbeard Date: Thu, 12 Jun 2025 12:18:26 -0400 Subject: [PATCH 5/5] Fixed wrong maximum for damage settings --- .../meteorclient/systems/modules/combat/BedAura.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java index 8aa3097d27..94484916fd 100644 --- a/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java +++ b/src/main/java/meteordevelopment/meteorclient/systems/modules/combat/BedAura.java @@ -147,7 +147,8 @@ public class BedAura extends Module { .name("min-damage") .description("The minimum damage to inflict on your target.") .defaultValue(7) - .range(0, 36) + .min(0) + .sliderMax(36) .build() ); @@ -155,7 +156,8 @@ public class BedAura extends Module { .name("max-self-damage") .description("The maximum damage to inflict on yourself.") .defaultValue(7) - .range(0, 36) + .min(0) + .sliderMax(36) .build() );