From 52a7f15a8fe1c3e552328d261f7a8bf460c17c06 Mon Sep 17 00:00:00 2001 From: bush-did-711 <39170869+bush-did-711@users.noreply.github.com> Date: Mon, 24 May 2021 22:40:20 -0700 Subject: [PATCH] Added Instaburrow and a few other options for reliability --- .../impl/module/combat/BurrowModule.java | 171 ++++++++++-------- 1 file changed, 99 insertions(+), 72 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/combat/BurrowModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/combat/BurrowModule.java index cb0204e..8aa2559 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/combat/BurrowModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/combat/BurrowModule.java @@ -13,6 +13,8 @@ import me.rigamortis.seppuku.api.value.Value; import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; +import net.minecraft.entity.Entity; +import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Blocks; import net.minecraft.network.play.client.CPacketAnimation; import net.minecraft.network.play.client.CPacketEntityAction; @@ -20,6 +22,7 @@ import net.minecraft.network.play.client.CPacketPlayer; import net.minecraft.network.play.client.CPacketPlayerTryUseItemOnBlock; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; +import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import team.stiff.pomelo.impl.annotated.handler.annotation.Listener; @@ -37,17 +40,17 @@ public final class BurrowModule extends Module { public final Value glitchY = new Value<>("ModeGlitchY", new String[]{"mgy", "glitchy"}, "Using GLITCH mode, this will be your player's motionY.", 0.5f, 0.1f, 1.5f, 0.1f); public final Value tpHeight = new Value<>("ModeTPHeight", new String[]{"mtph", "mth", "tpheight", "tpy"}, "Using TP mode, this will be how many blocks above the player to TP.", 20, -30, 30, 1); public final Value delay = new Value<>("ModeDelay", new String[]{"del", "d"}, "Delay(ms) to wait for placing obsidian after the initial jump. Not used in INSTA mode.", 200.0f, 1.0f, 500.0f, 1.0f); - public final Value smartTp = new Value<>("ModeSmartTp", new String[]{"smart", "adaptivetp", "a", "atp"}, "Searches for an air block to tp to for INSTA mode.", false); + public final Value smartTp = new Value<>("ModeSmartTp", new String[]{"smart", "adaptivetp", "a", "atp"}, "Searches for an air block to tp to for INSTA mode.", true); public final Value noVoid = new Value<>("ModeNoVoid", new String[]{"nonegative", "nv"}, "Doesn't tp you under Y 0", true); public final Value rotate = new Value<>("Rotate", new String[]{"rot", "r"}, "Rotate the players head to place the block.", true); public final Value center = new Value<>("Center", new String[]{"centered", "c", "cen"}, "Centers the player on their current block when beginning to place.", false); public final Value offGround = new Value<>("OffGround", new String[]{"offg", "og", "o"}, "Forces player onGround to false when enabled.", true); - public final Value sneaking = new Value<>("Sneaking", new String[]{"sneak", "s", "sneaking"}, "Makes player sneak when enabled.", false); + public final Value sneaking = new Value<>("Sneaking", new String[]{"sneak", "s", "fs", "sneaking"}, "Forces player to sneak when enabled.", false); private final Timer timer = new Timer(); private final RotationTask rotationTask = new RotationTask("BurrowTask", 9); // 9 == high priority - private BlockPos originalPos; + private BlockPos burrowPos; public BurrowModule() { super("Burrow", new String[]{"burow", "burro", "brrw"}, "Places obsidian on yourself.", "NONE", -1, ModuleType.COMBAT); @@ -58,41 +61,33 @@ public final class BurrowModule extends Module { super.onEnable(); final Minecraft mc = Minecraft.getMinecraft(); - originalPos = new BlockPos(mc.player.posX, mc.player.posY, mc.player.posZ); - if (mc.player != null) { - if (InventoryUtil.getBlockCount(Blocks.OBSIDIAN) > 0) { - if (adaptiveTpHeight() != 69420) { // this is really stupid but it works - // attempt to center - if (this.center.getValue()) { - final double[] newPos = {Math.floor(mc.player.posX) + 0.5d, mc.player.posY, Math.floor(mc.player.posZ) + 0.5d}; - final CPacketPlayer.Position middleOfPos = new CPacketPlayer.Position(newPos[0], newPos[1], newPos[2], mc.player.onGround); - if (!mc.world.isAirBlock(new BlockPos(newPos[0], newPos[1], newPos[2]).down())) { - if (mc.player.posX != middleOfPos.x && mc.player.posZ != middleOfPos.z) { - mc.player.connection.sendPacket(middleOfPos); - mc.player.setPosition(newPos[0], newPos[1], newPos[2]); - } - } - } + burrowPos = new BlockPos(mc.player.posX, Math.ceil(mc.player.posY), mc.player.posZ); + // ceil so you can burrow ontop of echests, path blocks etc (minor detail) - if (this.mode.getValue() == Mode.INSTA) { // these 4 lines aren't mine, they're from https://github.com/ciruu1/InstantBurrow - mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.41999998688698D, mc.player.posZ, true)); - mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.7531999805211997D, mc.player.posZ, true)); - mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 1.00133597911214D, mc.player.posZ, true)); - mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 1.16610926093821D, mc.player.posZ, true)); - } else { - mc.player.jump(); // jump - this.timer.reset(); // start timer + if (doChecks()) { + // attempt to center + if (this.center.getValue()) { + final double[] newPos = {Math.floor(mc.player.posX) + 0.5d, mc.player.posY, Math.floor(mc.player.posZ) + 0.5d}; + final CPacketPlayer.Position middleOfPos = new CPacketPlayer.Position(newPos[0], newPos[1], newPos[2], mc.player.onGround); + if (!mc.world.isAirBlock(new BlockPos(newPos[0], newPos[1], newPos[2]).down())) { + if (mc.player.posX != middleOfPos.x && mc.player.posZ != middleOfPos.z) { + mc.player.connection.sendPacket(middleOfPos); + mc.player.setPosition(newPos[0], newPos[1], newPos[2]); } - - } else { - Seppuku.INSTANCE.getNotificationManager().addNotification("", "Not enough space to burrow", Notification.Type.WARNING, 3000); - this.toggle(); } - - } else { - Seppuku.INSTANCE.getNotificationManager().addNotification("", "You don't have any obsidian to use " + this.getDisplayName(), Notification.Type.WARNING, 3000); - this.toggle(); // toggle off } + + if (this.mode.getValue() == Mode.INSTA) { // these 4 lines aren't mine, they're from https://github.com/ciruu1/InstantBurrow + mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.41999998688698D, mc.player.posZ, true)); + mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 0.7531999805211997D, mc.player.posZ, true)); + mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 1.00133597911214D, mc.player.posZ, true)); + mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, mc.player.posY + 1.16610926093821D, mc.player.posZ, true)); + } else { + mc.player.jump(); // jump + this.timer.reset(); // start timer + } + } else { + this.toggle(); } } @@ -111,43 +106,37 @@ public final class BurrowModule extends Module { switch (event.getStage()) { case PRE: if (this.timer.passed(this.delay.getValue()) || this.mode.getValue() == Mode.INSTA) { - if (InventoryUtil.getBlockCount(Blocks.OBSIDIAN) > 0) { - // get our hand swap context and ensure we have obsidian - final HandSwapContext handSwapContext = new HandSwapContext( - mc.player.inventory.currentItem, InventoryUtil.findObsidianInHotbar(mc.player)); - if (handSwapContext.getNewSlot() == -1) { - Seppuku.INSTANCE.getRotationManager().finishTask(this.rotationTask); - return; - } + // get our hand swap context and ensure we have obsidian + final HandSwapContext handSwapContext = new HandSwapContext( + mc.player.inventory.currentItem, InventoryUtil.findObsidianInHotbar(mc.player)); - Seppuku.INSTANCE.getRotationManager().startTask(this.rotationTask); - if (this.rotationTask.isOnline()) { - // swap to obby - handSwapContext.handleHandSwap(false, mc); + Seppuku.INSTANCE.getRotationManager().startTask(this.rotationTask); + if (this.rotationTask.isOnline()) { + // swap to obby + handSwapContext.handleHandSwap(false, mc); - if (this.place(originalPos, mc)) { // we've attempted to place the block - if (this.offGround.getValue()) { - mc.player.onGround = false; // set onground to false - } - - switch (this.mode.getValue()) { - case JUMP: - mc.player.jump(); // attempt another jump to flag ncp - break; - case GLITCH: - mc.player.motionY = this.glitchY.getValue(); - break; - default: // tp and insta mode are the same - mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, (this.smartTp.getValue() ? adaptiveTpHeight() : mc.player.posY + this.tpHeight.getValue()), mc.player.posZ, mc.player.onGround)); - break; - } + if (this.place(burrowPos, mc)) { // we've attempted to place the block + if (this.offGround.getValue()) { + mc.player.onGround = false; // set onground to false } - // swap back to original - handSwapContext.handleHandSwap(true, mc); - - this.toggle(); // toggle off the module + switch (this.mode.getValue()) { + case JUMP: + mc.player.jump(); // attempt another jump to flag ncp + break; + case GLITCH: + mc.player.motionY = this.glitchY.getValue(); + break; + default: // tp and insta mode are the same + mc.player.connection.sendPacket(new CPacketPlayer.Position(mc.player.posX, (this.smartTp.getValue() ? adaptiveTpHeight() : mc.player.posY + this.tpHeight.getValue()), mc.player.posZ, mc.player.onGround)); + break; + } } + + // swap back to original + handSwapContext.handleHandSwap(true, mc); + + this.toggle(); // toggle off the module } } break; @@ -170,21 +159,59 @@ public final class BurrowModule extends Module { final Minecraft mc = Minecraft.getMinecraft(); int airblock = (-1 * Math.abs(tpHeight.getValue())); - if (noVoid.getValue() && airblock + mc.player.posY - 1 < 0) { + if (noVoid.getValue() && airblock + mc.player.posY < 1) { airblock = 3; - } // set start search height + } // set lowest tp height while (airblock < Math.abs(tpHeight.getValue())) { - if (Math.abs(airblock) < 3 || !mc.world.isAirBlock(originalPos.offset(EnumFacing.UP, airblock)) || !mc.world.isAirBlock(originalPos.offset(EnumFacing.UP, airblock + 1))) { + if (Math.abs(airblock) < 3 || !mc.world.isAirBlock(burrowPos.offset(EnumFacing.UP, airblock)) || !mc.world.isAirBlock(burrowPos.offset(EnumFacing.UP, airblock + 1))) { airblock++; } else { - return originalPos.getY() + airblock; + return burrowPos.getY() + airblock; } } return 69420; // if there isn't any room } + private boolean doChecks() { + final Minecraft mc = Minecraft.getMinecraft(); + + if (mc.player != null) { + if (InventoryUtil.getBlockCount(Blocks.OBSIDIAN) == 0) { // check for obsidian + Seppuku.INSTANCE.getNotificationManager().addNotification("", "You don't have any obsidian to use " + this.getDisplayName(), Notification.Type.WARNING, 3000); + return false; + } else if (InventoryUtil.findObsidianInHotbar(mc.player) == -1) { + Seppuku.INSTANCE.getNotificationManager().addNotification("", "No obsidian in hotbar", Notification.Type.WARNING, 3000); + return false; + } + + if (mode.getValue() == Mode.INSTA || mode.getValue() == Mode.TP) { + if (adaptiveTpHeight() == 69420) { // check if there is room to tp + Seppuku.INSTANCE.getNotificationManager().addNotification("", "Not enough space to use " + this.getDisplayName(), Notification.Type.WARNING, 3000); + return false; + } + } + + if (mc.world.getBlockState(burrowPos).getBlock().equals(Blocks.OBSIDIAN)) { // is the player already burrowed + return false; + } + + for (final Entity entity : mc.world.loadedEntityList) { + if (!(entity instanceof EntityItem) && !entity.equals(mc.player)) { + if (new AxisAlignedBB(burrowPos).intersects(entity.getEntityBoundingBox())) { // is there another player in the hole + Seppuku.INSTANCE.getNotificationManager().addNotification("", "Not enough space to use " + this.getDisplayName(), Notification.Type.WARNING, 3000); + return false; + } + } + } + + return true; + } + + return false; + } + private boolean place(final BlockPos pos, final Minecraft mc) { final Block block = mc.world.getBlockState(pos).getBlock(); @@ -194,7 +221,7 @@ public final class BurrowModule extends Module { final boolean activated = block.onBlockActivated(mc.world, pos, mc.world.getBlockState(pos), mc.player, EnumHand.MAIN_HAND, direction, 0, 0, 0); - if (activated && sneaking.getValue()) + if (activated || sneaking.getValue()) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.START_SNEAKING)); final EnumFacing otherSide = direction.getOpposite(); @@ -208,7 +235,7 @@ public final class BurrowModule extends Module { mc.player.connection.sendPacket(new CPacketPlayerTryUseItemOnBlock(sideOffset, otherSide, EnumHand.MAIN_HAND, 0.5F, 0.5F, 0.5F)); mc.player.connection.sendPacket(new CPacketAnimation(EnumHand.MAIN_HAND)); - if (activated && sneaking.getValue()) + if (activated || sneaking.getValue()) mc.player.connection.sendPacket(new CPacketEntityAction(mc.player, CPacketEntityAction.Action.STOP_SNEAKING)); return true;