From b8b5e08bfcddf83e5a01c1fff3bc3bb19c651819 Mon Sep 17 00:00:00 2001 From: noil Date: Mon, 28 Dec 2020 18:40:03 -0500 Subject: [PATCH] NukerModule: Creative nuker mode now only allowed in creative --- .../impl/module/world/NukerModule.java | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/java/me/rigamortis/seppuku/impl/module/world/NukerModule.java b/src/main/java/me/rigamortis/seppuku/impl/module/world/NukerModule.java index bf16a6f..e233b16 100644 --- a/src/main/java/me/rigamortis/seppuku/impl/module/world/NukerModule.java +++ b/src/main/java/me/rigamortis/seppuku/impl/module/world/NukerModule.java @@ -71,38 +71,40 @@ public final class NukerModule extends Module { pos = this.getClosestBlock(false); break; case CREATIVE: - /* the amazing creative nuker straight from the latch hacked client */ - for (double y = Math.round(mc.player.posY - 1) + this.vDistance.getValue(); y > Math.round(mc.player.posY - 1); y -= 1.0D) { - for (double x = mc.player.posX - this.hDistance.getValue(); x < mc.player.posX + this.hDistance.getValue(); x += 1.0D) { - for (double z = mc.player.posZ - this.hDistance.getValue(); z < mc.player.posZ + this.hDistance.getValue(); z += 1.0D) { - final BlockPos blockPos = new BlockPos(x, y, z); - final Block block = BlockUtil.getBlock(blockPos); - if (block == Blocks.AIR || !mc.world.getBlockState(blockPos).isFullBlock()) - continue; - - final Vec3d eyesPos = new Vec3d(mc.player.posX, mc.player.posY + mc.player.getEyeHeight(), mc.player.posZ); - final Vec3d posVec = new Vec3d(blockPos).add(0.5f, 0.5f, 0.5f); - double distanceSqPosVec = eyesPos.squareDistanceTo(posVec); - - for (EnumFacing side : EnumFacing.values()) { - final Vec3d hitVec = posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5f)); - double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec); - - // check if hitVec is within range (6 blocks) - if (distanceSqHitVec > 36) + if (mc.player.capabilities.isCreativeMode) { + /* the amazing creative 'nuker' straight from the latch hacked client */ + for (double y = Math.round(mc.player.posY - 1) + this.vDistance.getValue(); y > Math.round(mc.player.posY - 1); y -= 1.0D) { + for (double x = mc.player.posX - this.hDistance.getValue(); x < mc.player.posX + this.hDistance.getValue(); x += 1.0D) { + for (double z = mc.player.posZ - this.hDistance.getValue(); z < mc.player.posZ + this.hDistance.getValue(); z += 1.0D) { + final BlockPos blockPos = new BlockPos(x, y, z); + final Block block = BlockUtil.getBlock(blockPos); + if (block == Blocks.AIR || !mc.world.getBlockState(blockPos).isFullBlock()) continue; - // check if side is facing towards player - if (distanceSqHitVec >= distanceSqPosVec) - continue; + final Vec3d eyesPos = new Vec3d(mc.player.posX, mc.player.posY + mc.player.getEyeHeight(), mc.player.posZ); + final Vec3d posVec = new Vec3d(blockPos).add(0.5f, 0.5f, 0.5f); + double distanceSqPosVec = eyesPos.squareDistanceTo(posVec); - // face block - final float[] rotations = EntityUtil.getRotations(hitVec.x, hitVec.y, hitVec.z); - Seppuku.INSTANCE.getRotationManager().setPlayerRotations(rotations[0], rotations[1]); + for (EnumFacing side : EnumFacing.values()) { + final Vec3d hitVec = posVec.add(new Vec3d(side.getDirectionVec()).scale(0.5f)); + double distanceSqHitVec = eyesPos.squareDistanceTo(hitVec); - // damage block - if (mc.playerController.onPlayerDamageBlock(blockPos, side)) { - mc.player.swingArm(EnumHand.MAIN_HAND); + // check if hitVec is within range (6 blocks) + if (distanceSqHitVec > 36) + continue; + + // check if side is facing towards player + if (distanceSqHitVec >= distanceSqPosVec) + continue; + + // face block + final float[] rotations = EntityUtil.getRotations(hitVec.x, hitVec.y, hitVec.z); + Seppuku.INSTANCE.getRotationManager().setPlayerRotations(rotations[0], rotations[1]); + + // damage block + if (mc.playerController.onPlayerDamageBlock(blockPos, side)) { + mc.player.swingArm(EnumHand.MAIN_HAND); + } } } }