merged testclient into chipmunkmod

This commit is contained in:
blackilykat 2023-06-03 19:09:03 +02:00
parent d7a69dc0e5
commit 31124e4364
51 changed files with 2274 additions and 36 deletions

View file

@ -1,6 +1,7 @@
package land.chipmunk.chipmunkmod; package land.chipmunk.chipmunkmod;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import land.chipmunk.chipmunkmod.util.Keybinds;
import land.chipmunk.chipmunkmod.util.gson.BlockPosTypeAdapter; import land.chipmunk.chipmunkmod.util.gson.BlockPosTypeAdapter;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import java.io.InputStream; import java.io.InputStream;
@ -37,8 +38,8 @@ public class ChipmunkMod implements ModInitializer {
} catch (IOException exception) { } catch (IOException exception) {
throw new RuntimeException("Could not load the config", exception); throw new RuntimeException("Could not load the config", exception);
} }
Keybinds.registerOpenGui();
LOGGER.info("Loaded ChipmunkMod (chayapak's fork)"); LOGGER.info("Loaded ChipmunkMod (Blackilykat's fork)");
} }
public static Configuration loadConfig () throws IOException { public static Configuration loadConfig () throws IOException {
@ -50,7 +51,7 @@ public class ChipmunkMod implements ModInitializer {
final File file = CONFIG_FILE; final File file = CONFIG_FILE;
if (!file.exists()) { if (!file.exists()) {
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("default_config.json"); InputStream is = ChipmunkMod.class.getClassLoader().getResourceAsStream("assets/chipmunkmod/default_config.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); BufferedReader reader = new BufferedReader(new InputStreamReader(is));
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();

View file

@ -12,6 +12,7 @@ public class Configuration {
public CustomChat customChat = new CustomChat(); public CustomChat customChat = new CustomChat();
public boolean fullbright = true; // should this be false? public boolean fullbright = true; // should this be false?
public String autoSkinUsername = "off"; public String autoSkinUsername = "off";
public String testbotWebhook = null;
public static class CommandManager { public static class CommandManager {
public String prefix = "."; public String prefix = ".";
@ -27,6 +28,7 @@ public class Configuration {
public BotInfo chipmunk = new BotInfo("'", null); public BotInfo chipmunk = new BotInfo("'", null);
public BotInfo chomens = new BotInfo("*", null); public BotInfo chomens = new BotInfo("*", null);
public BotInfo kittycorp = new BotInfo("^", null); public BotInfo kittycorp = new BotInfo("^", null);
public BotInfo testbot = new BotInfo("-", null);
} }
@AllArgsConstructor @AllArgsConstructor

View file

@ -41,6 +41,7 @@ public class CommandManager {
AutoSkinCommand.register(this.dispatcher); AutoSkinCommand.register(this.dispatcher);
ReloadConfigCommand.register(this.dispatcher); ReloadConfigCommand.register(this.dispatcher);
LoopCrouchCommand.register(this.dispatcher); LoopCrouchCommand.register(this.dispatcher);
AutoDeopCommand.register(this.dispatcher);
} }
public void executeCommand (String command) { public void executeCommand (String command) {

View file

@ -0,0 +1,62 @@
package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoDeopModule;
import land.chipmunk.chipmunkmod.util.Chat;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static com.mojang.brigadier.arguments.StringArgumentType.string;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
public class AutoDeopCommand {
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
final AutoDeopCommand instance = new AutoDeopCommand();
dispatcher.register(
literal("autodeop")
.then(
literal("add")
.then(argument("username", string()).executes(instance::add))
)
.then(
literal("remove")
.then(argument("username", string()).executes(instance::remove))
)
.then(
literal("list").executes(instance::list)
)
);
}
public int add(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
String username = getString(context, "username");
if(AutoDeopModule.players.contains(username)) {
throw new SimpleCommandExceptionType(Text.translatable("That player is already in the AutoDeop list!")).create();
}
AutoDeopModule.players.add(username);
Chat.sendGreen("Added " + username + " to the AutoDeop list!");
return 1;
}
public int remove(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
String username = getString(context, "username");
if(!AutoDeopModule.players.contains(username)) {
throw new SimpleCommandExceptionType(Text.translatable("That player is not in the AutoDeop list!")).create();
}
AutoDeopModule.players.remove(username);
Chat.sendGreen("Removed " + username + " to the AutoDeop list!");
return 1;
}
public int list(CommandContext<FabricClientCommandSource> context) {
Chat.sendGold("AutoDeop player list:");
for (String player : AutoDeopModule.players) {
Chat.send(" - " + player);
}
return 1;
}
}

View file

@ -7,6 +7,8 @@ import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal; import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument; import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource; import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen; import net.minecraft.client.gui.screen.ConnectScreen;
@ -32,31 +34,25 @@ public class UsernameCommand {
literal("set") literal("set")
.then( .then(
argument("username", greedyString()) argument("username", greedyString())
.executes(c -> updateUsername(c)) .executes(UsernameCommand::updateUsername)
) )
) )
.then(
literal("revert")
.executes(c -> updateSession(c, ORIGINAL_SESSION))
)
); );
} }
public static int updateUsername (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException { public static int updateUsername (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
final String username = getString(context, "username"); final String username = getString(context, "username");
if (username.length() > 16) throw USERNAME_TOO_LONG.create(); if (username.length() > 16) throw USERNAME_TOO_LONG.create();
final Session session = new Session(username, "", "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG); return updateSession(context, username);
return updateSession(context, session);
} }
public static int updateSession (CommandContext<FabricClientCommandSource> context, Session session) throws CommandSyntaxException { public static int updateSession (CommandContext<FabricClientCommandSource> context, String username) throws CommandSyntaxException {
final FabricClientCommandSource source = context.getSource(); final FabricClientCommandSource source = context.getSource();
final MinecraftClient client = source.getClient(); final MinecraftClient client = source.getClient();
((MinecraftClientAccessor) client).session(session); SharedVariables.username = username;
// TODO: Put this in a separate class
final ServerInfo info = client.getCurrentServerEntry(); final ServerInfo info = client.getCurrentServerEntry();
client.world.disconnect(); client.world.disconnect();
client.disconnect(); client.disconnect();

View file

@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.listeners.Listener; import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager; import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.modules.RainbowName; import land.chipmunk.chipmunkmod.modules.RainbowName;
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoDeopModule;
import net.minecraft.client.gui.hud.MessageIndicator; import net.minecraft.client.gui.hud.MessageIndicator;
import net.minecraft.network.message.MessageSignatureData; import net.minecraft.network.message.MessageSignatureData;
import net.minecraft.text.Text; import net.minecraft.text.Text;
@ -12,8 +13,23 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Mixin(net.minecraft.client.gui.hud.ChatHud.class) @Mixin(net.minecraft.client.gui.hud.ChatHud.class)
public class ChatHudMixin { public class ChatHudMixin {
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At("TAIL"))
private void testclient$autoDeopListener(Text message, MessageSignatureData signature, MessageIndicator indicator, CallbackInfo ci) {
String pattern = "\\[(.*?)\\: Made (.*?) a server operator\\]";
Matcher matcher = Pattern.compile(pattern).matcher(message.getString());
if (matcher.find()) {
AutoDeopModule.execute(matcher.group(1), matcher.group(2));
}
}
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true) @Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true)
public void addMessage(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) { public void addMessage(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) {
try { try {
@ -34,4 +50,5 @@ public class ChatHudMixin {
listener.chatMessageReceived(message); listener.chatMessageReceived(message);
} }
} }
} }

View file

@ -1,6 +1,9 @@
package land.chipmunk.chipmunkmod.mixin; package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.modules.CustomChat; import land.chipmunk.chipmunkmod.modules.CustomChat;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import land.chipmunk.chipmunkmod.util.Webhook;
import net.minecraft.client.gui.widget.TextFieldWidget; import net.minecraft.client.gui.widget.TextFieldWidget;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@ -12,12 +15,26 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import land.chipmunk.chipmunkmod.command.CommandManager; import land.chipmunk.chipmunkmod.command.CommandManager;
import java.io.IOException;
@Mixin(net.minecraft.client.gui.screen.ChatScreen.class) @Mixin(net.minecraft.client.gui.screen.ChatScreen.class)
public class ChatScreenMixin { public class ChatScreenMixin {
@Shadow protected TextFieldWidget chatField; @Shadow protected TextFieldWidget chatField;
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true) @Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) { public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
if(ChipmunkMod.CONFIG.testbotWebhook != null && chatText.startsWith("-")) {
new Thread(() -> {
Webhook webhook = new Webhook(ChipmunkMod.CONFIG.testbotWebhook);
webhook.setUsername("ChipmunkMod");
webhook.setContent(SharedVariables.username);
try {
webhook.execute();
} catch (IOException e) {
throw new RuntimeException(e);
}
}).start();
}
final CommandManager commandManager = CommandManager.INSTANCE; final CommandManager commandManager = CommandManager.INSTANCE;
if (chatText.startsWith(commandManager.prefix)) { if (chatText.startsWith(commandManager.prefix)) {

View file

@ -4,6 +4,9 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.DecoderException; import io.netty.handler.codec.DecoderException;
import land.chipmunk.chipmunkmod.listeners.Listener; import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager; import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.AntiParticleKickModule;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.network.listener.PacketListener; import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.Packet; import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket; import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
@ -14,6 +17,8 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.ArrayList;
@Mixin(net.minecraft.network.ClientConnection.class) @Mixin(net.minecraft.network.ClientConnection.class)
public class ClientConnectionMixin { public class ClientConnectionMixin {
@Inject(at = @At("HEAD"), method = "disconnect", cancellable = true) @Inject(at = @At("HEAD"), method = "disconnect", cancellable = true)
@ -26,6 +31,7 @@ public class ClientConnectionMixin {
@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true) @Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
private void exceptionCaught (ChannelHandlerContext context, Throwable ex, CallbackInfo ci) { private void exceptionCaught (ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
if (ex instanceof DecoderException) { if (ex instanceof DecoderException) {
Chat.sendGold("ChipmunkMod caught an exception in ClientConnection.");
ci.cancel(); ci.cancel();
ex.printStackTrace(); ex.printStackTrace();
} }
@ -35,10 +41,10 @@ public class ClientConnectionMixin {
private static void handlePacket (Packet<?> packet, PacketListener _listener, CallbackInfo ci) { private static void handlePacket (Packet<?> packet, PacketListener _listener, CallbackInfo ci) {
// please don't skid this.,. // please don't skid this.,.
// mabe mabe mabe // mabe mabe mabe
if (packet instanceof ParticleS2CPacket t_packet) { // lol i had my own im just gonna cop ypaste that :D
final double max = 1000; if(packet instanceof ParticleS2CPacket) {
if(AntiParticleKickModule.instance.isEnabled && ((ParticleS2CPacket) packet).getCount()>1000) {
if (t_packet.getCount() > max) { if(((ParticleS2CPacket) packet).getCount()>1000) Chat.sendGold("ChipmunkMod prevented a particle kick!");
ci.cancel(); ci.cancel();
} }
} }
@ -51,7 +57,7 @@ public class ClientConnectionMixin {
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true) @Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
private void sendPacket (Packet<?> packet, CallbackInfo ci) { private void sendPacket (Packet<?> packet, CallbackInfo ci) {
if (packet instanceof RequestCommandCompletionsC2SPacket t_packet) { if (packet instanceof RequestCommandCompletionsC2SPacket t_packet) {
if (t_packet.getPartialCommand().length() > 2048) { if (t_packet.getPartialCommand().length() > 2048) { // o thanks fancy
ci.cancel(); ci.cancel();
return; return;
} }
@ -61,4 +67,20 @@ public class ClientConnectionMixin {
listener.packetSent(packet); listener.packetSent(packet);
} }
} }
@Inject(method = "send(Lnet/minecraft/network/packet/Packet;)V", at = @At("HEAD"), cancellable = true)
private void testclient$delayPackets(Packet<?> packet, CallbackInfo ci) {
if(DelayPacketsModule.instance.isEnabled) {
DelayPacketsModule.packetsToSend.add(packet);
ci.cancel();
}
}
@Inject(method = "disconnect", at = @At("TAIL"))
private void testclient$disablePacketDelayerOnDisconnect(Text disconnectReason, CallbackInfo ci) {
DelayPacketsModule.instance.isEnabled = false;
DelayPacketsModule.packetsToSend = new ArrayList<>();
}
} }

View file

@ -1,5 +1,7 @@
package land.chipmunk.chipmunkmod.mixin; package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.utility.BlockGuardianParticlesModule;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import net.minecraft.client.particle.ElderGuardianAppearanceParticle; import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
import net.minecraft.client.particle.Particle; import net.minecraft.client.particle.Particle;
import net.minecraft.client.world.ClientWorld; import net.minecraft.client.world.ClientWorld;
@ -12,7 +14,9 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ElderGuardianAppearanceParticle.Factory.class) @Mixin(ElderGuardianAppearanceParticle.Factory.class)
public class ElderGuardianAppearanceParticleMixin { public class ElderGuardianAppearanceParticleMixin {
@Inject(method = "createParticle(Lnet/minecraft/particle/DefaultParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD")) @Inject(method = "createParticle(Lnet/minecraft/particle/DefaultParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"))
private void createParticle (DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) { private void testClient$limitGuardianParticles(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
cir.cancel(); if(BlockGuardianParticlesModule.instance.isEnabled) cir.cancel();
if(SharedVariables.elderGuardianParticleTimer > 0) cir.cancel();
SharedVariables.elderGuardianParticleTimer = 200;
} }
} }

View file

@ -0,0 +1,23 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
import net.minecraft.client.Keyboard;
import org.lwjgl.glfw.GLFW;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Keyboard.class)
public class KeyboardMixin {
@Inject(method = "onKey", at = @At("HEAD"), cancellable = true)
private void testclient$keyBindsOverrides(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) {
if(key == GLFW.GLFW_KEY_KP_0 && action == 1) {
DelayPacketsModule.instance.isEnabled = !DelayPacketsModule.instance.isEnabled;
if(!DelayPacketsModule.instance.isEnabled) {
DelayPacketsModule.instance.deactivateRunnable.run();
}
ci.cancel();
}
}
}

View file

@ -0,0 +1,33 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(MultiplayerScreen.class)
public class MultiplayerScreenMixin extends Screen{
@Shadow private ButtonWidget buttonEdit;
protected MultiplayerScreenMixin(Text title) {
super(title);
}
@Inject(method="init", at = @At("TAIL"))
private void testclient$addUsernameField(CallbackInfo ci) {
TextFieldWidget usernameField = new TextFieldWidget(textRenderer, buttonEdit.getX()-130, buttonEdit.getY(), 120, 20, Text.literal("Username"));;
usernameField.setText(SharedVariables.username);
usernameField.setChangedListener(text -> {
SharedVariables.username = text;
});
usernameField.setMaxLength(16);
addDrawableChild(usernameField);
}
}

View file

@ -0,0 +1,17 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtIo;
import net.minecraft.nbt.NbtTagSizeTracker;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import java.io.DataInput;
@Mixin(NbtIo.class)
public interface NbtIoInvoker {
@Invoker(value = "read")
static NbtElement readInvoker(DataInput input, int depth, NbtTagSizeTracker tracker) {
throw new AssertionError();
}
}

View file

@ -1,5 +1,7 @@
package land.chipmunk.chipmunkmod.mixin; package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.nbt.*; import net.minecraft.nbt.*;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.At;
@ -11,18 +13,32 @@ import java.io.IOException;
@Mixin(NbtIo.class) @Mixin(NbtIo.class)
public class NbtIoMixin { public class NbtIoMixin {
@Inject(method = "read(Ljava/io/DataInput;ILnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;",at = @At("HEAD"), cancellable = true) @Inject(method = "read(Ljava/io/DataInput;ILnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtElement;",at = @At("HEAD"), cancellable = true)
private static void read(DataInput input, int depth, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtElement> cir) { private static void testclient$preventNbtKick(DataInput input, int depth, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtElement> cir) throws IOException {
try {
byte b = input.readByte(); byte b = input.readByte();
if (b == 0) { if (b == 0) {
cir.setReturnValue(NbtEnd.INSTANCE); cir.setReturnValue(NbtEnd.INSTANCE);
} else {
NbtString.skip(input);
try {
cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker));
} catch (Exception var7) {
Chat.sendGold("ChipmunkMod prevented an NBT kick!");
cir.setReturnValue(NbtEnd.INSTANCE); // i don't fucking know i just copied
}
}
} }
NbtString.skip(input); @Inject(method = "read(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtCompound;", at = @At("HEAD"), cancellable = true)
cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker)); private static void testclient$antiNbtKickPreventLag(DataInput input, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtCompound> cir) {
} catch (IOException e) { NbtElement nbtElement = NbtIoInvoker.readInvoker(input, 0, tracker);
e.printStackTrace(); if (nbtElement instanceof NbtCompound) {
cir.setReturnValue((NbtCompound)nbtElement);
} else {
ChipmunkMod.LOGGER.warn("ChipmunkMod hopefully prevented lag lol idk");
} }
} }
} }

View file

@ -0,0 +1,18 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.movement.SlipperyWorldModule;
import net.minecraft.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Block.class)
public class PlayerEntityMixin {
@Inject(method = "getSlipperiness", at = @At("HEAD"), cancellable = true)
private void testclient$slipperyWorld(CallbackInfoReturnable<Float> cir) {
if(SlipperyWorldModule.instance.isEnabled) {
cir.setReturnValue(((Double) SlipperyWorldModule.instance.optionList.get(0).optionValue).floatValue());
}
}
}

View file

@ -0,0 +1,21 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import net.minecraft.client.util.Session;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Session.class)
public abstract class SessionMixin {
@Shadow public abstract Session.AccountType getAccountType();
@Inject(method = "getUsername", at=@At("RETURN"), cancellable = true)
void testclient$overrideUsernameGetter(CallbackInfoReturnable<String> cir) {
// only overrides when gui has been initialized cause issues
if(Gui.gui != null) cir.setReturnValue(SharedVariables.username);
}
}

View file

@ -0,0 +1,22 @@
package land.chipmunk.chipmunkmod.mixin;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.lang.reflect.Type;
@Mixin(Text.Serializer.class)
public class TextMixin {
@Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/text/MutableText;", at = @At("HEAD"), cancellable = true)
private void testclient$preventChatOverflowExploit(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
Throwable throwable = new Throwable();
if(throwable.getStackTrace().length >= 1000 && throwable.getStackTrace()[999].getMethodName().equals("deserialize")) cir.setReturnValue(Text.literal("TestClient prevented a text overflow exploit i think ("+throwable.getStackTrace().length+")").formatted(Formatting.GOLD));
}
}

View file

@ -0,0 +1,25 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import net.minecraft.client.gui.screen.TitleScreen;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(TitleScreen.class)
public class TitleScreenMixin {
@Shadow @Nullable private String splashText;
@Inject(method = "init", at = @At("HEAD"))
void testclient$initializeGui(CallbackInfo ci) {
splashText = "owo";
if(Gui.gui == null){
Gui.initAutoRefresher();
Gui.addComponents();
Gui.gui = new Gui();
}
}
}

View file

@ -0,0 +1,197 @@
package land.chipmunk.chipmunkmod.testclient.gui;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.gui.components.Category;
import land.chipmunk.chipmunkmod.testclient.modules.antip2w.DelayPacketsModule;
import land.chipmunk.chipmunkmod.testclient.modules.combat.KillAuraModule;
import land.chipmunk.chipmunkmod.testclient.modules.movement.*;
import land.chipmunk.chipmunkmod.testclient.modules.op.AntiTeleportModule;
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoDeopModule;
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoOpModule;
import land.chipmunk.chipmunkmod.testclient.modules.op.AutoSudoKickModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.AutoToolsModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.BlockGuardianParticlesModule;
import land.chipmunk.chipmunkmod.testclient.modules.utility.GuiMoveModule;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
public class Gui extends Screen{
public static ArrayList<Category> categoryList = new ArrayList<>();
public static Gui gui;
public <T extends Element & Drawable & Selectable> void publicAddDrawableChild(T element) {
addDrawableChild(element);
}
public void publicRemove(Element child) {
remove(child);
}
public Gui() {
super(Text.literal("TestClient menu"));
AtomicInteger categoryX = new AtomicInteger(20);
AtomicInteger categoryY = new AtomicInteger(20);
categoryList.forEach(category -> {
category.setFullHeight(categoryY.get());
addDrawableChild(category); // adapt category to be buttons
category.setX(categoryX.get());
category.setY(categoryY.get());
// category.setWidth(Main.MC.textRenderer.getWidth(category.getMessage()) + 20);
ChipmunkMod.LOGGER.info("Created category " + category.getMessage().getString() + " at x " + categoryX.get() + "(" + category.getX() + ") and y " + categoryY + "(" + category.getY() + ") and is " + category.getWidth() + " wide and " + category.getFullHeight() + " high");
categoryX.addAndGet(category.getWidth() + 20);
if(categoryX.get() + category.getWidth() + 20 > MinecraftClient.getInstance().getWindow().getWidth()) {
categoryX.set(20);
categoryY.addAndGet(40); //TODO make a max height per row at some point
/* Something like:
+----------------------+
| #### ### #### ##### |
| //// /// ///// |
| /// |
| ### ##### ### |
| /// ///// |
| ///// |
| ///// |
+----------------------+
actually nvm its good as it is now
*/
}
AtomicInteger yPos = new AtomicInteger(category.getY());
if(category.isExtended) category.moduleList.forEach(module -> {
publicAddDrawableChild(module);
module.setX(category.getX());
module.setY(yPos.addAndGet(20));
module.setWidth(category.getWidth());
});
});
}
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
// this.renderBackground(matrices);
super.render(matrices, mouseX, mouseY, delta);
}
public static void open() {
gui = new Gui();
MinecraftClient.getInstance().setScreen(gui);
}
// private class ScreenGui extends LightweightGuiDescription {
// public ScreenGui() {
// int scale = Main.MC.options.getGuiScale().getValue();
// // create invisible panel
// root = new Root();
// // set it as root
// setRootPanel(root);
// // make panel size big as the screen
// root.setSize(Main.MC.getWindow().getWidth()/scale, Main.MC.getWindow().getHeight()/scale); // still broken but fuck it idc
// root.setInsets(Insets.ROOT_PANEL);
//
// // set initial positions for the buttons
// AtomicInteger categoryX = new AtomicInteger(20);
// AtomicInteger categoryY = new AtomicInteger(20);
// categoryList.forEach(category -> {
// category.setFullHeight(categoryY.get());
// root.add(category, categoryX.get(), categoryY.get());
// category.setWidth(Main.MC.textRenderer.getWidth(category.getLabel()) + 20);
//
// Main.LOGGER.info("Created category " + category.getLabel().getString() + " at x " + categoryX.get() + "(" + category.getX() + ") and y " + categoryY + "(" + category.getY() + ") and is " + category.getWidth() + " wide and " + category.getFullHeight() + " high");
// categoryX.addAndGet(category.getWidth() + 20);
// if(categoryX.get() + category.getWidth() + 20 > root.getWidth()) {
// categoryX.set(20);
// categoryY.addAndGet(40); //TODO make a max height per row at some point
// /* Something like:
// +----------------------+
// | #### ### #### ##### |
// | //// /// ///// |
// | /// |
// | ### ##### ### |
// | /// ///// |
// | ///// |
// | ///// |
// +----------------------+
// actually nvm its good as it is now
// */
// }
// });
//
// root.validate(this);
// }
// }
public static void refreshGui() {
gui = new Gui();
}
public static void initAutoRefresher() {
// ClientTickEvents.END_CLIENT_TICK.register(listener -> {
// int scale = Main.MC.options.getGuiScale().getValue();
//// scale = 1;
// if(
// Main.MC.getWindow().getWidth()/scale != gui.root.getWidth()
// || Main.MC.getWindow().getHeight()/scale != gui.root.getHeight()
// ) {
// Main.LOGGER.info("Refreshed GUI size because "
// + Main.MC.getWindow().getWidth()/scale
// + " != "
// + gui.root.getWidth()
// + " or "
// + Main.MC.getWindow().getHeight()/scale
// + " != "
// + gui.root.getHeight()
// );
// refreshGui();
// }
// });
}
public static void addComponents() {
new Category("Movement")
.withModule(new FlightModule())
.withModule(new SpeedModule())
.withModule(new FreezeModule())
.withModule(new AirJumpModule())
.withModule(new JesusModule())
.withModule(SlipperyWorldModule.instance)
.register();
new Category("Combat")
.withModule(new KillAuraModule())
.withModule(new Module("Reach"))
.withModule(new Module("Bow Aimbot"))
.register();
new Category("Utility")
.withModule(AutoToolsModule.instance)
.withModule(AntiVoidModule.instance)
.withModule(BlockGuardianParticlesModule.instance)
.withModule(new GuiMoveModule())
.register();
new Category("OP")
.withModule(new AntiTeleportModule())
.withModule(AutoDeopModule.instance)
.withModule(AutoOpModule.instance)
.withModule(AutoSudoKickModule.instance)
.register();
new Category("p2w")
.withModule(DelayPacketsModule.instance)
.register();
}
}

View file

@ -0,0 +1,44 @@
package land.chipmunk.chipmunkmod.testclient.gui;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
public class OptionsScreen extends Screen {
public static int backgroundColor = 0x99000000;
ArrayList<Option<?>> optionList = new ArrayList<>();
public OptionsScreen(Module module) {
super(module.getMessage().copy().append("'s options"));
for (Option<?> option : module.optionList) {
optionList.add(option);
addDrawableChild(option.widget);
}
}
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
fill(matrices, 40, 40, width-40, height-40, backgroundColor);
int textWidth = MinecraftClient.getInstance().textRenderer.getWidth(getTitle());
AtomicInteger lineY = new AtomicInteger(70);
AtomicInteger textY = new AtomicInteger(50);
drawTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, getTitle(), width/2 - textWidth/2, 50, 0xFFFFFFFF);
fill(matrices, 45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
for (Option<?> option : optionList) {
lineY.addAndGet(30);
drawTextWithShadow(matrices, MinecraftClient.getInstance().textRenderer, option.name, 50, textY.addAndGet(30), 0xFFFFFFFF);
fill(matrices, 45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
// drawHorizontalLine(matrices, 45, width-45, lineY.addAndGet(30), 0x33FFFFFF);
option.widget.setX(width - 50 - option.widget.getWidth());
option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2));
}
super.render(matrices, mouseX, mouseY, delta);
}
}

View file

@ -0,0 +1,108 @@
package land.chipmunk.chipmunkmod.testclient.gui.components;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
public class Category extends ButtonWidget {
public ArrayList<Module> moduleList = new ArrayList<>();
public boolean isExtended;
private int fullHeight;
private int defaultColor = 0xAAAA0000;
private int hoveredColor = 0xCCCC0000;
public Category(String name) {
super(0, 0, 20, 20, Text.literal(name), widget -> {}, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
isExtended = false;
}
@Override
public void onPress() {
isExtended = !isExtended;
if(isExtended) ChipmunkMod.LOGGER.info("Extended " + getMessage().getString());
else ChipmunkMod.LOGGER.info("Contracted " + getMessage().getString());
// getModuleList();
AtomicInteger yPos = new AtomicInteger(getY());
moduleList.forEach(module -> {
if(isExtended) {
Gui.gui.publicAddDrawableChild(module);
module.setX(getX());
module.setY(yPos.addAndGet(20));
module.setWidth(getWidth());
}
else Gui.gui.publicRemove(module);
// give module same width as category
// module.setWidth(getWidth());
});
}
public int getFullHeight() {
return fullHeight;
}
public void setFullHeight(int fullHeight) {
this.fullHeight = fullHeight;
}
public void register() {
Gui.categoryList.add(this);
}
public Category withModule(Module module) {
int moduleWidth = MinecraftClient.getInstance().textRenderer.getWidth(module.getMessage())+16;
ChipmunkMod.LOGGER.info("Module (" + module.getMessage() +") width: " + moduleWidth);
ChipmunkMod.LOGGER.info("This width: " + width);
ChipmunkMod.LOGGER.info("Module width is larger than this width: " + (moduleWidth > width));
if(moduleWidth > width) width = moduleWidth;
ChipmunkMod.LOGGER.info("Width after: " + width);
moduleList.add(module);
return this;
}
public void getModuleList() {
Chat.send(this.getMessage().getString() + "'s modules: ");
moduleList.forEach(module -> {
Chat.send(" - " + module.getMessage().getString());
});
}
// @Override
// public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
// boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX<getWidth() && mouseY<getHeight());
// boolean isHovered = false; //0 = regular, 1 = hovered.
// if (hovered || isFocused()) {
// isHovered = true;
// }
// // draw the box
// ScreenDrawing.coloredRect(matrices, x, y, getWidth(), getHeight(), isHovered ? hoveredColor : defaultColor);
//
// if (this.getLabel()!=null) {
// // draw the text
// int textColor = 0xE0E0E0;
// ScreenDrawing.drawStringWithShadow(matrices, this.getLabel().asOrderedText(), alignment, x, y + ((20 - 8) / 2), width, textColor);
// /* else if (hovered) {
// color = 0xFFFFA0;
// }*/
//
// // int xOffset = (icon != null && alignment == HorizontalAlignment.LEFT) ? ICON_SPACING+iconSize+ICON_SPACING : 0;
// }
// }
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
MinecraftClient minecraftClient = MinecraftClient.getInstance();
fill(matrices, getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
this.drawMessage(matrices, minecraftClient.textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
}
}

View file

@ -0,0 +1,188 @@
package land.chipmunk.chipmunkmod.testclient.gui.components;
import land.chipmunk.chipmunkmod.testclient.gui.OptionsScreen;
import land.chipmunk.chipmunkmod.util.TickRunnableHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
import java.util.ArrayList;
public class Module extends ButtonWidget {
public Runnable activateRunnable;
public Runnable deactivateRunnable;
public Runnable endTickRunnable;
public boolean needsInWorld = true;
public boolean isEnabled;
public static int defaultColor = 0xCC333333;
public static int hoveredColor = 0xEE444444;
public static int disabledBarColor = 0xAA000000;
public static int enabledBarColor = 0xEE00AA00;
public ArrayList<Option<?>> optionList = new ArrayList<>();
public Module(String name) {
super(0, 0, 20, 20, Text.literal(name), widget -> {}, ButtonWidget.DEFAULT_NARRATION_SUPPLIER);
isEnabled = false;
// optionsButton = new OptionsButton(this);
}
public Module withOption(Option<?> option) {
optionList.add(option);
return this;
}
// @Override
// public void onPress() {
//
// isEnabled = !isEnabled;
// if (isEnabled) {
// if (activateRunnable != null) activateRunnable.run();
// if (endTickRunnable != null) TickRunnableHandler.runAtTickEnd.add(endTickRunnable);
// } else {
// if (deactivateRunnable != null) deactivateRunnable.run();
// if (endTickRunnable != null) TickRunnableHandler.runAtTickEnd.remove(endTickRunnable);
// }
// }
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (this.active && this.visible && clicked(mouseX, mouseY)) {
if (button == 0) {
isEnabled = !isEnabled;
if (isEnabled) {
if (activateRunnable != null) activateRunnable.run();
if (endTickRunnable != null) TickRunnableHandler.runAtTickEnd.add(endTickRunnable);
} else {
if (deactivateRunnable != null) deactivateRunnable.run();
if (endTickRunnable != null) TickRunnableHandler.runAtTickEnd.remove(endTickRunnable);
}
return true;
} else if(button == 1) {
MinecraftClient.getInstance().setScreen(new OptionsScreen(this));
return true;
}
}
return false;
}
// void setWidth(int width) {
// this.width = width;
// }
// @Override
// public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
// MinecraftClient minecraftClient = MinecraftClient.getInstance();
// RenderSystem.setShaderTexture(0, WIDGETS_TEXTURE);
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, this.alpha);
// RenderSystem.enableBlend();
// RenderSystem.enableDepthTest();
// drawNineSlicedTexture(matrices, this.getX(), this.getY(), this.getWidth(), this.getHeight(), 20, 4, 200, 20, 0, this.getTextureY());
//
// RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
// int i = this.active ? 16777215 : 10526880;
// this.drawMessage(matrices, minecraftClient.textRenderer, i | MathHelper.ceil(this.alpha * 255.0F) << 24);
// }
// public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
// boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX<getWidth() && mouseY<getHeight());
// boolean isHovered = false; //0 = regular, 1 = hovered.
// if (hovered || isFocused()) {
// isHovered = true;
// }
// // draw the box
// ScreenDrawing.coloredRect(matrices, x, y, getWidth(), getHeight(), isHovered ? hoveredColor : defaultColor);
// // draw enabled/disabled indicator
// ScreenDrawing.coloredRect(matrices, x, y, 2, getHeight(), isEnabled ? enabledBarColor : disabledBarColor);
//
//
// if (this.getLabel()!=null) {
// // draw the text
// int textColor = 0xE0E0E0;
// ScreenDrawing.drawStringWithShadow(matrices, this.getLabel().asOrderedText(), alignment, x+1 /* to make it offset to the indicator */, y + ((20 - 8) / 2), width, textColor);
// /* else if (hovered) {
// color = 0xFFFFA0;
// }*/
//
// // int xOffset = (icon != null && alignment == HorizontalAlignment.LEFT) ? ICON_SPACING+iconSize+ICON_SPACING : 0;
// }
// }
public Module atActivate(Runnable runnable) {
activateRunnable = runnable;
return this;
}
public Module atDeactivate(Runnable runnable) {
deactivateRunnable = runnable;
return this;
}
public Module atEndTick(Runnable runnable) {
endTickRunnable = runnable;
return this;
}
private Module getThis() {return this;}
@Override
public void renderButton(MatrixStack matrices, int mouseX, int mouseY, float delta) {
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
fill(matrices, getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
fill(matrices, getX(), getY(), getX()+2, getY()+getHeight(), isEnabled ? enabledBarColor : disabledBarColor);
drawMessage(matrices, MinecraftClient.getInstance().textRenderer, 0xFFFFFF | MathHelper.ceil(this.alpha * 255.0F) << 24);
}
// public static class OptionsButton extends WButton {
// public boolean isHovered = false;
// public Module parentModule;
// public OptionsButton(Module parent) {
// super(Text.of(""));
// setSize(20, 20);
// parentModule = parent;
// setOnClick(() -> {
// int scale = Main.MC.options.getGuiScale().getValue();
// Gui.gui.root.add(new OptionsPanel(parentModule), 10, 10, (Main.MC.getWindow().getWidth()/scale)-40, (Main.MC.getWindow().getHeight()/scale)-40);
// });
// }
//
//
// private final int defaultColor = 0x00333333;
// private final int hoveredColor = 0xEE777777;
//
// @Override
// public void paint(MatrixStack matrices, int x, int y, int mouseX, int mouseY) {
// boolean hovered = (mouseX>=0 && mouseY>=0 && mouseX<getWidth() && mouseY<getHeight());
// isHovered = false; //0 = regular, 1 = hovered.
// if (hovered || isFocused()) {
// isHovered = true;
// }
// // draw the box
// ScreenDrawing.coloredRect(matrices, x, y, getWidth(), getHeight(), isHovered ? hoveredColor : defaultColor);
//
//
// if (this.getLabel()!=null) {
// // draw the text
// int textColor = 0xE0E0E0;
// ScreenDrawing.drawStringWithShadow(matrices, this.getLabel().asOrderedText(), alignment, x, y + ((20 - 8) / 2), width, textColor);
// /* else if (hovered) {
// color = 0xFFFFA0;
// }*/
//
// // int xOffset = (icon != null && alignment == HorizontalAlignment.LEFT) ? ICON_SPACING+iconSize+ICON_SPACING : 0;
// }
// }
//
//
//
// }
}
/*
TODO:
- finish translating Module from WButton to vanilla ButtonWidget
- translate categories from WButton to vanilla ButtonWidget
- make everything work with vanilla stuff
The goal is to stop struggling with screen size. It's so annoying with LibGui.
*/

View file

@ -0,0 +1,15 @@
package land.chipmunk.chipmunkmod.testclient.gui.components;
import net.minecraft.client.gui.widget.ClickableWidget;
public abstract class Option<ValueType> {
public String name;
public ValueType optionValue;
public ClickableWidget widget;
public Option(String name, ValueType defaultValue) {
this.name = name;
optionValue = defaultValue;
}
}

View file

@ -0,0 +1,56 @@
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.text.Text;
public class DoubleSliderOption extends Option<Double> {
public double maxValue = 100;
public double minValue = 0;
int roundTo = 4;
SliderWidget sliderWidget = new SliderWidget(0, 0, 100, 20, Text.literal("text ig"), 0.0) {
@Override
protected void updateMessage() {
setMessage(Text.literal(round((value * (maxValue - minValue) + minValue), roundTo)+""));
}
@Override
protected void applyValue() {
optionValue = round((value * (maxValue - minValue) + minValue), roundTo);
}
public double getValue() {
return value;
}
};
public DoubleSliderOption(String name, double defaultValue) {
super(name, defaultValue);
optionValue = defaultValue;
widget = sliderWidget;
}
public DoubleSliderOption(String name, double defaultValue, double minValue, double maxValue) {
super(name, defaultValue);
optionValue = defaultValue;
widget = sliderWidget;
this.minValue = minValue;
this.maxValue = maxValue;
}
public DoubleSliderOption(String name, double defaultValue, double minValue, double maxValue, int round) {
super(name, defaultValue);
optionValue = defaultValue;
widget = sliderWidget;
this.minValue = minValue;
this.maxValue = maxValue;
roundTo = round;
}
public static double round(double value, int places) {
if (places < 0) return value;
long factor = (long) Math.pow(10, places);
value = value * factor;
long tmp = Math.round(value);
return (double) tmp / factor;
}
}

View file

@ -0,0 +1,38 @@
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import net.minecraft.client.gui.widget.SliderWidget;
import net.minecraft.text.Text;
public class IntSliderOption extends Option<Integer> {
public int maxValue = 100;
public int minValue = 0;
SliderWidget sliderWidget = new SliderWidget(0, 0, 100, 20, Text.literal("text ig"), 0.0) {
@Override
protected void updateMessage() {
setMessage(Text.literal(((int) (value * (maxValue - minValue) + minValue))+""));
}
@Override
protected void applyValue() {
optionValue = (int) (value * (maxValue - minValue) + minValue);
}
public double getValue() {
return value;
}
};
public IntSliderOption(String name, int defaultValue) {
super(name, defaultValue);
optionValue = defaultValue;
widget = sliderWidget;
}
public IntSliderOption(String name, int defaultValue, int minValue, int maxValue) {
super(name, defaultValue);
optionValue = defaultValue;
widget = sliderWidget;
this.minValue = minValue;
this.maxValue = maxValue;
}
}

View file

@ -0,0 +1,19 @@
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
public class StringOption extends Option<String> {
TextFieldWidget textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 200, 20, Text.empty());
public StringOption(String name, String defaultValue) {
super(name, defaultValue);
textFieldWidget.setText(defaultValue);
textFieldWidget.setChangedListener(text -> {
optionValue = text;
});
widget = textFieldWidget;
}
}

View file

@ -0,0 +1,21 @@
package land.chipmunk.chipmunkmod.testclient.modules.antip2w;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.network.packet.Packet;
import java.util.ArrayList;
public class DelayPacketsModule extends Module {
public static DelayPacketsModule instance = new DelayPacketsModule();
public static ArrayList<Packet<?>> packetsToSend = new ArrayList<>();
public DelayPacketsModule() {
super("Delay packets");
deactivateRunnable = () -> {
packetsToSend.forEach(packet -> {
MinecraftClient.getInstance().getNetworkHandler().getConnection().send(packet);
});
packetsToSend = new ArrayList<>();
};
}
}

View file

@ -0,0 +1,61 @@
package land.chipmunk.chipmunkmod.testclient.modules.combat;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.command.argument.EntityAnchorArgumentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.text.Text;
import net.minecraft.util.math.Box;
import java.util.ArrayList;
import java.util.Objects;
public class KillAuraModule extends Module {
ArrayList<EntityType> attackEntityList = new ArrayList<>();
double reach = 10;
static boolean debug = false;
public KillAuraModule() {
super("KillAura");
attackEntityList.add(EntityType.ZOMBIE);
endTickRunnable = () -> {
debug("Ticked!");
for (Entity entity : MinecraftClient.getInstance().world.getOtherEntities(MinecraftClient.getInstance().player, Box.of(MinecraftClient.getInstance().player.getEyePos(), reach / 2, reach / 2, reach / 2))) {
debug("Found entity " + entity.getType().toString());
for (EntityType entityType : attackEntityList) {
if(Objects.equals(entity.getType().toString(), entityType.toString())) {
debug("And is of the correct entity type");
MinecraftClient.getInstance().inGameHud.setSubtitle(Text.literal(entity.getType().toString()));
MinecraftClient.getInstance().player.lookAt(EntityAnchorArgumentType.EntityAnchor.EYES, entity.getPos());
if(MinecraftClient.getInstance().player.getAttackCooldownProgress(0)==1) {
MinecraftClient.getInstance().interactionManager.attackEntity(MinecraftClient.getInstance().player, entity);
}
return;
}
}
}
// for (Entity entity : MinecraftClient.getInstance().world.getEntities()) {
// if(entity.equals(MinecraftClient.getInstance().player)) return;
// debug(WorldUtil.getPlayerDistance(entity.getPos()) + " blocks away");
// if(WorldUtil.getPlayerDistance(entity.getPos()) > reach) return;
// debug("Which is close enough to the player");
// MinecraftClient.getInstance().inGameHud.setTitle(Text.literal(entity.getType().toString()));
// debug("Found entity " + entity.getType().toString());
// for (EntityType entityType : attackEntityList) {
// if(Objects.equals(entity.getType().toString(), entityType.toString())) {
// debug("And is of the correct entity type");
// MinecraftClient.getInstance().inGameHud.setSubtitle(Text.literal(entity.getType().toString()));
//// MinecraftClient.getInstance().player.lookAt(EntityAnchorArgumentType.EntityAnchor.EYES, entity.getPos());
// MinecraftClient.getInstance().interactionManager.attackEntity(MinecraftClient.getInstance().player, entity);
// }
// }
// }
};
}
private static void debug(String message) {
if(debug) ChipmunkMod.LOGGER.info("[KillAura] " + message);
}
}

View file

@ -0,0 +1,25 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class AirJumpModule extends Module {
boolean wasSpacePressed;
public AirJumpModule() {
super("Air Jump");
wasSpacePressed = false;
endTickRunnable = new Runnable() {
@Override
public void run() {
if(MinecraftClient.getInstance().options.jumpKey.wasPressed() && !wasSpacePressed) {
wasSpacePressed = true;
Vec3d v = MinecraftClient.getInstance().player.getVelocity();
MinecraftClient.getInstance().player.setVelocity(v.x, 0.35, v.z);
} else if (!MinecraftClient.getInstance().options.jumpKey.wasPressed()) {
wasSpacePressed = false;
}
}
};
}
}

View file

@ -0,0 +1,18 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
public class AntiVoidModule extends Module {
public static AntiVoidModule instance = new AntiVoidModule();
public AntiVoidModule() {
super("Anti void");
endTickRunnable = () -> {
if(MinecraftClient.getInstance().player.getY() < -64) {
MinecraftClient.getInstance().player.setPosition(MinecraftClient.getInstance().player.getX(), -64, MinecraftClient.getInstance().player.getZ());
MinecraftClient.getInstance().player.setOnGround(true);
}
};
isEnabled = true;
}
}

View file

@ -0,0 +1,19 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
public class FlightModule extends Module {
public FlightModule() {
super("Flight");
endTickRunnable = () -> MinecraftClient.getInstance().player.getAbilities().allowFlying = true;
deactivateRunnable = () -> {
if(MinecraftClient.getInstance().player != null)
MinecraftClient.getInstance().player.getAbilities().allowFlying = MinecraftClient.getInstance().player.getAbilities().creativeMode;
};
}
}

View file

@ -0,0 +1,22 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class FreezeModule extends Module {
public static Vec3d mantainPos;
public FreezeModule() {
super("Freeze");
activateRunnable = () -> {
mantainPos = MinecraftClient.getInstance().player.getPos();
};
endTickRunnable = new Runnable() {
@Override
public void run() {
MinecraftClient.getInstance().player.setVelocity(0, 0, 0);
MinecraftClient.getInstance().player.setPosition(mantainPos);
}
};
}
}

View file

@ -0,0 +1,44 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.DoubleSliderOption;
import net.minecraft.client.MinecraftClient;
import net.minecraft.block.Material;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
public class JesusModule extends Module {
public static boolean forceOnGround = false;
public JesusModule() {
super("Jesus");
withOption(new DoubleSliderOption("Float strength", 0.2, 0, 2, 3));
withOption(new DoubleSliderOption("Recognise top offset", 0.4, 0, 1, 4));
withOption(new DoubleSliderOption("Walk offset", 0.4, 0, 1, 4));
endTickRunnable = () -> {
// do stuffs
// Material material = MinecraftClient.getInstance().player.getBlockStateAtPos().getMaterial();
Vec3d pos = MinecraftClient.getInstance().player.getPos();
pos = new Vec3d(pos.x, pos.y-((double) optionList.get(2).optionValue), pos.z);
Material material = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(pos)).getMaterial();
Vec3d posRightAbove = new Vec3d(pos.x, ((int) (pos.y+((double) optionList.get(1).optionValue))), pos.z);
Vec3d posRightUnder = new Vec3d(pos.x, ((int) (pos.y-((double) optionList.get(1).optionValue))), pos.z);
// posRightAbove.floorAlongAxes(EnumSet.of(Direction.Axis.Y));
Material materialRightAbove = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(posRightAbove.x, posRightAbove.y, posRightAbove.z)).getMaterial();
Material materialRightUnder = MinecraftClient.getInstance().world.getBlockState(BlockPos.ofFloored(posRightUnder.x, posRightUnder.y, posRightUnder.z)).getMaterial();
Vec3d walkOn = new Vec3d(posRightAbove.x, posRightAbove.y+((double) optionList.get(2).optionValue), posRightAbove.z);
if(material == Material.WATER || material == Material.LAVA) {
Vec3d v = MinecraftClient.getInstance().player.getVelocity();
if(materialRightAbove == Material.AIR || materialRightUnder == Material.AIR) {
MinecraftClient.getInstance().player.setPosition(walkOn);
MinecraftClient.getInstance().player.setOnGround(true);
MinecraftClient.getInstance().player.setVelocity(v.x, 0, v.z);
return;
}
// if there isn't air *right above* the feet, send player up
MinecraftClient.getInstance().player.setVelocity(v.x, ((double) optionList.get(0).optionValue), v.z);
} else forceOnGround = false;
MinecraftClient.getInstance().player.isOnGround();
};
}
}

