Fixed Spawn Proofer
This commit is contained in:
@@ -41,7 +41,7 @@ public class MeteorRejectsAddon extends MeteorAddon {
|
|||||||
modules.add(new Rendering());
|
modules.add(new Rendering());
|
||||||
modules.add(new SkeletonESP());
|
modules.add(new SkeletonESP());
|
||||||
modules.add(new SoundLocator());
|
modules.add(new SoundLocator());
|
||||||
// modules.add(new SpawnProofer());
|
modules.add(new SpawnProofer());
|
||||||
|
|
||||||
Commands commands = Commands.get();
|
Commands commands = Commands.get();
|
||||||
commands.add(new AntiAntiXrayCommand());
|
commands.add(new AntiAntiXrayCommand());
|
||||||
|
|||||||
@@ -92,9 +92,6 @@ public class AutoTNT extends Module {
|
|||||||
// If there isn't any tnt
|
// If there isn't any tnt
|
||||||
if (blocks.size() <= 0) {
|
if (blocks.size() <= 0) {
|
||||||
|
|
||||||
// Give a warning
|
|
||||||
error("No TNT in range");
|
|
||||||
|
|
||||||
// If we should just turn off after igniting
|
// If we should just turn off after igniting
|
||||||
if (turnOff.get() && ignited) {
|
if (turnOff.get() && ignited) {
|
||||||
toggle();
|
toggle();
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package cloudburst.rejects.modules;
|
package cloudburst.rejects.modules;
|
||||||
|
|
||||||
|
import cloudburst.rejects.MeteorRejectsAddon;
|
||||||
|
import cloudburst.rejects.utils.WorldUtils;
|
||||||
import meteordevelopment.orbit.EventHandler;
|
import meteordevelopment.orbit.EventHandler;
|
||||||
import minegame159.meteorclient.events.render.RenderEvent;
|
import minegame159.meteorclient.events.render.RenderEvent;
|
||||||
import minegame159.meteorclient.events.world.TickEvent;
|
import minegame159.meteorclient.events.world.TickEvent;
|
||||||
@@ -10,123 +12,132 @@ import minegame159.meteorclient.settings.*;
|
|||||||
import minegame159.meteorclient.systems.modules.Module;
|
import minegame159.meteorclient.systems.modules.Module;
|
||||||
import minegame159.meteorclient.utils.player.InvUtils;
|
import minegame159.meteorclient.utils.player.InvUtils;
|
||||||
import minegame159.meteorclient.utils.render.color.SettingColor;
|
import minegame159.meteorclient.utils.render.color.SettingColor;
|
||||||
import minegame159.meteorclient.utils.world.BlockIterator;
|
|
||||||
import minegame159.meteorclient.utils.world.BlockUtils;
|
import minegame159.meteorclient.utils.world.BlockUtils;
|
||||||
import net.minecraft.block.*;
|
import net.minecraft.block.*;
|
||||||
import net.minecraft.block.enums.BlockHalf;
|
import net.minecraft.block.enums.BlockHalf;
|
||||||
import net.minecraft.block.enums.SlabType;
|
import net.minecraft.block.enums.SlabType;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.registry.Registry;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.LightType;
|
import net.minecraft.world.LightType;
|
||||||
|
|
||||||
import cloudburst.rejects.MeteorRejectsAddon;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SpawnProofer extends Module {
|
public class SpawnProofer extends Module {
|
||||||
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
private final SettingGroup sgGeneral = settings.getDefaultGroup();
|
||||||
|
|
||||||
private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder()
|
private final Setting<Integer> range = sgGeneral.add(new IntSetting.Builder()
|
||||||
.name("range")
|
.name("range")
|
||||||
.description("Range for block placement and rendering")
|
.description("Range for block placement and rendering")
|
||||||
.min(1)
|
.min(1)
|
||||||
.max(4)
|
.max(4)
|
||||||
.sliderMin(1)
|
.sliderMin(1)
|
||||||
.sliderMax(1)
|
.sliderMax(1)
|
||||||
.defaultValue(3)
|
.defaultValue(3)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<List<Block>> blocks = sgGeneral.add(new BlockListSetting.Builder()
|
private final Setting<List<Block>> blocks = sgGeneral.add(new BlockListSetting.Builder()
|
||||||
.name("blocks")
|
.name("blocks")
|
||||||
.description("Blocks to use for spawn proofing")
|
.description("Blocks to use for spawn proofing")
|
||||||
.defaultValue(Collections.emptyList())
|
.defaultValue(getDefaultBlocks())
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<ShapeMode> shapeMode = sgGeneral.add(new EnumSetting.Builder<ShapeMode>()
|
private final Setting<ShapeMode> shapeMode = sgGeneral.add(new EnumSetting.Builder<ShapeMode>()
|
||||||
.name("shape-mode")
|
.name("shape-mode")
|
||||||
.description("Shape mode")
|
.description("Shape mode")
|
||||||
.defaultValue(ShapeMode.Both)
|
.defaultValue(ShapeMode.Both)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<SettingColor> sideColor = sgGeneral.add(new ColorSetting.Builder()
|
private final Setting<SettingColor> sideColor = sgGeneral.add(new ColorSetting.Builder()
|
||||||
.name("side-color")
|
.name("side-color")
|
||||||
.description("Edge color")
|
.description("Edge color")
|
||||||
.defaultValue(new SettingColor(255, 0, 0, 75))
|
.defaultValue(new SettingColor(255, 0, 0, 75))
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final Setting<SettingColor> lineColor = sgGeneral.add(new ColorSetting.Builder()
|
private final Setting<SettingColor> lineColor = sgGeneral.add(new ColorSetting.Builder()
|
||||||
.name("line-color")
|
.name("line-color")
|
||||||
.description("Line color")
|
.description("Line color")
|
||||||
.defaultValue(new SettingColor(255, 0, 0, 255))
|
.defaultValue(new SettingColor(255, 0, 0, 255))
|
||||||
.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("Rotates towards the blocks being placed.")
|
.description("Rotates towards the blocks being placed.")
|
||||||
.defaultValue(true)
|
.defaultValue(true)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final BlockPos.Mutable bp = new BlockPos.Mutable();
|
private final ArrayList<BlockPos> positions = new ArrayList<>();
|
||||||
private final ArrayList<BlockPos> positions = new ArrayList<>();
|
private final MeshBuilder mb = new MeshBuilder();
|
||||||
private final MeshBuilder mb = new MeshBuilder();
|
|
||||||
|
|
||||||
public SpawnProofer() {
|
public SpawnProofer() {
|
||||||
super(MeteorRejectsAddon.CATEGORY, "spawn-proofer", "Spawn proofs things using slabs.");
|
super(MeteorRejectsAddon.CATEGORY, "spawn-proofer", "Spawn proofs things using slabs.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onTick(TickEvent.Post event) {
|
private void onTick(TickEvent.Post event) {
|
||||||
// Clear and set positions
|
// Clear and set positions
|
||||||
positions.clear();
|
positions.clear();
|
||||||
BlockIterator.register(range.get(), range.get(), (blockPos, blockState) -> {
|
for (BlockPos blockPos : WorldUtils.getSphere(mc.player.getBlockPos(), range.get(), range.get())) {
|
||||||
if (validSpawn(new BlockPos(blockPos.getX(), blockPos.getY()-1, blockPos.getZ()), blockState)) positions.add(blockPos);
|
if (validSpawn(blockPos)) positions.add(blockPos);
|
||||||
});
|
}
|
||||||
|
|
||||||
for (BlockPos blockPos : positions) {
|
for (BlockPos blockPos : positions) {
|
||||||
// Set slot
|
// Set slot
|
||||||
int slot = findSlot();
|
int slot = findSlot();
|
||||||
// Place blocks
|
// Place blocks
|
||||||
BlockUtils.place(blockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, false, true, true, true);
|
BlockUtils.place(blockPos, Hand.MAIN_HAND, slot, rotate.get(), -50, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
private void onRender(RenderEvent event) {
|
private void onRender(RenderEvent event) {
|
||||||
// Render all positions
|
// Render all positions
|
||||||
for (BlockPos blockPos : positions) {
|
for (BlockPos blockPos : positions) {
|
||||||
Renderer.boxWithLines(Renderer.NORMAL, Renderer.LINES, blockPos, sideColor.get(), lineColor.get(), shapeMode.get(), 0);
|
Renderer.boxWithLines(Renderer.NORMAL, Renderer.LINES, blockPos.down(), sideColor.get(), lineColor.get(), shapeMode.get(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findSlot() {
|
private int findSlot() {
|
||||||
return InvUtils.findItemInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
|
return InvUtils.findItemInHotbar(itemStack -> blocks.get().contains(Block.getBlockFromItem(itemStack.getItem())));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validSpawn(BlockPos blockPos, BlockState blockState) {
|
private boolean validSpawn(BlockPos blockPos) {
|
||||||
if (blockPos.getY() == 0) return false;
|
BlockState blockState = mc.world.getBlockState(blockPos);
|
||||||
if (!(blockState.getBlock() instanceof AirBlock)) return false;
|
|
||||||
|
|
||||||
bp.set(blockPos).move(0, -1, 0);
|
if (blockPos.getY() == 0) return false;
|
||||||
if (!topSurface(mc.world.getBlockState(bp))) {
|
if (!(blockState.getBlock() instanceof AirBlock)) return false;
|
||||||
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;
|
if (!topSurface(mc.world.getBlockState(blockPos.down()))) {
|
||||||
else return mc.world.getLightLevel(LightType.BLOCK, blockPos) <= 7;
|
if (mc.world.getBlockState(blockPos.down()).getCollisionShape(mc.world, blockPos.down()) != VoxelShapes.fullCube()) return false;
|
||||||
}
|
if (mc.world.getBlockState(blockPos.down()).isTranslucent(mc.world, blockPos.down())) return false;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean topSurface(BlockState blockState) {
|
if (mc.world.getLightLevel(blockPos, 0) <= 7) return false;
|
||||||
if (blockState.getBlock() instanceof SlabBlock && blockState.get(SlabBlock.TYPE) == SlabType.TOP) return true;
|
else return mc.world.getLightLevel(LightType.BLOCK, blockPos) <= 7;
|
||||||
else return blockState.getBlock() instanceof StairsBlock && blockState.get(StairsBlock.HALF) == BlockHalf.TOP;
|
}
|
||||||
}
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Block> getDefaultBlocks() {
|
||||||
|
List<Block> defaultBlocks = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Block block : Registry.BLOCK) {
|
||||||
|
if (block instanceof SlabBlock) defaultBlocks.add(block);
|
||||||
|
if (block instanceof AbstractButtonBlock) defaultBlocks.add(block);
|
||||||
|
if (block instanceof TorchBlock) defaultBlocks.add(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defaultBlocks;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user