AutoTNT & SpawnProofer
This commit is contained in:
@@ -28,6 +28,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
||||
modules.add(new AutoExtinguish());
|
||||
modules.add(new AutoHighway());
|
||||
modules.add(new AutoPot());
|
||||
modules.add(new AutoTNT());
|
||||
modules.add(new Confuse());
|
||||
modules.add(new InteractionMenu());
|
||||
modules.add(new Glide());
|
||||
@@ -38,6 +39,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
||||
modules.add(new SkeletonESP());
|
||||
modules.add(new Sneak());
|
||||
modules.add(new SoundLocator());
|
||||
modules.add(new SpawnProofer());
|
||||
modules.add(new TPSSync());
|
||||
|
||||
Commands commands = Commands.get();
|
||||
|
||||
150
src/main/java/cloudburst/rejects/modules/AutoTNT.java
Normal file
150
src/main/java/cloudburst/rejects/modules/AutoTNT.java
Normal file
@@ -0,0 +1,150 @@
|
||||
package cloudburst.rejects.modules;
|
||||
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
import minegame159.meteorclient.events.world.TickEvent;
|
||||
import minegame159.meteorclient.settings.BoolSetting;
|
||||
import minegame159.meteorclient.settings.IntSetting;
|
||||
import minegame159.meteorclient.settings.Setting;
|
||||
import minegame159.meteorclient.settings.SettingGroup;
|
||||
import minegame159.meteorclient.systems.modules.Module;
|
||||
import minegame159.meteorclient.utils.player.InvUtils;
|
||||
import minegame159.meteorclient.utils.player.PlayerUtils;
|
||||
import minegame159.meteorclient.utils.world.BlockUtils;
|
||||
import net.minecraft.block.TntBlock;
|
||||
import net.minecraft.item.FlintAndSteelItem;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import cloudburst.rejects.MeteorRejectsAddon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
|
||||
public class AutoTNT extends Module {
|
||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||
|
||||
// General
|
||||
|
||||
private final Setting<Integer> delay = sgGeneral.add(new IntSetting.Builder()
|
||||
.name("delay")
|
||||
.description("Delay in ticks between ignition")
|
||||
.defaultValue(1)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder()
|
||||
.name("range")
|
||||
.description("Range of ignition")
|
||||
.defaultValue(4)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Boolean> turnOff = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("turn-off")
|
||||
.description("Turns of after igniting tnt")
|
||||
.defaultValue(true)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Boolean> antiBreak = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("anti-break")
|
||||
.description("Whether or not to save flint and steel from breaking.")
|
||||
.defaultValue(true)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final ArrayList<BlockPos> blocks = new ArrayList<>();
|
||||
private BlockPos.Mutable bp = new BlockPos.Mutable();
|
||||
private boolean ignited, messaged;
|
||||
private int ticks = 0;
|
||||
private int preSlot, slot;
|
||||
|
||||
@Override
|
||||
public void onActivate() {
|
||||
ignited = false;
|
||||
messaged = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeactivate() {
|
||||
ticks = 0;
|
||||
}
|
||||
|
||||
public AutoTNT() {
|
||||
super(MeteorRejectsAddon.CATEGORY, "auto-tnt", "Ignites TNT for you");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onTick(TickEvent.Post event) {
|
||||
if (ticks <= 0) {
|
||||
// Clear and get tnt blocks
|
||||
blocks.clear();
|
||||
for (BlockPos vec3d : BlockUtils.getSphere(mc.player.getBlockPos(), range.get(), range.get())) {
|
||||
setBpToVec3d(vec3d);
|
||||
|
||||
if (mc.world.getBlockState(bp).getBlock() instanceof TntBlock) blocks.add(bp.toImmutable());
|
||||
}
|
||||
|
||||
// Make sure there are TNTs around us
|
||||
if (blocks.size() <= 0) {
|
||||
|
||||
// If already ignited and turnOff.get()
|
||||
if (turnOff.get() && ignited) {
|
||||
toggle();
|
||||
return;
|
||||
}
|
||||
|
||||
// If we haven't warned yet
|
||||
if (!messaged) {
|
||||
error("No TNT in range");
|
||||
messaged = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
else messaged = false;
|
||||
|
||||
// Sort based on closest tnt
|
||||
blocks.sort(Comparator.comparingDouble(PlayerUtils::distanceTo));
|
||||
|
||||
// Get slot
|
||||
slot = getSlot();
|
||||
if (slot == -1) {
|
||||
error("No flint and steel in hotbar");
|
||||
return;
|
||||
}
|
||||
|
||||
// Ignition
|
||||
bp.set(blocks.get(0));
|
||||
ignite(bp, slot);
|
||||
|
||||
// Reset ticks
|
||||
ticks = delay.get();
|
||||
} else ticks--;
|
||||
}
|
||||
|
||||
private void ignite(BlockPos pos, int slot) {
|
||||
// Set slots
|
||||
preSlot = mc.player.inventory.selectedSlot;
|
||||
mc.player.inventory.selectedSlot = slot;
|
||||
|
||||
// Ignited the tnt
|
||||
ActionResult result = 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));
|
||||
if (result == ActionResult.CONSUME || result == ActionResult.SUCCESS) ignited = true;
|
||||
|
||||
// Reset slot
|
||||
mc.player.inventory.selectedSlot = preSlot;
|
||||
}
|
||||
|
||||
private int getSlot() {
|
||||
return InvUtils.findItemInHotbar(item -> item.getItem() instanceof FlintAndSteelItem && (antiBreak.get() && (item.getMaxDamage() - item.getDamage()) > 10));
|
||||
}
|
||||
|
||||
private void setBpToVec3d(BlockPos pos) {
|
||||
bp.set(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
}
|
||||
|
||||
132
src/main/java/cloudburst/rejects/modules/SpawnProofer.java
Normal file
132
src/main/java/cloudburst/rejects/modules/SpawnProofer.java
Normal file
@@ -0,0 +1,132 @@
|
||||
package cloudburst.rejects.modules;
|
||||
|
||||
import meteordevelopment.orbit.EventHandler;
|
||||
import minegame159.meteorclient.events.render.RenderEvent;
|
||||
import minegame159.meteorclient.events.world.TickEvent;
|
||||
import minegame159.meteorclient.rendering.MeshBuilder;
|
||||
import minegame159.meteorclient.rendering.Renderer;
|
||||
import minegame159.meteorclient.rendering.ShapeMode;
|
||||
import minegame159.meteorclient.settings.*;
|
||||
import minegame159.meteorclient.systems.modules.Module;
|
||||
import minegame159.meteorclient.utils.player.InvUtils;
|
||||
import minegame159.meteorclient.utils.render.color.SettingColor;
|
||||
import minegame159.meteorclient.utils.world.BlockIterator;
|
||||
import minegame159.meteorclient.utils.world.BlockUtils;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.enums.BlockHalf;
|
||||
import net.minecraft.block.enums.SlabType;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.LightType;
|
||||
|
||||
import cloudburst.rejects.MeteorRejectsAddon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnProofer extends Module {
|
||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||
|
||||
private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder()
|
||||
.name("range")
|
||||
.description("Range for block placement and rendering")
|
||||
.min(1)
|
||||
.max(4)
|
||||
.sliderMin(1)
|
||||
.sliderMax(1)
|
||||
.defaultValue(3)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<List<Block>> blocks = sgGeneral.add(new BlockListSetting.Builder()
|
||||
.name("blocks")
|
||||
.description("Blocks to use for spawn proofing")
|
||||
.defaultValue(Collections.emptyList())
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<ShapeMode> shapeMode = sgGeneral.add(new EnumSetting.Builder<ShapeMode>()
|
||||
.name("shape-mode")
|
||||
.description("Shape mode")
|
||||
.defaultValue(ShapeMode.Both)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<SettingColor> sideColor = sgGeneral.add(new ColorSetting.Builder()
|
||||
.name("side-color")
|
||||
.description("Edge color")
|
||||
.defaultValue(new SettingColor(255, 0, 0, 75))
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<SettingColor> lineColor = sgGeneral.add(new ColorSetting.Builder()
|
||||
.name("line-color")
|
||||
.description("Line color")
|
||||
.defaultValue(new SettingColor(255, 0, 0, 255))
|
||||
.build()
|
||||
);
|
||||
|
||||
private final Setting<Boolean> rotate = sgGeneral.add(new BoolSetting.Builder()
|
||||
.name("rotate")
|
||||
.description("Rotates towards the blocks being placed.")
|
||||
.defaultValue(true)
|
||||
.build()
|
||||
);
|
||||
|
||||
private final BlockPos.Mutable bp = new BlockPos.Mutable();
|
||||
private final ArrayList<BlockPos> positions = new ArrayList<>();
|
||||
private final MeshBuilder mb = new MeshBuilder();
|
||||
|
||||
public SpawnProofer() {
|
||||
super(MeteorRejectsAddon.CATEGORY, "spawn-proofer", "Spawn proofs things using slabs.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onTick(TickEvent.Post event) {
|
||||
// Clear and set positions
|
||||
positions.clear();
|
||||
BlockIterator.register(range.get(), range.get(), (blockPos, blockState) -> {
|
||||
if (validSpawn(new BlockPos(blockPos.getX(), blockPos.getY()-1, blockPos.getZ()), blockState)) positions.add(blockPos);
|
||||
});
|
||||
|
||||
for (BlockPos blockPos : positions) {
|
||||
// Set slot
|
||||
int slot = findSlot();
|
||||
// Place blocks
|
||||
BlockUtils.place(blockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false, true, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
private void onRender(RenderEvent event) {
|
||||
// Render all positions
|
||||
for (BlockPos blockPos : positions) {
|
||||
Renderer.boxWithLines(Renderer.NORMAL, Renderer.LINES, blockPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
private int findSlot() {
|
||||
return InvUtils.findItemInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
|
||||
}
|
||||
|
||||
private boolean validSpawn(BlockPos blockPos, BlockState blockState) {
|
||||
if (blockPos.getY() == 0) return false;
|
||||
if (!(blockState.getBlock() instanceof AirBlock)) return false;
|
||||
|
||||
bp.set(blockPos).move(0, -1, 0);
|
||||
if (!topSurface(mc.world.getBlockState(bp))) {
|
||||
if (mc.world.getBlockState(bp).getCollisionShape(mc.world, bp) != VoxelShapes.fullCube()) return false;
|
||||
if (mc.world.getBlockState(bp).isTranslucent(mc.world, bp)) return false;
|
||||
}
|
||||
|
||||
if (mc.world.getLightLevel(blockPos, 0) <= 7) return false;
|
||||
else return mc.world.getLightLevel(LightType.BLOCK, blockPos) <= 7;
|
||||
}
|
||||
|
||||
private boolean topSurface(BlockState blockState) {
|
||||
if (blockState.getBlock() instanceof SlabBlock && blockState.get(SlabBlock.TYPE) == SlabType.TOP) return true;
|
||||
else return blockState.getBlock() instanceof StairsBlock && blockState.get(StairsBlock.HALF) == BlockHalf.TOP;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user