View file

@ -0,0 +1,13 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.DoubleSliderOption;
import net.minecraft.client.MinecraftClient;
public class SlipperyWorldModule extends Module {
public static SlipperyWorldModule instance = new SlipperyWorldModule();
public SlipperyWorldModule() {
super("Slippery world");
withOption(new DoubleSliderOption("Slipperiness", 0, -5, 5, 2));
}
}

View file

@ -0,0 +1,43 @@
package land.chipmunk.chipmunkmod.testclient.modules.movement;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.DoubleSliderOption;
import land.chipmunk.chipmunkmod.util.AttributeModifier;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.attribute.EntityAttributeModifier;
import net.minecraft.entity.attribute.EntityAttributes;
public class SpeedModule extends Module {
public static AttributeModifier attributeModifier;
public SpeedModule() {
super("Speed");
withOption(new DoubleSliderOption("multiplier", 0, 0, 10, 3));
endTickRunnable = new Runnable() {
@Override
public void run() {
if(MinecraftClient.getInstance().player == null) return;
if(attributeModifier == null) {
attributeModifier = new AttributeModifier(
EntityAttributes.GENERIC_MOVEMENT_SPEED,
2,
EntityAttributeModifier.Operation.MULTIPLY_TOTAL
);
} else {
float value = ((Double)optionList.get(0).optionValue).floatValue();
if(attributeModifier.getValue() != value) {
attributeModifier.setValue(value);
// Chat.sendGold("Speed multiplier: " + value);
}
}
if(!attributeModifier.isOnPlayer()) attributeModifier.add();
}
};
deactivateRunnable = new Runnable() {
@Override
public void run() {
attributeModifier.remove();
}
};
}
}

