diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESP.java b/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESP.java index 00f9186a..6554de9a 100644 --- a/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESP.java +++ b/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESP.java @@ -1,134 +1,142 @@ package me.zeroeightsix.kami.module.modules.bewwawho.render; -import me.zeroeightsix.kami.command.Command; import me.zeroeightsix.kami.event.events.RenderEvent; import me.zeroeightsix.kami.module.Module; import me.zeroeightsix.kami.module.ModuleManager; +import me.zeroeightsix.kami.module.modules.combat.CrystalAura; import me.zeroeightsix.kami.setting.Setting; import me.zeroeightsix.kami.setting.Settings; import me.zeroeightsix.kami.util.GeometryMasks; import me.zeroeightsix.kami.util.KamiTessellator; import net.minecraft.block.Block; -import net.minecraft.block.material.Material; import net.minecraft.init.Blocks; import net.minecraft.util.math.BlockPos; import org.lwjgl.opengl.GL11; -import java.util.ArrayList; +import java.awt.*; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; -/*** - * @author S-B99 - * Created by @S-B99 on 30/11/19 +import static me.zeroeightsix.kami.module.modules.combat.CrystalAura.getPlayerPos; + +/** + * Created 16 November 2019 by hub + * Updated by S-B99 on 15/12/19 */ -@Module.Info(name = "HoleESP", category = Module.Category.RENDER) +@Module.Info(name = "HoleESP", category = Module.Category.RENDER, description = "Show safe holes") public class HoleESP extends Module { - private ArrayList holesObby = new ArrayList(); - private ArrayList holesBedr = new ArrayList(); - private static long startTime = 0; - private static long startTimeTwo = 0; + private final BlockPos[] surroundOffset = { + new BlockPos(0, -1, 0), // down + new BlockPos(0, 0, -1), // north + new BlockPos(1, 0, 0), // east + new BlockPos(0, 0, 1), // south + new BlockPos(-1, 0, 0) // west + }; + private Setting renderDistance = register(Settings.d("Render Distance", 8.0d)); private Setting renObby = register(Settings.b("Render Obby", true)); private Setting renBedr = register(Settings.b("Render Bedrock", true)); - // private Setting speed = register(Settings.doubleBuilder().withName("Calculate speed").withMinimum(0.1).withValue(3.0).withMaximum(10.0).build()); - private Setting distance = register(Settings.integerBuilder().withName("Distance").withMinimum(1).withValue(5).withMaximum(20).build()); - private Setting a = register(Settings.integerBuilder("Transparency (Obby)").withMinimum(0).withValue(26).withMaximum(255).build()); - private Setting r = register(Settings.integerBuilder("Red (Obby)").withMinimum(0).withValue(144).withMaximum(255).build()); - private Setting g = register(Settings.integerBuilder("Green (Obby)").withMinimum(0).withValue(144).withMaximum(255).build()); - private Setting b = register(Settings.integerBuilder("Blue (Obby)").withMinimum(0).withValue(255).withMaximum(255).build()); - private Setting a2 = register(Settings.integerBuilder("Transparency (Bedrock)").withMinimum(0).withValue(26).withMaximum(255).build()); - private Setting r2 = register(Settings.integerBuilder("Red (Bedrock)").withMinimum(0).withValue(208).withMaximum(255).build()); + private Setting renderMode = register(Settings.e("Render Mode", RenderMode.BLOCK)); + private Setting a0 = register(Settings.integerBuilder("Transparency").withMinimum(0).withValue(32).withMaximum(255).build()); + private Setting r1 = register(Settings.integerBuilder("Red (Obby)").withMinimum(0).withValue(208).withMaximum(255).build()); // 144 + private Setting g1 = register(Settings.integerBuilder("Green (Obby)").withMinimum(0).withValue(144).withMaximum(255).build()); + private Setting b1 = register(Settings.integerBuilder("Blue (Obby)").withMinimum(0).withValue(255).withMaximum(255).build()); + private Setting r2 = register(Settings.integerBuilder("Red (Bedrock)").withMinimum(0).withValue(144).withMaximum(255).build()); // 208 private Setting g2 = register(Settings.integerBuilder("Green (Bedrock)").withMinimum(0).withValue(144).withMaximum(255).build()); private Setting b2 = register(Settings.integerBuilder("Blue (Bedrock)").withMinimum(0).withValue(255).withMaximum(255).build()); + private ConcurrentHashMap safeHoles; + + @Override public void onUpdate() { - if (mc.player == null) return; - Iterable blocks = null; - this.holesObby = new ArrayList(); - this.holesBedr = new ArrayList(); + if (safeHoles == null) { + safeHoles = new ConcurrentHashMap<>(); + } else { + safeHoles.clear(); + } -// double delayTime = 100.0 * speed.getValue(); -// double delayTimeTwo = 100.0 * speed.getValue(); + int range = (int) Math.ceil(renderDistance.getValue()); - blocks = BlockPos.getAllInBox(mc.player.getPosition().add(-distance.getValue(), -distance.getValue(), -distance.getValue()), mc.player.getPosition().add(distance.getValue(), distance.getValue(), distance.getValue())); + CrystalAura crystalAura = (CrystalAura) ModuleManager.getModuleByName("CrystalAura"); + List blockPosList = crystalAura.getSphere(getPlayerPos(), range, range, false, true, 0); - if (blocks == null) { // prevent rare crash cases - Command.sendErrorMessage("[HoleESP] Caught NPE, contact S-B99 about this"); + for (BlockPos pos : blockPosList) { + + // block gotta be air + if (!mc.world.getBlockState(pos).getBlock().equals(Blocks.AIR)) { + continue; + } + + // block 1 above gotta be air + if (!mc.world.getBlockState(pos.add(0, 1, 0)).getBlock().equals(Blocks.AIR)) { + continue; + } + + // block 2 above gotta be air + if (!mc.world.getBlockState(pos.add(0, 2, 0)).getBlock().equals(Blocks.AIR)) { + continue; + } + + boolean isSafe = true; + boolean isBedrock = true; + + for (BlockPos offset : surroundOffset) { + Block block = mc.world.getBlockState(pos.add(offset)).getBlock(); + if (block != Blocks.BEDROCK) { + isBedrock = false; + } + if (block != Blocks.BEDROCK && block != Blocks.OBSIDIAN && block != Blocks.ENDER_CHEST && block != Blocks.ANVIL) { + isSafe = false; + break; + } + } + + if (isSafe) { + safeHoles.put(pos, isBedrock); + } + + } + + } + + @Override + public void onWorldRender(final RenderEvent event) { + + if (mc.player == null || safeHoles == null) { return; } - for (BlockPos pos : blocks) { - Block pos1 = mc.world.getBlockState(pos.add(0, -1, 0)).getBlock(); - Block pos2 = mc.world.getBlockState(pos.add(1, 0, 0)).getBlock(); - Block pos3 = mc.world.getBlockState(pos.add(0, 0, 1)).getBlock(); - Block pos4 = mc.world.getBlockState(pos.add(-1, 0, 0)).getBlock(); - Block pos5 = mc.world.getBlockState(pos.add(0, 0, -1)).getBlock(); - Material pos6 = mc.world.getBlockState(pos.add(0, 0, 0)).getMaterial(); - Material pos7 = mc.world.getBlockState(pos.add(0, 1, 0)).getMaterial(); - Material pos8 = mc.world.getBlockState(pos.add(0, 2, 0)).getMaterial(); - - if (!mc.world.getBlockState(pos).getMaterial().blocksMovement() && !mc.world.getBlockState(pos.add(0, 1, 0)).getMaterial().blocksMovement()) { - if (renObby.getValue()) { - boolean solidNeighboursObby = ( - pos1 == Blocks.OBSIDIAN | pos1 == Blocks.BEDROCK - && pos2 == Blocks.OBSIDIAN | pos2 == Blocks.BEDROCK - && pos3 == Blocks.OBSIDIAN | pos3 == Blocks.BEDROCK - && pos4 == Blocks.OBSIDIAN | pos4 == Blocks.BEDROCK - && pos5 == Blocks.OBSIDIAN | pos5 == Blocks.BEDROCK - && pos6 == Material.AIR - && pos7 == Material.AIR - && pos8 == Material.AIR - ); -// if (startTime == 0) startTime = System.currentTimeMillis(); -// if (startTime + delayTime <= System.currentTimeMillis()) { - if (solidNeighboursObby) { -// Command.sendWarningMessage("[HoleESP] Ran this 2"); - this.holesObby.add(pos); - } -// startTime = System.currentTimeMillis(); -// } - } - if (renBedr.getValue()) { - boolean solidNeighboursBedr = ( - pos1 == Blocks.BEDROCK - && pos2 == Blocks.BEDROCK - && pos3 == Blocks.BEDROCK - && pos4 == Blocks.BEDROCK - && pos5 == Blocks.BEDROCK - && pos6 == Material.AIR - && pos7 == Material.AIR - && pos8 == Material.AIR - ); -// if (startTimeTwo == 0) startTimeTwo = System.currentTimeMillis(); -// if (startTimeTwo + delayTimeTwo <= System.currentTimeMillis()) { - if (solidNeighboursBedr) { -// Command.sendWarningMessage("[HoleESP] Ran this"); - this.holesBedr.add(pos); - } -// startTimeTwo = System.currentTimeMillis(); -// } - } - } - } - } - - - public void onWorldRender(RenderEvent event) { - int colorObby; - int colorBedr; - if (ModuleManager.getModuleByName("Freecam").isEnabled()) { - colorObby = ((a.getValue())/2 & 0xff) << 24 | (r.getValue() & 0xff) << 16 | (g.getValue() & 0xff) << 8 | (b.getValue() & 0xff); - colorBedr = ((a2.getValue())/2 & 0xff) << 24 | (r2.getValue() & 0xff) << 16 | (g2.getValue() & 0xff) << 8 | (b2.getValue() & 0xff); - } - else { - colorObby = (a.getValue() & 0xff) << 24 | (r.getValue() & 0xff) << 16 | (g.getValue() & 0xff) << 8 | (b.getValue() & 0xff); - colorBedr = (a2.getValue() & 0xff) << 24 | (r2.getValue() & 0xff) << 16 | (g2.getValue() & 0xff) << 8 | (b2.getValue() & 0xff); + if (safeHoles.isEmpty()) { + return; } KamiTessellator.prepare(GL11.GL_QUADS); - this.holesObby.forEach(blockPos -> KamiTessellator.drawBox((BlockPos) blockPos, colorObby, GeometryMasks.Quad.ALL)); - this.holesBedr.forEach(blockPos -> KamiTessellator.drawBox((BlockPos) blockPos, colorBedr, GeometryMasks.Quad.ALL)); + + safeHoles.forEach((blockPos, isBedrock) -> { + if (isBedrock && renBedr.getValue()) { + drawBox(blockPos, r2.getValue(), g2.getValue(), b2.getValue()); + } else if (renObby.getValue()){ + drawBox(blockPos, r1.getValue(), g1.getValue(), b1.getValue()); + } + }); + KamiTessellator.release(); + } + + private void drawBox(BlockPos blockPos, int r, int g, int b) { + Color color = new Color(r, g, b, a0.getValue()); + if (renderMode.getValue().equals(RenderMode.DOWN)) { + KamiTessellator.drawBox(blockPos, color.getRGB(), GeometryMasks.Quad.DOWN); + } else if (renderMode.getValue().equals(RenderMode.BLOCK)) { + KamiTessellator.drawBox(blockPos, color.getRGB(), GeometryMasks.Quad.ALL); + } + } + + private enum RenderMode { + DOWN, BLOCK + } + } diff --git a/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESPFast.java b/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESPFast.java deleted file mode 100644 index 8c0078a0..00000000 --- a/src/main/java/me/zeroeightsix/kami/module/modules/bewwawho/render/HoleESPFast.java +++ /dev/null @@ -1,133 +0,0 @@ -package me.zeroeightsix.kami.module.modules.bewwawho.render; - -import me.zeroeightsix.kami.event.events.RenderEvent; -import me.zeroeightsix.kami.module.Module; -import me.zeroeightsix.kami.module.ModuleManager; -import me.zeroeightsix.kami.module.modules.combat.CrystalAura; -import me.zeroeightsix.kami.setting.Setting; -import me.zeroeightsix.kami.setting.Settings; -import me.zeroeightsix.kami.util.GeometryMasks; -import me.zeroeightsix.kami.util.KamiTessellator; -import net.minecraft.block.Block; -import net.minecraft.init.Blocks; -import net.minecraft.util.math.BlockPos; -import org.lwjgl.opengl.GL11; - -import java.awt.*; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import static me.zeroeightsix.kami.module.modules.combat.CrystalAura.getPlayerPos; - -/** - * Created 16 November 2019 by hub - */ -@Module.Info(name = "HoleESPFast", category = Module.Category.RENDER, description = "Show safe holes") -public class HoleESPFast extends Module { - - private final BlockPos[] surroundOffset = { - new BlockPos(0, -1, 0), // down - new BlockPos(0, 0, -1), // north - new BlockPos(1, 0, 0), // east - new BlockPos(0, 0, 1), // south - new BlockPos(-1, 0, 0) // west - }; - - private Setting renderDistance = register(Settings.d("Render Distance", 8.0d)); - private Setting renderMode = register(Settings.e("Render Mode", RenderMode.DOWN)); - private Setting renderAlpha = register(Settings.integerBuilder("Render Alpha").withMinimum(0).withValue(42).withMaximum(255).build()); - - private ConcurrentHashMap safeHoles; - - @Override - public void onUpdate() { - - if (safeHoles == null) { - safeHoles = new ConcurrentHashMap<>(); - } else { - safeHoles.clear(); - } - - int range = (int) Math.ceil(renderDistance.getValue()); - - CrystalAura crystalAura = (CrystalAura) ModuleManager.getModuleByName("CrystalAura"); - List blockPosList = crystalAura.getSphere(getPlayerPos(), range, range, false, true, 0); - - for (BlockPos pos : blockPosList) { - - // block gotta be air - if (!mc.world.getBlockState(pos).getBlock().equals(Blocks.AIR)) { - continue; - } - - // block 1 above gotta be air - if (!mc.world.getBlockState(pos.add(0, 1, 0)).getBlock().equals(Blocks.AIR)) { - continue; - } - - // block 2 above gotta be air - if (!mc.world.getBlockState(pos.add(0, 2, 0)).getBlock().equals(Blocks.AIR)) { - continue; - } - - boolean isSafe = true; - boolean isBedrock = true; - - for (BlockPos offset : surroundOffset) { - Block block = mc.world.getBlockState(pos.add(offset)).getBlock(); - if (block != Blocks.BEDROCK) { - isBedrock = false; - } - if (block != Blocks.BEDROCK && block != Blocks.OBSIDIAN && block != Blocks.ENDER_CHEST && block != Blocks.ANVIL) { - isSafe = false; - break; - } - } - - if (isSafe) { - safeHoles.put(pos, isBedrock); - } - - } - - } - - @Override - public void onWorldRender(final RenderEvent event) { - - if (mc.player == null || safeHoles == null) { - return; - } - - if (safeHoles.isEmpty()) { - return; - } - - KamiTessellator.prepare(GL11.GL_QUADS); - - safeHoles.forEach((blockPos, isBedrock) -> { - if (isBedrock) { - drawBox(blockPos, 81, 12, 104); - } else { - drawBox(blockPos, 104, 12, 35); - } - }); - - KamiTessellator.release(); - - } - - private void drawBox(BlockPos blockPos, int r, int g, int b) { - Color color = new Color(r, g, b, renderAlpha.getValue()); - if (renderMode.getValue().equals(RenderMode.DOWN)) { - KamiTessellator.drawBox(blockPos, color.getRGB(), GeometryMasks.Quad.DOWN); - } else if (renderMode.getValue().equals(RenderMode.BLOCK)) { - KamiTessellator.drawBox(blockPos, color.getRGB(), GeometryMasks.Quad.ALL); - } - } - - private enum RenderMode { - DOWN, BLOCK - } - -}