added a warning for autotnt place mode
this is temporary until the calculation algorithm is improved
This commit is contained in:
@@ -29,23 +29,23 @@ import java.util.List;
|
|||||||
|
|
||||||
public class AutoTNT extends Module {
|
public class AutoTNT extends Module {
|
||||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||||
|
|
||||||
// General
|
// General
|
||||||
|
|
||||||
private final Setting<Boolean> ignite = sgGeneral.add(new BoolSetting.Builder()
|
private final Setting<Boolean> ignite = sgGeneral.add(new BoolSetting.Builder()
|
||||||
.name("ignite")
|
.name("ignite")
|
||||||
.description("Whether to ignite tnt.")
|
.description("Whether to ignite tnt.")
|
||||||
.defaultValue(false)
|
.defaultValue(false)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Boolean> place = sgGeneral.add(new BoolSetting.Builder()
|
private final Setting<Boolean> place = sgGeneral.add(new BoolSetting.Builder()
|
||||||
.name("place")
|
.name("place")
|
||||||
.description("Whether to place tnt.")
|
.description("Whether to place tnt. (VERY LAGGY)")
|
||||||
.defaultValue(true)
|
.defaultValue(true)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Integer> igniteDelay = sgGeneral.add(new IntSetting.Builder()
|
private final Setting<Integer> igniteDelay = sgGeneral.add(new IntSetting.Builder()
|
||||||
.name("ignition-delay")
|
.name("ignition-delay")
|
||||||
.description("Delay in ticks between ignition")
|
.description("Delay in ticks between ignition")
|
||||||
@@ -53,7 +53,7 @@ public class AutoTNT extends Module {
|
|||||||
.visible(ignite::get)
|
.visible(ignite::get)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Integer> placeDelay = sgGeneral.add(new IntSetting.Builder()
|
private final Setting<Integer> placeDelay = sgGeneral.add(new IntSetting.Builder()
|
||||||
.name("place-delay")
|
.name("place-delay")
|
||||||
.description("Delay in ticks between placement")
|
.description("Delay in ticks between placement")
|
||||||
@@ -61,21 +61,21 @@ public class AutoTNT extends Module {
|
|||||||
.visible(place::get)
|
.visible(place::get)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Integer> horizontalRange = sgGeneral.add(new IntSetting.Builder()
|
private final Setting<Integer> horizontalRange = sgGeneral.add(new IntSetting.Builder()
|
||||||
.name("horizontal-range")
|
.name("horizontal-range")
|
||||||
.description("Horizontal range of ignition and placement")
|
.description("Horizontal range of ignition and placement")
|
||||||
.defaultValue(4)
|
.defaultValue(4)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Integer> verticalRange = sgGeneral.add(new IntSetting.Builder()
|
private final Setting<Integer> verticalRange = sgGeneral.add(new IntSetting.Builder()
|
||||||
.name("vertical-range")
|
.name("vertical-range")
|
||||||
.description("Vertical range of ignition and placement")
|
.description("Vertical range of ignition and placement")
|
||||||
.defaultValue(4)
|
.defaultValue(4)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Boolean> antiBreak = sgGeneral.add(new BoolSetting.Builder()
|
private final Setting<Boolean> antiBreak = sgGeneral.add(new BoolSetting.Builder()
|
||||||
.name("anti-break")
|
.name("anti-break")
|
||||||
.description("Whether to save flint and steel from breaking.")
|
.description("Whether to save flint and steel from breaking.")
|
||||||
@@ -91,56 +91,56 @@ public class AutoTNT extends Module {
|
|||||||
.visible(ignite::get)
|
.visible(ignite::get)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
|
private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
|
||||||
.name("rotate")
|
.name("rotate")
|
||||||
.description("Whether to rotate towards action.")
|
.description("Whether to rotate towards action.")
|
||||||
.defaultValue(true)
|
.defaultValue(true)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final List<BlockPos.Mutable> blocksToIgnite = new ArrayList<>();
|
private final List<BlockPos.Mutable> blocksToIgnite = new ArrayList<>();
|
||||||
private final Pool<BlockPos.Mutable> ignitePool = new Pool<>(BlockPos.Mutable::new);
|
private final Pool<BlockPos.Mutable> ignitePool = new Pool<>(BlockPos.Mutable::new);
|
||||||
private final List<TntPos> blocksToPlace = new ArrayList<>();
|
private final List<TntPos> blocksToPlace = new ArrayList<>();
|
||||||
private final Pool<TntPos> placePool = new Pool<>(TntPos::new);
|
private final Pool<TntPos> placePool = new Pool<>(TntPos::new);
|
||||||
private int igniteTick = 0;
|
private int igniteTick = 0;
|
||||||
private int placeTick = 0;
|
private int placeTick = 0;
|
||||||
|
|
||||||
public AutoTNT() {
|
public AutoTNT() {
|
||||||
super(MeteorRejectsAddon.CATEGORY, "auto-tnt", "Places and/or ignites tnt automatically. Good for griefing.");
|
super(MeteorRejectsAddon.CATEGORY, "auto-tnt", "Places and/or ignites tnt automatically. Good for griefing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDeactivate() {
|
public void onDeactivate() {
|
||||||
igniteTick = 0;
|
igniteTick = 0;
|
||||||
placeTick = 0;
|
placeTick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onPreTick(TickEvent.Pre event) {
|
private void onPreTick(TickEvent.Pre event) {
|
||||||
if (ignite.get() && igniteTick > igniteDelay.get()) {
|
if (ignite.get() && igniteTick > igniteDelay.get()) {
|
||||||
// Clear blocks
|
// Clear blocks
|
||||||
for (BlockPos.Mutable blockPos : blocksToIgnite) ignitePool.free(blockPos);
|
for (BlockPos.Mutable blockPos : blocksToIgnite) ignitePool.free(blockPos);
|
||||||
blocksToIgnite.clear();
|
blocksToIgnite.clear();
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> {
|
BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> {
|
||||||
if (blockState.getBlock() instanceof TntBlock) blocksToIgnite.add(ignitePool.get().set(blockPos));
|
if (blockState.getBlock() instanceof TntBlock) blocksToIgnite.add(ignitePool.get().set(blockPos));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (place.get() && placeTick > placeDelay.get()) {
|
if (place.get() && placeTick > placeDelay.get()) {
|
||||||
// Clear blocks
|
// Clear blocks
|
||||||
for (TntPos tntPos : blocksToPlace) placePool.free(tntPos);
|
for (TntPos tntPos : blocksToPlace) placePool.free(tntPos);
|
||||||
blocksToPlace.clear();
|
blocksToPlace.clear();
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> {
|
BlockIterator.register(horizontalRange.get(), verticalRange.get(), (blockPos, blockState) -> {
|
||||||
if (BlockUtils.canPlace(blockPos)) blocksToPlace.add(placePool.get().set(blockPos, TntDamage.calculate(blockPos)));
|
if (BlockUtils.canPlace(blockPos)) blocksToPlace.add(placePool.get().set(blockPos, TntDamage.calculate(blockPos)));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onPostTick(TickEvent.Post event) {
|
private void onPostTick(TickEvent.Post event) {
|
||||||
// Ignition
|
// Ignition
|
||||||
@@ -148,7 +148,7 @@ public class AutoTNT extends Module {
|
|||||||
if (igniteTick > igniteDelay.get()) {
|
if (igniteTick > igniteDelay.get()) {
|
||||||
// Sort based on closest tnt
|
// Sort based on closest tnt
|
||||||
blocksToIgnite.sort(Comparator.comparingDouble(PlayerUtils::distanceTo));
|
blocksToIgnite.sort(Comparator.comparingDouble(PlayerUtils::distanceTo));
|
||||||
|
|
||||||
// Ignition
|
// Ignition
|
||||||
FindItemResult itemResult = InvUtils.findInHotbar(item -> {
|
FindItemResult itemResult = InvUtils.findInHotbar(item -> {
|
||||||
if (item.getItem() instanceof FlintAndSteelItem) {
|
if (item.getItem() instanceof FlintAndSteelItem) {
|
||||||
@@ -165,13 +165,13 @@ public class AutoTNT extends Module {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ignite(blocksToIgnite.get(0), itemResult);
|
ignite(blocksToIgnite.get(0), itemResult);
|
||||||
|
|
||||||
// Reset ticks
|
// Reset ticks
|
||||||
igniteTick = 0;
|
igniteTick = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
igniteTick++;
|
igniteTick++;
|
||||||
|
|
||||||
// Placement
|
// Placement
|
||||||
if (place.get() && blocksToPlace.size() > 0) {
|
if (place.get() && blocksToPlace.size() > 0) {
|
||||||
if (placeTick > placeDelay.get()) {
|
if (placeTick > placeDelay.get()) {
|
||||||
@@ -193,29 +193,29 @@ public class AutoTNT extends Module {
|
|||||||
}
|
}
|
||||||
placeTick++;
|
placeTick++;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ignite(BlockPos pos, FindItemResult item) {
|
private void ignite(BlockPos pos, FindItemResult item) {
|
||||||
InvUtils.swap(item.getSlot(), true);
|
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));
|
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();
|
InvUtils.swapBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void place(BlockPos pos, FindItemResult item) {
|
private void place(BlockPos pos, FindItemResult item) {
|
||||||
BlockUtils.place(pos, item, rotate.get(), 10);
|
BlockUtils.place(pos, item, rotate.get(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TntPos {
|
private class TntPos {
|
||||||
public BlockPos.Mutable blockPos;
|
public BlockPos.Mutable blockPos;
|
||||||
public int score;
|
public int score;
|
||||||
|
|
||||||
public TntPos set(BlockPos blockPos, int score) {
|
public TntPos set(BlockPos blockPos, int score) {
|
||||||
if (this.blockPos != null)
|
if (this.blockPos != null)
|
||||||
this.blockPos.set(blockPos);
|
this.blockPos.set(blockPos);
|
||||||
|
|
||||||
this.score = score;
|
this.score = score;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user