View file

@ -0,0 +1,53 @@
package land.chipmunk.chipmunkmod.testclient.modules.op;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.Vec3d;
public class AntiTeleportModule extends Module {
private static Vec3d previousPos;
private static Vec3d currentPos;
public static int timer = 0;
public AntiTeleportModule() {
super("AntiTP");
endTickRunnable = new Runnable() {
@Override
public void run() {
if(MinecraftClient.getInstance().player != null) {
currentPos = MinecraftClient.getInstance().player.getPos();
if(previousPos == null) {
previousPos = currentPos;
return;
}
if(getDistance(currentPos, previousPos) > 10 && timer <= 0) {
String command = "tp "+previousPos.x+" "+previousPos.y+" "+previousPos.z;
MinecraftClient.getInstance().player.networkHandler.sendChatCommand(command);
// Chat.send("[AntiTP] Ran `" + command + "`");
timer = 10;
}
previousPos = currentPos;
timer--;
}
}
};
isEnabled = true;
}
public double getDistance(Vec3d first, Vec3d second) {
double distanceX = 0, distanceY = 0, distanceZ = 0;
distanceX = first.x - second.x;
if(distanceX<0) distanceX = -distanceX;
distanceY = first.y - second.y;
if(distanceY<0) distanceY = -distanceY;
distanceZ = first.z - second.z;
if(distanceZ<0) distanceZ = -distanceZ;
return distanceX + distanceY + distanceZ;
}
}

