From b5f720edc2a192a543af1672d72a23f9740a4df7 Mon Sep 17 00:00:00 2001 From: StormyBytes Date: Sun, 18 Jul 2021 12:17:22 +0700 Subject: [PATCH] Added BlockIn (selftrap + surround + any block) --- .../rejects/MeteorRejectsAddon.java | 129 ++++++++-------- .../cloudburst/rejects/modules/BlockIn.java | 146 ++++++++++++++++++ 2 files changed, 211 insertions(+), 64 deletions(-) create mode 100644 src/main/java/cloudburst/rejects/modules/BlockIn.java diff --git a/src/main/java/cloudburst/rejects/MeteorRejectsAddon.java b/src/main/java/cloudburst/rejects/MeteorRejectsAddon.java index 3d5aebe..917c0a4 100644 --- a/src/main/java/cloudburst/rejects/MeteorRejectsAddon.java +++ b/src/main/java/cloudburst/rejects/MeteorRejectsAddon.java @@ -23,68 +23,69 @@ import org.apache.logging.log4j.Logger; import java.lang.invoke.MethodHandles; public class MeteorRejectsAddon extends MeteorAddon { - public static final Logger LOG = LogManager.getLogger(); - public static final Category CATEGORY = new Category("Rejects", Items.BARRIER.getDefaultStack()); - - @Override - public void onInitialize() { - LOG.info("Initializing Meteor Rejects Addon"); - - MeteorClient.EVENT_BUS.registerLambdaFactory("cloudburst.rejects", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); - - Utils.init(); - GiveUtils.init(); - - Modules modules = Modules.get(); - modules.add(new AntiBot()); - modules.add(new AntiSpawnpoint()); - modules.add(new AntiVanish()); - modules.add(new Auto32K()); - modules.add(new AutoBedTrap()); - modules.add(new AutoExtinguish()); - modules.add(new AutoEz()); - modules.add(new AutoHighway()); - modules.add(new AutoPot()); - modules.add(new AutoTNT()); - modules.add(new AutoWither()); - modules.add(new BoatGlitch()); - modules.add(new BoatPhase()); - modules.add(new Boost()); - modules.add(new ColorSigns()); - modules.add(new Confuse()); - modules.add(new CoordLogger()); - modules.add(new InteractionMenu()); - modules.add(new Lavacast()); - modules.add(new NewChunks()); - modules.add(new ObsidianFarm()); - modules.add(new PacketFly()); - modules.add(new Painter()); - modules.add(new Phase()); - modules.add(new Rendering()); - modules.add(new SkeletonESP()); - modules.add(new SoundLocator()); - - Commands commands = Commands.get(); - commands.add(new GhostCommand()); - commands.add(new GiveCommand()); - commands.add(new SaveSkinCommand()); - commands.add(new HeadsCommand()); - commands.add(new ServerCommand()); - commands.add(new SetBlockCommand()); - commands.add(new TeleportCommand()); - commands.add(new TerrainExport()); - - HUD hud = modules.get(HUD.class); - hud.elements.add(new AppleHud(hud)); - hud.elements.add(new CrystalHud(hud)); - hud.elements.add(new ExpHud(hud)); - hud.elements.add(new CpsHud(hud)); - - GuiThemes.add(new MeteorRoundedGuiTheme()); - } - - @Override - public void onRegisterCategories() { - Modules.registerCategory(CATEGORY); - } + public static final Logger LOG = LogManager.getLogger(); + public static final Category CATEGORY = new Category("Rejects", Items.BARRIER.getDefaultStack()); + + @Override + public void onInitialize() { + LOG.info("Initializing Meteor Rejects Addon"); + + MeteorClient.EVENT_BUS.registerLambdaFactory("cloudburst.rejects", (lookupInMethod, klass) -> (MethodHandles.Lookup) lookupInMethod.invoke(null, klass, MethodHandles.lookup())); + + Utils.init(); + GiveUtils.init(); + + Modules modules = Modules.get(); + modules.add(new AntiBot()); + modules.add(new AntiSpawnpoint()); + modules.add(new AntiVanish()); + modules.add(new Auto32K()); + modules.add(new AutoBedTrap()); + modules.add(new AutoExtinguish()); + modules.add(new AutoEz()); + modules.add(new AutoHighway()); + modules.add(new AutoPot()); + modules.add(new AutoTNT()); + modules.add(new AutoWither()); + modules.add(new BoatGlitch()); + modules.add(new BlockIn()); + modules.add(new BoatPhase()); + modules.add(new Boost()); + modules.add(new ColorSigns()); + modules.add(new Confuse()); + modules.add(new CoordLogger()); + modules.add(new InteractionMenu()); + modules.add(new Lavacast()); + modules.add(new NewChunks()); + modules.add(new ObsidianFarm()); + modules.add(new PacketFly()); + modules.add(new Painter()); + modules.add(new Phase()); + modules.add(new Rendering()); + modules.add(new SkeletonESP()); + modules.add(new SoundLocator()); + + Commands commands = Commands.get(); + commands.add(new GhostCommand()); + commands.add(new GiveCommand()); + commands.add(new SaveSkinCommand()); + commands.add(new HeadsCommand()); + commands.add(new ServerCommand()); + commands.add(new SetBlockCommand()); + commands.add(new TeleportCommand()); + commands.add(new TerrainExport()); + + HUD hud = modules.get(HUD.class); + hud.elements.add(new AppleHud(hud)); + hud.elements.add(new CrystalHud(hud)); + hud.elements.add(new ExpHud(hud)); + hud.elements.add(new CpsHud(hud)); + + GuiThemes.add(new MeteorRoundedGuiTheme()); + } + + @Override + public void onRegisterCategories() { + Modules.registerCategory(CATEGORY); + } } diff --git a/src/main/java/cloudburst/rejects/modules/BlockIn.java b/src/main/java/cloudburst/rejects/modules/BlockIn.java new file mode 100644 index 0000000..3034682 --- /dev/null +++ b/src/main/java/cloudburst/rejects/modules/BlockIn.java @@ -0,0 +1,146 @@ +package cloudburst.rejects.modules; + +import cloudburst.rejects.MeteorRejectsAddon; +import meteordevelopment.meteorclient.events.world.TickEvent; +import meteordevelopment.meteorclient.settings.BoolSetting; +import meteordevelopment.meteorclient.settings.Setting; +import meteordevelopment.meteorclient.settings.SettingGroup; +import meteordevelopment.meteorclient.systems.modules.Module; +import meteordevelopment.meteorclient.utils.player.FindItemResult; +import meteordevelopment.meteorclient.utils.player.InvUtils; +import meteordevelopment.meteorclient.utils.player.PlayerUtils; +import meteordevelopment.meteorclient.utils.world.BlockUtils; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.block.Block; +import net.minecraft.block.FallingBlock; +import net.minecraft.item.BlockItem; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; + +public class BlockIn extends Module { + private final SettingGroup sgGeneral = settings.getDefaultGroup(); + + private final Setting multiPlace = sgGeneral.add(new BoolSetting.Builder() + .name("multi-place") + .description("Whether to place all blocks in a single tick") + .defaultValue(false) + .build() + ); + + private final Setting center = sgGeneral.add(new BoolSetting.Builder() + .name("center") + .description("Whether to center to avoid obstructing placement") + .defaultValue(true) + .build() + ); + + private final Setting rotate = sgGeneral.add(new BoolSetting.Builder() + .name("rotate") + .description("Whether to rotate towards block placements.") + .defaultValue(true) + .build() + ); + + private final Setting turnOff = sgGeneral.add(new BoolSetting.Builder() + .name("turn-off") + .description("Whether to turn off after finished placing.") + .defaultValue(true) + .build() + ); + + private final Setting onlyOnGround = sgGeneral.add(new BoolSetting.Builder() + .name("only-on-ground") + .description("Only places when you are standing on blocks (not in midair).") + .defaultValue(true) + .build() + ); + + private final BlockPos.Mutable bp = new BlockPos.Mutable(); + private boolean return_; + + public BlockIn() { + super(MeteorRejectsAddon.CATEGORY, "block-in", "Block yourself in using any block."); + } + + @EventHandler + private void onPreTick(TickEvent.Pre event) { + if (center.get()) PlayerUtils.centerPlayer(); + if (onlyOnGround.get() && !mc.player.isOnGround()) return; + + return_ = false; + + // Multiplace + if (multiPlace.get()) { + // Bottom + boolean p1 = place(0, -1, 0); + // Lower sides + boolean p2 = place(1, 0, 0); + boolean p3 = place(-1, 0, 0); + boolean p4 = place(0, 0, 1); + boolean p5 = place(0, 0, -1); + // Upper sides + boolean p6 = place(1, 1, 0); + boolean p7 = place(-1, 1, 0); + boolean p8 = place(0, 1, 1); + boolean p9 = place(0, 1, -1); + // Top + boolean p10 = place(0, 2, 0); + + // Turn off + if (turnOff.get() && p1 && p2 && p3 && p4 && p5 && p6 && p7 && p8 && p9 && p10) toggle(); + + // No multiplace + } else { + // Bottom + boolean p1 = place(0, -1, 0); + if (return_) return; + // Lower sides + boolean p2 = place(1, 0, 0); + if (return_) return; + boolean p3 = place(-1, 0, 0); + if (return_) return; + boolean p4 = place(0, 0, 1); + if (return_) return; + boolean p5 = place(0, 0, -1); + if (return_) return; + // Upper sides + boolean p6 = place(1, 1, 0); + if (return_) return; + boolean p7 = place(-1, 1, 0); + if (return_) return; + boolean p8 = place(0, 1, 1); + if (return_) return; + boolean p9 = place(0, 1, -1); + if (return_) return; + // Top + boolean p10 = place(0, 2, 0); + + // Turn off + if (turnOff.get() && p1 && p2 && p3 && p4 && p5 && p6 && p7 && p8 && p9 && p10) toggle(); + } + } + + private boolean place(int x, int y, int z) { + setBlockPos(x, y, z); + FindItemResult findItemResult = InvUtils.findInHotbar(itemStack -> validItem(itemStack, bp)); + if (!BlockUtils.canPlace(bp)) return true; + + if (BlockUtils.place(bp, findItemResult, rotate.get(), 100, true)) { + return_ = true; + } + + return false; + } + + private void setBlockPos(int x, int y, int z) { + bp.set(mc.player.getX() + x, mc.player.getY() + y, mc.player.getZ() + z); + } + + private boolean validItem(ItemStack itemStack, BlockPos pos) { + if (!(itemStack.getItem() instanceof BlockItem)) return false; + Block block = ((BlockItem) itemStack.getItem()).getBlock(); + + if (!Block.isShapeFullCube(block.getDefaultState().getCollisionShape(mc.world, pos))) return false; + return !(block instanceof FallingBlock) || !FallingBlock.canFallThrough(mc.world.getBlockState(pos)); + } +}