From 4e5ea69fa77c645d02086f91c8af22b12d63c2c8 Mon Sep 17 00:00:00 2001 From: Stormybytes Date: Sat, 11 Sep 2021 16:36:27 +0700 Subject: [PATCH] added a warning for autotnt place mode this is temporary until the calculation algorithm is improved --- .../cloudburst/rejects/modules/AutoTNT.java | 54 +++++++++---------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/main/java/cloudburst/rejects/modules/AutoTNT.java b/src/main/java/cloudburst/rejects/modules/AutoTNT.java index e5cae1a..2ae1bef 100644 --- a/src/main/java/cloudburst/rejects/modules/AutoTNT.java +++ b/src/main/java/cloudburst/rejects/modules/AutoTNT.java @@ -29,23 +29,23 @@ import java.util.List; public class AutoTNT extends Module { private final SettingGroup sgGeneral = settings.getDefaultGroup(); - + // General - + private final Setting ignite = sgGeneral.add(new BoolSetting.Builder() .name("ignite") .description("Whether to ignite tnt.") .defaultValue(false) .build() ); - + private final Setting place = sgGeneral.add(new BoolSetting.Builder() .name("place") - .description("Whether to place tnt.") + .description("Whether to place tnt. (VERY LAGGY)") .defaultValue(true) .build() ); - + private final Setting igniteDelay = sgGeneral.add(new IntSetting.Builder() .name("ignition-delay") .description("Delay in ticks between ignition") @@ -53,7 +53,7 @@ public class AutoTNT extends Module { .visible(ignite::get) .build() ); - + private final Setting placeDelay = sgGeneral.add(new IntSetting.Builder() .name("place-delay") .description("Delay in ticks between placement") @@ -61,21 +61,21 @@ public class AutoTNT extends Module { .visible(place::get) .build() ); - + private final Setting horizontalRange = sgGeneral.add(new IntSetting.Builder() .name("horizontal-range") .description("Horizontal range of ignition and placement") .defaultValue(4) .build() ); - + private final Setting verticalRange = sgGeneral.add(new IntSetting.Builder() .name("vertical-range") .description("Vertical range of ignition and placement") .defaultValue(4) .build() ); - + private final Setting antiBreak = sgGeneral.add(new BoolSetting.Builder() .name("anti-break") .description("Whether to save flint and steel from breaking.") @@ -91,56 +91,56 @@ public class AutoTNT extends Module { .visible(ignite::get) .build() ); - + private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() .name("rotate") .description("Whether to rotate towards action.") .defaultValue(true) .build() ); - + private final List blocksToIgnite = new ArrayList<>(); private final Pool ignitePool = new Pool<>(BlockPos.Mutable::new); private final List blocksToPlace = new ArrayList<>(); private final Pool placePool = new Pool<>(TntPos::new); private int igniteTick = 0; private int placeTick = 0; - + public AutoTNT() { super(MeteorRejectsAddon.CATEGORY, "auto-tnt", "Places and/or ignites tnt automatically. Good for griefing."); } - + @Override public void onDeactivate() { igniteTick = 0; placeTick = 0; } - + @EventHandler private void onPreTick(TickEvent.Pre event) { if (ignite.get() && igniteTick > igniteDelay.get()) { // Clear blocks for (BlockPos.Mutable blockPos : blocksToIgnite) ignitePool.free(blockPos); blocksToIgnite.clear(); - + // Register BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> { if (blockState.getBlock() instanceof TntBlock) blocksToIgnite.add(ignitePool.get().set(blockPos)); }); } - + if (place.get() && placeTick > placeDelay.get()) { // Clear blocks for (TntPos tntPos : blocksToPlace) placePool.free(tntPos); blocksToPlace.clear(); - + // Register BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> { if (BlockUtils.canPlace(blockPos)) blocksToPlace.add(placePool.get().set(blockPos, TntDamage.calculate(blockPos))); }); } } - + @EventHandler private void onPostTick(TickEvent.Post event) { // Ignition @@ -148,7 +148,7 @@ public class AutoTNT extends Module { if (igniteTick > igniteDelay.get()) { // Sort based on closest tnt blocksToIgnite.sort(Comparator.comparingDouble(PlayerUtils::distanceTo)); - + // Ignition FindItemResult itemResult = InvUtils.findInHotbar(item -> { if (item.getItem() instanceof FlintAndSteelItem) { @@ -165,13 +165,13 @@ public class AutoTNT extends Module { return; } ignite(blocksToIgnite.get(0), itemResult); - + // Reset ticks igniteTick = 0; } } igniteTick++; - + // Placement if (place.get() && blocksToPlace.size() > 0) { if (placeTick > placeDelay.get()) { @@ -193,29 +193,29 @@ public class AutoTNT extends Module { } placeTick++; } - + private void ignite(BlockPos pos, FindItemResult item) { InvUtils.swap(item.getSlot(), true); mc.interactionManager.interactBlock(mc.player, mc.world, Hand.MAIN_HAND, new BlockHitResult(new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5), Direction.UP, pos, true)); - + InvUtils.swapBack(); } - + private void place(BlockPos pos, FindItemResult item) { BlockUtils.place(pos, item, rotate.get(), 10); } - + private class TntPos { public BlockPos.Mutable blockPos; public int score; - + public TntPos set(BlockPos blockPos, int score) { if (this.blockPos != null) this.blockPos.set(blockPos); this.score = score; - + return this; } }