View file

@ -0,0 +1,21 @@
package land.chipmunk.chipmunkmod.testclient.modules.op;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import java.util.ArrayList;
public class AutoDeopModule extends Module {
public static ArrayList<String> players = new ArrayList<>();
public static AutoDeopModule instance = new AutoDeopModule();
public AutoDeopModule() {
super("Auto Deop");
}
public static void execute(String opper, String opped) {
if(!instance.isEnabled) return;
if(players.contains(opped)) {
MinecraftClient.getInstance().getNetworkHandler().sendChatCommand("deop " + opped);
}
}
}

View file

@ -0,0 +1,20 @@
package land.chipmunk.chipmunkmod.testclient.modules.op;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.util.WorldUtil;
import net.minecraft.client.MinecraftClient;
import net.minecraft.server.MinecraftServer;
public class AutoOpModule extends Module {
public static AutoOpModule instance = new AutoOpModule();
public AutoOpModule() {
super("Auto OP");
// endTickRunnable = () -> {
// if(!WorldUtil.isPlayerOP()) MinecraftClient.getInstance().getNetworkHandler().sendCommand("op " + MinecraftClient.getInstance().getSession().getUsername());
// };
}
public void run(MinecraftServer server) {
if(!WorldUtil.isPlayerOP(server)) MinecraftClient.getInstance().getNetworkHandler().sendCommand("op " + MinecraftClient.getInstance().getSession().getUsername());
}
}

View file

@ -0,0 +1,20 @@
package land.chipmunk.chipmunkmod.testclient.modules.op;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import java.util.ArrayList;
public class AutoSudoKickModule extends Module {
public static AutoSudoKickModule instance = new AutoSudoKickModule();
public static ArrayList<String> players = new ArrayList<>();
public AutoSudoKickModule() {
super("Auto SudoKick");
isEnabled = true;
}
public static void execute(String username) {
if(instance.isEnabled && players.contains(username))
MinecraftClient.getInstance().getNetworkHandler().sendCommand("sudo " + username + " msg @s @e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e");
}
}

View file

@ -0,0 +1,14 @@
package land.chipmunk.chipmunkmod.testclient.modules.utility;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
public class AntiParticleKickModule extends Module {
public static AntiParticleKickModule instance = new AntiParticleKickModule();
public AntiParticleKickModule() {
super("Anti particle crash");
isEnabled = true;
}
}

View file

@ -0,0 +1,199 @@
package land.chipmunk.chipmunkmod.testclient.modules.utility;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.util.Chat;
import land.chipmunk.chipmunkmod.util.WorldUtil;
import net.minecraft.client.MinecraftClient;
import net.fabricmc.fabric.api.event.player.AttackBlockCallback;
import net.minecraft.block.Material;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import java.util.ArrayList;
public class AutoToolsModule extends Module {
public static AutoToolsModule instance = new AutoToolsModule();
public AutoToolsModule() {
super("Auto tools");
// it's all in the event listener below
}
public static void registerListener() {
Materials.initialize();
Tools.initialize();
AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
WorldUtil.setBlockBreaking(world.getBlockState(pos).getBlock());
if(instance.isEnabled) {
// Chat.send("Breaking: " + WorldUtil.getBlockBreaking().getTranslationKey());
switchToToolFor(WorldUtil.getBlockBreaking().getDefaultState().getMaterial());
}
return ActionResult.PASS;
});
}
public static void switchToToolFor(Material material) {
/*
* 0 = none
* 1 = pickaxe
* 2 = axe
* 3 = hoe
* 4 = sword
* 5 = shovel
* 6 = shears
*/
int tool = 0;
if(Materials.pickaxe.contains(material)) tool = 1;
if(Materials.axe. contains(material)) tool = 2;
if(Materials.hoe. contains(material)) tool = 3;
if(Materials.sword. contains(material)) tool = 4;
if(Materials.shovel. contains(material)) tool = 5;
if(Materials.shears. contains(material)) tool = 6;
// switch (tool) {
// case 0 -> Chat.send("This block has no tool.");
// case 1 -> Chat.send("This block needs a pickaxe.");
// case 2 -> Chat.send("This block needs an axe.");
// case 3 -> Chat.send("This block needs a hoe.");
// case 4 -> Chat.send("This block needs a sword.");
// case 5 -> Chat.send("This block needs a shovel.");
// case 6 -> Chat.send("This block needs shears.");
// }
switchToTool(tool);
}
public static void switchToTool(int tool) {
ArrayList<Item> tools = new ArrayList<>();
switch(tool) {
case 0 -> {return;}
case 1 -> tools = Tools.pickaxe;
case 2 -> tools = Tools.axe;
case 3 -> tools = Tools.hoe;
case 4 -> tools = Tools.sword;
case 5 -> tools = Tools.shovel;
case 6 -> tools = Tools.shears;
}
int i = 0;
for (ItemStack itemStack : MinecraftClient.getInstance().player.getInventory().main) {
if(tools.contains(itemStack.getItem())) {
// Chat.send(i + "You have that tool!");
if(i < 9) {
MinecraftClient.getInstance().player.getInventory().selectedSlot = i;
// Chat.send(Text.empty()
// .append("Switched to ")
// .append(itemStack.toHoverableText())
// .append(" in slot ")
// .append(""+i)
// .append(" in your hotbar.")
// );
}
}
// else Chat.send(MinecraftClient.getInstance().player.getInventory().main.indexOf(itemStack) + "You do not have that tool!");
i++;
}
}
public static class Tools {
public static final ArrayList<Item> pickaxe = new ArrayList<>();
public static final ArrayList<Item> axe = new ArrayList<>();
public static final ArrayList<Item> sword = new ArrayList<>();
public static final ArrayList<Item> hoe = new ArrayList<>();
public static final ArrayList<Item> shovel = new ArrayList<>();
public static final ArrayList<Item> shears = new ArrayList<>();
public static void initialize() {
/* PICKAXE */ {
pickaxe.add(Items.NETHERITE_PICKAXE);
pickaxe.add(Items. DIAMOND_PICKAXE);
pickaxe.add(Items. GOLDEN_PICKAXE);
pickaxe.add(Items. IRON_PICKAXE);
pickaxe.add(Items. STONE_PICKAXE);
pickaxe.add(Items. WOODEN_PICKAXE);
}
/* AXE */ {
axe.add(Items.NETHERITE_AXE);
axe.add(Items. DIAMOND_AXE);
axe.add(Items. GOLDEN_AXE);
axe.add(Items. IRON_AXE);
axe.add(Items. STONE_AXE);
axe.add(Items. WOODEN_AXE);
}
/* HOE */ {
hoe.add(Items.NETHERITE_HOE);
hoe.add(Items. DIAMOND_HOE);
hoe.add(Items. GOLDEN_HOE);
hoe.add(Items. IRON_HOE);
hoe.add(Items. STONE_HOE);
hoe.add(Items. WOODEN_HOE);
}
/* SWORD */ {
sword.add(Items.NETHERITE_SWORD);
sword.add(Items. DIAMOND_SWORD);
sword.add(Items. GOLDEN_SWORD);
sword.add(Items. IRON_SWORD);
sword.add(Items. STONE_SWORD);
sword.add(Items. WOODEN_SWORD);
}
/* SHUOWEL */ {
shovel.add(Items.NETHERITE_SHOVEL);
shovel.add(Items. DIAMOND_SHOVEL);
shovel.add(Items. GOLDEN_SHOVEL);
shovel.add(Items. IRON_SHOVEL);
shovel.add(Items. STONE_SHOVEL);
shovel.add(Items. WOODEN_SHOVEL);
}
/* SHAEARS */ {
shears.add(Items.SHEARS);
}
}
}
public static class Materials {
public static final ArrayList<Material> pickaxe = new ArrayList<>();
public static final ArrayList<Material> axe = new ArrayList<>();
public static final ArrayList<Material> sword = new ArrayList<>();
public static final ArrayList<Material> hoe = new ArrayList<>();
public static final ArrayList<Material> shovel = new ArrayList<>();
public static final ArrayList<Material> shears = new ArrayList<>();
public static void initialize() {
/* PICKAXE */ {
pickaxe.add(Material.ICE);
pickaxe.add(Material.STONE);
pickaxe.add(Material.DENSE_ICE);
pickaxe.add(Material.AMETHYST);
pickaxe.add(Material.METAL);
pickaxe.add(Material.PISTON);
pickaxe.add(Material.REDSTONE_LAMP);
pickaxe.add(Material.REPAIR_STATION);
pickaxe.add(Material.SCULK);
}
/* AXE */ {
axe.add(Material.WOOD);
axe.add(Material.NETHER_WOOD);
axe.add(Material.NETHER_SHOOTS);
}
/* HOE */ {
hoe.add(Material.MOSS_BLOCK);
hoe.add(Material.ORGANIC_PRODUCT);
hoe.add(Material.LEAVES);
}
/* SWORD */ {
sword.add(Material.BAMBOO);
sword.add(Material.BAMBOO_SAPLING);
sword.add(Material.COBWEB);
}
/* SHUOWEL */ {
shovel.add(Material.SOLID_ORGANIC);
shovel.add(Material.AGGREGATE);
}
/* SHAEARS */ {
shears.add(Material.CARPET);
shears.add(Material.WOOL);
}
}
}
}

View file

@ -0,0 +1,20 @@
package land.chipmunk.chipmunkmod.testclient.modules.utility;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.StringOption;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.client.MinecraftClient;
public class BlockGuardianParticlesModule extends Module {
public static BlockGuardianParticlesModule instance = new BlockGuardianParticlesModule();
public BlockGuardianParticlesModule() {
super("No guardian particles");
isEnabled = true;
withOption(new StringOption("Message", "Test option"));
activateRunnable = () -> {
Chat.send("" + optionList.get(0).optionValue);
};
}
}

View file

@ -0,0 +1,14 @@
package land.chipmunk.chipmunkmod.testclient.modules.utility;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
public class GuiMoveModule extends Module {
public GuiMoveModule() {
super("GUI Move");
endTickRunnable = () -> {
if (MinecraftClient.getInstance().currentScreen != null)
MinecraftClient.getInstance().currentScreen.passEvents = true;
};
}
}

View file

@ -0,0 +1,9 @@
package land.chipmunk.chipmunkmod.util;
import java.util.Arrays;
public class ArrayUtil {
public static String[] removeFirst(String[] original,int index) {
return Arrays.stream(original).toList().subList(index, original.length).toArray(new String[0]);
}
}

View file

@ -0,0 +1,58 @@
package land.chipmunk.chipmunkmod.util;
import net.minecraft.client.MinecraftClient;
import net.minecraft.entity.attribute.EntityAttribute;
import net.minecraft.entity.attribute.EntityAttributeInstance;
import net.minecraft.entity.attribute.EntityAttributeModifier;
public class AttributeModifier {
/*
EntityAttributeInstance movementSpeedAttribute = MC.player.getAttributeInstance(EntityAttributes.GENERIC_MOVEMENT_SPEED);
EntityAttributeModifier tempModifier = new EntityAttributeModifier(
"TestClient@Speed", // Modifier name
3, // Modifier value
EntityAttributeModifier.Operation.MULTIPLY_TOTAL); // Modifier operation
movementSpeedAttribute.addPersistentModifier(tempModifier);
*/
String name;
EntityAttribute attribute;
float value;
EntityAttributeModifier.Operation operation;
EntityAttributeModifier modifier;
EntityAttributeInstance instance;
public AttributeModifier(EntityAttribute attribute, float value, EntityAttributeModifier.Operation operation) {
this.attribute = attribute;
this.value = value;
this.operation = operation;
name = "TestClient@"+(new Throwable().getStackTrace()[1].getClassName())+"."+(new Throwable().getStackTrace()[1].getMethodName());
// Chat.send("Created new attribute modifier " + name);
instance = MinecraftClient.getInstance().player.getAttributeInstance(attribute);
modifier = new EntityAttributeModifier(name, value, operation);
}
public void add() {
instance.addPersistentModifier(modifier);
}
public void remove() {
instance.removeModifier(modifier);
}
public boolean isOnPlayer() {
return instance.hasModifier(modifier);
}
public void setValue(float value) {
this.value = value;
modifier = new EntityAttributeModifier(name, value, operation);
// remove and add multiplier to refresh value
if(isOnPlayer()){
remove();
add();
}
}
public float getValue() {
return value;
}
}

View file

@ -0,0 +1,30 @@
package land.chipmunk.chipmunkmod.util;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.time.Instant;
import java.util.Random;
public class Chat {
public static final MinecraftClient MC = MinecraftClient.getInstance();
public static void send(String message) {
MC.inGameHud.getChatHud().addMessage(Text.of(message));
}
public static void send(Text message) {
MC.inGameHud.getChatHud().addMessage(message);
}
public static void sendRed(String message) {
send(Text.literal(message).formatted(Formatting.RED));
}
public static void sendGreen(String message) {
send(Text.literal(message).formatted(Formatting.GREEN));
}
public static void sendGold(String message) {
send(Text.literal(message).formatted(Formatting.GOLD));
}
}

View file

@ -0,0 +1,45 @@
package land.chipmunk.chipmunkmod.util;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;
import org.lwjgl.glfw.GLFW;
public class Keybinds {
private static KeyBinding testKeyBinding;
private static KeyBinding delayPacketsKeyBinding;
private static KeyBinding openGuiKeyBinding;
public static void registerTest() {
// create the keybind
testKeyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.test_client.test", // the translation key for the keybind itself
InputUtil.Type.KEYSYM, // KEYSYM for keyboard, MOUSE for mouse
GLFW.GLFW_KEY_RIGHT_SHIFT, // the key
"category.test_client.test" // The translation key for the keybind category
));
// register it
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (testKeyBinding.wasPressed()) {
// here goes the code that gets executed when it's pressed
Chat.send("Test button has been pressed!");
}
});
}
public static void registerOpenGui() {
// create the keybind
openGuiKeyBinding = KeyBindingHelper.registerKeyBinding(new KeyBinding(
"key.test_client.open_gui", // the translation key for the keybind itself
InputUtil.Type.KEYSYM, // KEYSYM for keyboard, MOUSE for mouse
GLFW.GLFW_KEY_RIGHT_SHIFT, // the key
"category.test_client.test_client" // The translation key for the keybind category
));
// register it
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (openGuiKeyBinding.wasPressed()) {
Gui.open();
}
});
}
}

View file

@ -0,0 +1,27 @@
package land.chipmunk.chipmunkmod.util;
import net.minecraft.server.MinecraftServer;
/**
* This class is used when there isn't a specific class where you'd store a variable, but you still need it somewhere.
* It's mostly used by mixins which can't hold public variables themselves.
*/
public class SharedVariables {
/**
* The first time the player starts a message with '.', the game will warn them about commands having a '\' prefix.
* This is here to make sure starting messages with '.' isn't entirely blocked.
*/
public static boolean WarnedOfBackslashCommands = false;
/**
* The username that gets returned in Session.
*/
public static String username = "Dev_Blackilykat";
public static MinecraftServer serverConnectedTo = null;
public static int elderGuardianParticleTimer = 0;
/**
* Password to generate the hash for TestBot.
* Must be entered with \sethash every time game is launched.
*/
public static String hashPassword = "";
public static int deserializedThisTick = 0;
}

View file

@ -0,0 +1,28 @@
package land.chipmunk.chipmunkmod.util;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import land.chipmunk.chipmunkmod.testclient.gui.components.Category;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
import java.util.ArrayList;
public class TickRunnableHandler {
public static ArrayList<Runnable> runAtTickEnd = new ArrayList<>();
public static void registerTickEndRunnables() {
ClientTickEvents.END_CLIENT_TICK.register(client -> {
for (Category category : Gui.categoryList) {
for (Module module : category.moduleList) {
if(module.isEnabled) {
if(
(!module.needsInWorld || MinecraftClient.getInstance().player != null)
&& module.endTickRunnable != null
) module.endTickRunnable.run();
}
}
}
});
}
}

View file

@ -0,0 +1,388 @@
package land.chipmunk.chipmunkmod.util;
import javax.net.ssl.HttpsURLConnection;
import java.awt.*;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.net.URL;
import java.util.List;
import java.util.*;
/**
* Class used to execute Discord Webhooks with low effort
*/
public class Webhook {
private final String url;
private String content;
private String username;
private String avatarUrl;
private boolean tts;
private List<EmbedObject> embeds = new ArrayList<>();
/**
* Constructs a new DiscordWebhook instance
*
* @param url The webhook URL obtained in Discord
*/
public Webhook(String url) {
this.url = url;
}
public void setContent(String content) {
this.content = content;
}
public void setUsername(String username) {
this.username = username;
}
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
public void setTts(boolean tts) {
this.tts = tts;
}
public void addEmbed(EmbedObject embed) {
this.embeds.add(embed);
}
public void execute() throws IOException {
if (this.content == null && this.embeds.isEmpty()) {
throw new IllegalArgumentException("Set content or add at least one EmbedObject");
}
JSONObject json = new JSONObject();
json.put("content", this.content);
json.put("username", this.username);
json.put("avatar_url", this.avatarUrl);
json.put("tts", this.tts);
if (!this.embeds.isEmpty()) {
List<JSONObject> embedObjects = new ArrayList<>();
for (EmbedObject embed : this.embeds) {
JSONObject jsonEmbed = new JSONObject();
jsonEmbed.put("title", embed.getTitle());
jsonEmbed.put("description", embed.getDescription());
jsonEmbed.put("url", embed.getUrl());
if (embed.getColor() != null) {
Color color = embed.getColor();
int rgb = color.getRed();
rgb = (rgb << 8) + color.getGreen();
rgb = (rgb << 8) + color.getBlue();
jsonEmbed.put("color", rgb);
}
EmbedObject.Footer footer = embed.getFooter();
EmbedObject.Image image = embed.getImage();
EmbedObject.Thumbnail thumbnail = embed.getThumbnail();
EmbedObject.Author author = embed.getAuthor();
List<EmbedObject.Field> fields = embed.getFields();
if (footer != null) {
JSONObject jsonFooter = new JSONObject();
jsonFooter.put("text", footer.getText());
jsonFooter.put("icon_url", footer.getIconUrl());
jsonEmbed.put("footer", jsonFooter);
}
if (image != null) {
JSONObject jsonImage = new JSONObject();
jsonImage.put("url", image.getUrl());
jsonEmbed.put("image", jsonImage);
}
if (thumbnail != null) {
JSONObject jsonThumbnail = new JSONObject();
jsonThumbnail.put("url", thumbnail.getUrl());
jsonEmbed.put("thumbnail", jsonThumbnail);
}
if (author != null) {
JSONObject jsonAuthor = new JSONObject();
jsonAuthor.put("name", author.getName());
jsonAuthor.put("url", author.getUrl());
jsonAuthor.put("icon_url", author.getIconUrl());
jsonEmbed.put("author", jsonAuthor);
}
List<JSONObject> jsonFields = new ArrayList<>();
for (EmbedObject.Field field : fields) {
JSONObject jsonField = new JSONObject();
jsonField.put("name", field.getName());
jsonField.put("value", field.getValue());
jsonField.put("inline", field.isInline());
jsonFields.add(jsonField);
}
jsonEmbed.put("fields", jsonFields.toArray());
embedObjects.add(jsonEmbed);
}
json.put("embeds", embedObjects.toArray());
}
URL url = new URL(this.url);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("User-Agent", "Java-DiscordWebhook-BY-Gelox_");
connection.setDoOutput(true);
connection.setRequestMethod("POST");
OutputStream stream = connection.getOutputStream();
stream.write(json.toString().getBytes());
stream.flush();
stream.close();
connection.getInputStream().close(); //I'm not sure why but it doesn't work without getting the InputStream
connection.disconnect();
}
public static class EmbedObject {
private String title;
private String description;
private String url;
private Color color;
private Footer footer;
private Thumbnail thumbnail;
private Image image;
private Author author;
private List<Field> fields = new ArrayList<>();
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String getUrl() {
return url;
}
public Color getColor() {
return color;
}
public Footer getFooter() {
return footer;
}
public Thumbnail getThumbnail() {
return thumbnail;
}
public Image getImage() {
return image;
}
public Author getAuthor() {
return author;
}
public List<Field> getFields() {
return fields;
}
public EmbedObject setTitle(String title) {
this.title = title;
return this;
}
public EmbedObject setDescription(String description) {
this.description = description;
return this;
}
public EmbedObject setUrl(String url) {
this.url = url;
return this;
}
public EmbedObject setColor(Color color) {
this.color = color;
return this;
}
public EmbedObject setFooter(String text, String icon) {
this.footer = new Footer(text, icon);
return this;
}
public EmbedObject setThumbnail(String url) {
this.thumbnail = new Thumbnail(url);
return this;
}
public EmbedObject setImage(String url) {
this.image = new Image(url);
return this;
}
public EmbedObject setAuthor(String name, String url, String icon) {
this.author = new Author(name, url, icon);
return this;
}
public EmbedObject addField(String name, String value, boolean inline) {
this.fields.add(new Field(name, value, inline));
return this;
}
private class Footer {
private String text;
private String iconUrl;
private Footer(String text, String iconUrl) {
this.text = text;
this.iconUrl = iconUrl;
}
private String getText() {
return text;
}
private String getIconUrl() {
return iconUrl;
}
}
private class Thumbnail {
private String url;
private Thumbnail(String url) {
this.url = url;
}
private String getUrl() {
return url;
}
}
private class Image {
private String url;
private Image(String url) {
this.url = url;
}
private String getUrl() {
return url;
}
}
private class Author {
private String name;
private String url;
private String iconUrl;
private Author(String name, String url, String iconUrl) {
this.name = name;
this.url = url;
this.iconUrl = iconUrl;
}
private String getName() {
return name;
}
private String getUrl() {
return url;
}
private String getIconUrl() {
return iconUrl;
}
}
private class Field {
private String name;
private String value;
private boolean inline;
private Field(String name, String value, boolean inline) {
this.name = name;
this.value = value;
this.inline = inline;
}
private String getName() {
return name;
}
private String getValue() {
return value;
}
private boolean isInline() {
return inline;
}
}
}
private class JSONObject {
private final HashMap<String, Object> map = new HashMap<>();
void put(String key, Object value) {
if (value != null) {
map.put(key, value);
}
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
Set<Map.Entry<String, Object>> entrySet = map.entrySet();
builder.append("{");
int i = 0;
for (Map.Entry<String, Object> entry : entrySet) {
Object val = entry.getValue();
builder.append(quote(entry.getKey())).append(":");
if (val instanceof String) {
builder.append(quote(String.valueOf(val)));
} else if (val instanceof Integer) {
builder.append(Integer.valueOf(String.valueOf(val)));
} else if (val instanceof Boolean) {
builder.append(val);
} else if (val instanceof JSONObject) {
builder.append(val.toString());
} else if (val.getClass().isArray()) {
builder.append("[");
int len = Array.getLength(val);
for (int j = 0; j < len; j++) {
builder.append(Array.get(val, j).toString()).append(j != len - 1 ? "," : "");
}
builder.append("]");
}
builder.append(++i == entrySet.size() ? "}" : ",");
}
return builder.toString();
}
private String quote(String string) {
return "\"" + string + "\"";
}
}
}

View file

@ -0,0 +1,55 @@
package land.chipmunk.chipmunkmod.util;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
public class WorldUtil {
private static Block blockBreaking = null;
private static MinecraftClient MC = MinecraftClient.getInstance();
public static Block getBlockBreaking() {
return blockBreaking;
}
public static void setBlockBreaking(Block block) {
blockBreaking = block;
}
public static Block getBlockLooking() {
Vec3d pos = MinecraftClient.getInstance().crosshairTarget.getPos();
BlockPos blockPos = BlockPos.ofFloored(pos.x, pos.y, pos.z);
if(MC.world.getBlockState(blockPos) != null) return MC.world.getBlockState(blockPos).getBlock();
return null; // only if this is called while not in a world
}
public static double getPlayerDistance(Vec3d position) {
// crash-proof
if(MinecraftClient.getInstance().player == null) return 0;
Vec3d playerPos = MinecraftClient.getInstance().player.getPos();
double distanceX, distanceY, distanceZ;
distanceX = position.x - playerPos.x;
if(distanceX<0) distanceX = -distanceX;
distanceY = position.y - playerPos.y;
if(distanceY<0) distanceY = -distanceY;
distanceZ = position.z - playerPos.z;
if(distanceZ<0) distanceZ = -distanceZ;
return distanceX + distanceY + distanceZ;
}
public static boolean isPlayerOP() {
if(SharedVariables.serverConnectedTo==null) return false;
Chat.send(SharedVariables.serverConnectedTo.getOpPermissionLevel()+"");
return SharedVariables.serverConnectedTo.getOpPermissionLevel() > 0;
}
public static boolean isPlayerOP(MinecraftServer server) {
if(server==null) return false;
Chat.send(server.getOpPermissionLevel()+"");
return server.getOpPermissionLevel() > 0;
}
}

View file

@ -11,15 +11,24 @@
"ClientPlayerEntityMixin", "ClientPlayerEntityMixin",
"ClientPlayNetworkHandlerAccessor", "ClientPlayNetworkHandlerAccessor",
"ClientPlayNetworkHandlerMixin", "ClientPlayNetworkHandlerMixin",
"MinecraftClientAccessor",
"LightmapTextureManagerMixin",
"DecoderHandlerMixin", "DecoderHandlerMixin",
"StringHelperMixin", "ElderGuardianAppearanceParticleMixin",
"NbtIoMixin",
"KeyboardInputMixin", "KeyboardInputMixin",
"ElderGuardianAppearanceParticleMixin" "KeyboardMixin",
"LightmapTextureManagerMixin",
"MinecraftClientAccessor",
"MultiplayerScreenMixin",
"NbtIoMixin",
"SessionMixin",
"StringHelperMixin",
"TitleScreenMixin"
], ],
"injectors": { "injectors": {
"defaultRequire": 1 "defaultRequire": 1
} },
"mixins": [
"NbtIoInvoker",
"PlayerEntityMixin",
"TextMixin"
]
} }