Compare commits

...

27 commits

Author SHA1 Message Date
b5ba97afaf added .eval java with jshell and fixed TitleScreenMixin not being in mixins 2023-09-10 19:17:54 +02:00
11dbc4665a Merge remote-tracking branch 'upstream/1.20.1' into 1.20.1
# Conflicts:
#	src/main/java/land/chipmunk/chipmunkmod/Configuration.java
#	src/main/java/land/chipmunk/chipmunkmod/mixin/ChatScreenMixin.java
#	src/main/java/land/chipmunk/chipmunkmod/mixin/ClientConnectionMixin.java
#	src/main/java/land/chipmunk/chipmunkmod/mixin/TextSerializerMixin.java
#	src/main/java/land/chipmunk/chipmunkmod/modules/CommandCore.java
#	src/main/java/land/chipmunk/chipmunkmod/modules/SelfCare.java
#	src/main/resources/chipmunkmod.mixins.json
2023-09-10 13:15:01 +02:00
44dffc37a2 F 2023-09-10 13:09:28 +07:00
d194d6baa2 nice 2023-09-02 21:23:15 +07:00
5cf5163d75 IT FIWX<S<AD,sit894758743987589437598437583758937589rtghrfdjk
FUCK YOU
2023-09-02 19:57:01 +07:00
80d67f17f8 ADD SUPPOR TFOR SOUNDS OVER AND LOWER THE OCTAVE
IT TOOK AGES IM SO DUMB :(((((((((((((((((((( :((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((
HELP ME
2023-09-02 19:08:37 +07:00
b231e5e3d6 fix Lol 2023-08-31 18:57:48 +07:00
e1bbd2fa08 fix 2023-08-30 21:23:33 +07:00
4c1ff7a0aa fix and make it a LOT better 2023-08-30 16:51:49 +07:00
bb30748a00 aFIX 2023-08-29 20:32:25 +07:00
40c9f94293 CLAMP CORE Y (YES It is now DYNAMIC) 2023-08-29 16:55:16 +07:00
e4b1f66bb3 naH 2023-08-28 21:24:35 +07:00
a153b0befb RACISM BAD 2023-08-28 17:21:46 +07:00
9d7d16c643 FIX custom chat overriding other mods 2023-08-28 17:04:33 +07:00
198ec68b43 section signs chomens bot validation 2023-08-27 11:19:33 +07:00
6a26456bc1 some OHIo 2023-08-24 19:47:58 +07:00
d987be251f chomens auth i forgor to commit
i made this since yesterday and modified it a bit today few hours ago but forgor to commit 💀
2023-08-21 19:18:43 +07:00
4e07c1083a fix core 2023-08-20 15:49:51 +07:00
f75dbac63a cspy = false; 2023-08-20 10:21:39 +07:00
9ebd9154d9 try 2023-08-18 20:55:46 +07:00
6ea08ab4dc better patch
totallynotskidded from devious sex mod but not really cuz its just similar code
2023-08-18 12:05:47 +07:00
994cbba173 patch stack overflow crash (mabe) and fix 2023-08-17 19:08:13 +07:00
82b5259b44 icu slef care 2023-08-17 17:35:10 +07:00
64fd0d1ad4 runFillCommand
before i go to sleep
2023-08-16 21:20:39 +07:00
5ec6250570 racism bad 2023-08-16 18:04:24 +07:00
e61407fa22 remove fullbright 2023-08-13 19:25:03 +07:00
2feee9503d some lol 2023-08-12 09:08:37 +07:00
25 changed files with 616 additions and 146 deletions

View file

@ -14,7 +14,7 @@ public class Configuration {
public Bots bots = new Bots();
public CustomChat customChat = new CustomChat();
public AntiSpam antiSpam = new AntiSpam();
public boolean fullbright = true; // should this be false? Kat note: mabe
public boolean fullbright = true; // unused, but it is here for old configs
public String autoSkinUsername = "off";
public String testbotWebhook = null;
public String defaultUsername = null;
@ -32,11 +32,23 @@ public class Configuration {
public BotInfo hbot = new BotInfo("#", null);
public BotInfo sbot = new BotInfo(":", null);
public BotInfo chipmunk = new BotInfo("'", null);
public BotInfo chomens = new BotInfo("*", null);
public ChomeNSBotInfo chomens = new ChomeNSBotInfo("*", null, null);
public BotInfo kittycorp = new BotInfo("^", null);
public TestBotInfo testbot = new TestBotInfo("-", null);
}
public static class ChomeNSBotInfo {
public String prefix;
public String key;
public String authKey;
public ChomeNSBotInfo (String prefix, String key, String authKey) {
this.prefix = prefix;
this.key = key;
this.authKey = authKey;
}
}
public static class TestBotInfo {
public String prefix;
public String webhookUrl;

View file

@ -3,6 +3,9 @@ package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
@ -35,6 +38,14 @@ public class CoreCommand {
.then(literal("refill").executes(c -> refill(c)))
.then(literal("move").executes(c -> move(c)))
.then(
literal("runFillCommand")
.then(
argument("enabled", bool())
.executes(c -> runFillCommand(c))
)
)
);
}
@ -76,4 +87,16 @@ public class CoreCommand {
return Command.SINGLE_SUCCESS;
}
public static int runFillCommand(CommandContext<FabricClientCommandSource> context) {
final FabricClientCommandSource source = context.getSource();
final boolean bool = getBool(context, "enabled");
CommandCore.INSTANCE.runFillCommand = bool;
source.sendFeedback(Text.literal("Running fill commands are now " + (bool ? "enabled" : "disabled")));
return Command.SINGLE_SUCCESS;
}
}

View file

@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import land.chipmunk.chipmunkmod.util.Eval;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
@ -21,14 +22,22 @@ public class EvalCommand {
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(
literal("eval")
.then(
argument("code", greedyString())
.executes(EvalCommand::eval)
.then(literal("java")
.then(
argument("code", greedyString())
.executes(EvalCommand::evalJava)
)
)
.then(literal("lua")
.then(
argument("code", greedyString())
.executes(EvalCommand::evalLua)
)
)
);
}
public static int eval (CommandContext<FabricClientCommandSource> context) {
public static int evalLua(CommandContext<FabricClientCommandSource> context) {
final String code = getString(context, "code");
try {
@ -45,6 +54,13 @@ public class EvalCommand {
context.getSource().sendError(Text.literal(e.toString()));
}
return Command.SINGLE_SUCCESS;
}
public static int evalJava(CommandContext<FabricClientCommandSource> context) {
final String code = getString(context, "code");
Eval.shell(code);
return Command.SINGLE_SUCCESS;
}
}

View file

@ -3,12 +3,13 @@ package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import land.chipmunk.chipmunkmod.modules.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.greedyString;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
public class SayCommand {
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
@ -22,8 +23,7 @@ public class SayCommand {
}
public static int say (CommandContext<FabricClientCommandSource> context) {
final FabricClientCommandSource source = context.getSource();
source.getClient().getNetworkHandler().sendChatMessage(getString(context, "message"));
Chat.sendChatMessage(getString(context, "message"), true);
return Command.SINGLE_SUCCESS;
}

View file

@ -37,6 +37,13 @@ public class SelfCareCommand {
.executes(m -> setSelfCare(m, "cspy"))
)
)
.then(
literal("icu")
.then(
argument("boolean", bool())
.executes(m -> setSelfCare(m, "icu"))
)
)
);
}
@ -58,6 +65,10 @@ public class SelfCareCommand {
SelfCare.INSTANCE.cspyEnabled = bool;
source.sendFeedback(Text.literal("The CommandSpy self care is now " + (bool ? "enabled" : "disabled")));
}
case "icu" -> {
SelfCare.INSTANCE.icuEnabled = bool;
source.sendFeedback(Text.literal("The iControlU self care is now " + (bool ? "enabled" : "disabled")));
}
}
return Command.SINGLE_SUCCESS;

View file

@ -2,10 +2,8 @@ package land.chipmunk.chipmunkmod.mixin;
import com.google.gson.JsonObject;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.command.CommandManager;
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
import land.chipmunk.chipmunkmod.modules.CustomChat;
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
import land.chipmunk.chipmunkmod.util.Executor;
import land.chipmunk.chipmunkmod.util.Webhook;
@ -30,15 +28,48 @@ import java.io.OutputStream;
import java.net.URL;
import java.util.List;
@Mixin(net.minecraft.client.gui.screen.ChatScreen.class)
@Mixin(value = net.minecraft.client.gui.screen.ChatScreen.class)
public class ChatScreenMixin extends Screen {
@Shadow protected TextFieldWidget chatField;
@Shadow private String originalChatText;
@Shadow ChatInputSuggestor chatInputSuggestor;
@Shadow private int messageHistorySize = -1;
public ChatScreenMixin(String originalChatText) {
super(Text.translatable("chat_screen.title"));
this.originalChatText = originalChatText;
}
@Inject(at = @At("TAIL"), method = "init", cancellable = true)
public void init (CallbackInfo ci) {
final MinecraftClient client = MinecraftClient.getInstance();
this.messageHistorySize = client.inGameHud.getChatHud().getMessageHistory().size();
this.chatField = new TextFieldWidget(client.advanceValidatingTextRenderer, 4, this.height - 12, this.width - 4, 12, Text.translatable("chat.editBox")) {
protected MutableText getNarrationMessage() {
return super.getNarrationMessage().append(ChatScreenMixin.this.chatInputSuggestor.getNarration());
}
};
this.chatField.setMaxLength(Integer.MAX_VALUE);
this.chatField.setDrawsBackground(false);
this.chatField.setText(this.originalChatText);
this.chatField.setChangedListener(this::onChatFieldUpdate);
this.chatField.setFocusUnlocked(false);
this.addSelectableChild(this.chatField);
this.chatInputSuggestor = new ChatInputSuggestor(this.client, this, this.chatField, this.textRenderer, false, false, 1, 10, true, -805306368);
this.chatInputSuggestor.refresh();
this.setInitialFocus(this.chatField);
ci.cancel();
}
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
final MinecraftClient client = MinecraftClient.getInstance();
if (addToHistory) {
client.inGameHud.getChatHud().addToMessageHistory(chatText);
}
if(ChipmunkMod.CONFIG.testbotWebhook != null && chatText.startsWith("-")) {
Executor.service.submit(() -> {
try {
@ -61,61 +92,25 @@ public class ChatScreenMixin extends Screen {
BotValidationUtilities.chomens(chatText.substring(ChipmunkMod.CONFIG.bots.chomens.prefix.length()));
cir.setReturnValue(true);
if(addToHistory) {
assert client != null;
client.inGameHud.getChatHud().addToMessageHistory(chatText);
}
cir.cancel();
return;
} catch (Exception ignored) {}
}
}
final CommandManager commandManager = CommandManager.INSTANCE;
if (chatText.startsWith(commandManager.prefix)) {
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
if (addToHistory) MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(chatText);
cir.setReturnValue(true);
} else if (!chatText.startsWith("/")) {
CustomChat.INSTANCE.chat(chatText);
if (addToHistory) MinecraftClient.getInstance().inGameHud.getChatHud().addToMessageHistory(chatText);
cir.setReturnValue(true);
if (chatText.startsWith("/")) {
client.player.networkHandler.sendChatCommand(chatText.substring(1));
} else {
client.player.networkHandler.sendChatMessage(chatText);
}
cir.setReturnValue(true);
cir.cancel();
}
public ChatScreenMixin(String originalChatText) {
super(Text.translatable("chat_screen.title"));
this.originalChatText = originalChatText;
}
@Inject(at = @At("TAIL"), method = "init", cancellable = true)
public void init (CallbackInfo ci) {
final MinecraftClient client = MinecraftClient.getInstance();
this.messageHistorySize = client.inGameHud.getChatHud().getMessageHistory().size();
this.chatField = new TextFieldWidget(client.advanceValidatingTextRenderer, 4, this.height - 12, this.width - 4, 12, Text.translatable("chat.editBox")) {
protected MutableText getNarrationMessage() {
return super.getNarrationMessage().append(ChatScreenMixin.this.chatInputSuggestor.getNarration());
}
};
this.chatField.setMaxLength(Integer.MAX_VALUE);
this.chatField.setDrawsBackground(false);
this.chatField.setText(this.originalChatText);
this.chatField.setChangedListener(this::onChatFieldUpdate);
this.chatField.setFocusUnlocked(false);
this.addSelectableChild(this.chatField);
this.chatInputSuggestor = new ChatInputSuggestor(this.client, this, this.chatField, this.textRenderer, false, false, 1, 10, true, -805306368);
this.chatInputSuggestor.refresh();
this.setInitialFocus(this.chatField);
ci.cancel();
}
@Unique
private void onChatFieldUpdate(String chatText) {
String string = this.chatField.getText();
this.chatInputSuggestor.setWindowActive(!string.equals(this.originalChatText));

View file

@ -6,24 +6,30 @@ import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiParticleKickModule;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.listener.PacketListener;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.RequestCommandCompletionsC2SPacket;
import net.minecraft.network.packet.s2c.play.ParticleS2CPacket;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.registry.RegistryKey;
import net.minecraft.sound.SoundEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Optional;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@Mixin(net.minecraft.network.ClientConnection.class)
public class ClientConnectionMixin {
@Unique
private static final Pattern CUSTOM_PITCH_PATTERN = Pattern.compile(".*\\.pitch\\.(.*)");
@Inject(at = @At("HEAD"), method = "disconnect", cancellable = true)
public void disconnect (Text disconnectReason, CallbackInfo ci) {
if (disconnectReason == ClientPlayNetworkHandlerAccessor.chatValidationFailedText()) {
@ -33,11 +39,9 @@ public class ClientConnectionMixin {
@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
private void exceptionCaught (ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
if (ex instanceof DecoderException) {
Chat.sendGold("ChipmunkMod caught an exception in ClientConnection.");
ci.cancel();
ex.printStackTrace();
}
Chat.sendGold("ChipmunkMod caught an exception in ClientConnection.");
ci.cancel();
ex.printStackTrace();
}
@Inject(method = "handlePacket", at = @At("HEAD"), cancellable = true)
@ -46,6 +50,8 @@ public class ClientConnectionMixin {
listener.packetReceived(packet);
}
final MinecraftClient client = MinecraftClient.getInstance();
// please don't skid this.,.
// mabe mabe mabe
// lol i had my own im just gonna cop ypaste that :D
@ -55,17 +61,34 @@ public class ClientConnectionMixin {
ci.cancel();
}
} else if (packet instanceof PlaySoundS2CPacket t_packet) {
if (t_packet.getVolume() != 1) return;
final SoundEvent soundEvent = t_packet.getSound().value();
final Optional<RegistryKey<SoundEvent>> event = t_packet.getSound().getKey();
final Identifier sound = soundEvent.getId();
if (event.isEmpty()) return;
final Matcher matcher = CUSTOM_PITCH_PATTERN.matcher(sound.getPath());
final Identifier sound = event.get().getValue();
if (!matcher.find()) return;
if (!sound.getPath().equals("entity.enderman.scream")) return;
try {
final String stringPitch = matcher.group(1);
ci.cancel();
final float pitch = Float.parseFloat(stringPitch);
final ClientWorld world = client.world;
if (world == null) return;
// huge mess
final SoundEvent newSound = SoundEvent.of(new Identifier(sound.getNamespace(), sound.getPath().substring(0, sound.getPath().length() - (".pitch." + stringPitch).length())));
client.executeSync(() -> world.playSound(client.player, t_packet.getX(), t_packet.getY(), t_packet.getZ(), newSound, t_packet.getCategory(), t_packet.getVolume(), pitch, t_packet.getSeed()));
ci.cancel();
} catch (NumberFormatException e) {
e.printStackTrace();
}
if (t_packet.getVolume() == 1 && sound.getPath().equals("entity.enderman.scream")) ci.cancel();
}
}
@ -82,6 +105,4 @@ public class ClientConnectionMixin {
listener.packetSent(packet);
}
}
}

View file

@ -14,6 +14,13 @@ import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.util.telemetry.WorldSession;
import net.minecraft.command.CommandRegistryAccess;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.encryption.NetworkEncryptionUtils;
import net.minecraft.network.message.LastSeenMessagesCollector;
import net.minecraft.network.message.MessageBody;
import net.minecraft.network.message.MessageChain;
import net.minecraft.network.message.MessageSignatureData;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.c2s.play.ChatMessageC2SPacket;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.network.packet.s2c.play.GameMessageS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerRemoveS2CPacket;
@ -27,10 +34,17 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(net.minecraft.client.network.ClientPlayNetworkHandler.class)
import java.time.Instant;
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
public class ClientPlayNetworkHandlerMixin {
@Shadow private FeatureSet enabledFeatures;
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
@Shadow private LastSeenMessagesCollector lastSeenMessagesCollector;
@Shadow private MessageChain.Packer messagePacker;
@Shadow
public void sendPacket(Packet<?> packet) {}
@Inject(method = "<init>", at = @At("TAIL"))
private void init (MinecraftClient client, Screen screen, ClientConnection connection, ServerInfo serverInfo, GameProfile profile, WorldSession worldSession, CallbackInfo ci) {
@ -48,6 +62,7 @@ public class ClientPlayNetworkHandlerMixin {
SongPlayer.INSTANCE.coreReady();
RainbowName.INSTANCE.init();
ChomeNSBotCommandSuggestions.INSTANCE.init();
ChomeNSAuth.INSTANCE.init();
}
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
@ -78,7 +93,10 @@ public class ClientPlayNetworkHandlerMixin {
}
try {
if (((TextComponent) message.asComponent().children().get(0)).content().equals(ChomeNSBotCommandSuggestions.ID)) {
final TextComponent suggestionId = ((TextComponent) message.asComponent().children().get(0));
final TextComponent authId = (TextComponent) message.asComponent();
if (suggestionId.content().equals(ChomeNSBotCommandSuggestions.ID) || authId.content().equals(ChomeNSAuth.INSTANCE.id)) {
ci.cancel();
}
} catch (Exception ignored) {}
@ -86,4 +104,33 @@ public class ClientPlayNetworkHandlerMixin {
e.printStackTrace();
}
}
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
private void sendChatMessage (String chatText, CallbackInfo ci) {
final CommandManager commandManager = CommandManager.INSTANCE;
final String secret = String.valueOf(Chat.secret);
if (chatText.startsWith(commandManager.prefix)) {
commandManager.executeCommand(chatText.substring(commandManager.prefix.length()));
ci.cancel();
} else if (!chatText.startsWith("/") && !chatText.startsWith(secret)) {
CustomChat.INSTANCE.chat(chatText);
ci.cancel();
}
if (chatText.startsWith(secret)) {
final String content = chatText.substring(secret.length());
Instant instant = Instant.now();
long l = NetworkEncryptionUtils.SecureRandomUtil.nextLong();
LastSeenMessagesCollector.LastSeenMessages lastSeenMessages = this.lastSeenMessagesCollector.collect();
MessageSignatureData messageSignatureData = this.messagePacker.pack(new MessageBody(content, instant, l, lastSeenMessages.lastSeen()));
this.sendPacket(new ChatMessageC2SPacket(content, instant, l, messageSignatureData, lastSeenMessages.update()));
ci.cancel();
}
}
}

View file

@ -2,6 +2,7 @@ package land.chipmunk.chipmunkmod.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -16,7 +17,7 @@ import land.chipmunk.chipmunkmod.modules.CommandCore;
@Mixin(ClientPlayerEntity.class)
public class ClientPlayerEntityMixin {
private static MinecraftClient CLIENT = MinecraftClient.getInstance();
@Unique private static MinecraftClient CLIENT = MinecraftClient.getInstance();
@Inject(at = @At("HEAD"), method = "move")
public void move (MovementType type, Vec3d relPos, CallbackInfo ci) {

View file

@ -0,0 +1,24 @@
package land.chipmunk.chipmunkmod.mixin;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.context.CommandContextBuilder;
import com.mojang.brigadier.tree.CommandNode;
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(CommandDispatcher.class)
public class CommandDispatcherMixin<S> {
@Inject(method = "parseNodes", at = @At("HEAD"), cancellable = true, /* important --> */ remap = false)
private void parseNodes (CommandNode<S> node, StringReader originalReader, CommandContextBuilder<S> contextSoFar, CallbackInfoReturnable<ParseResults<S>> cir) {
// correct way to patch this?
// if (node.getRelevantNodes(originalReader).size() > 127) {
// cir.setReturnValue(new ParseResults<>(contextSoFar));
//
// cir.cancel();
// }
}
}

View file

@ -0,0 +1,17 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.client.sound.SoundInstance;
import net.minecraft.client.sound.SoundSystem;
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(SoundSystem.class)
public class SoundSystemMixin {
@Inject(method = "getAdjustedPitch", at = @At("HEAD"), cancellable = true)
private void getAdjustedPitch (SoundInstance sound, CallbackInfoReturnable<Float> cir) {
cir.setReturnValue(sound.getPitch());
cir.cancel();
}
}

View file

@ -1,11 +1,14 @@
package land.chipmunk.chipmunkmod.mixin;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
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.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@ -14,6 +17,48 @@ import java.lang.reflect.Type;
@Mixin(Text.Serializer.class)
public class TextSerializerMixin {
@Unique private static final int LIMIT = 128;
@Unique private int i;
@Unique
private boolean checkDepth (JsonElement element) {
if (element.isJsonPrimitive()) return false;
else if (i >= LIMIT) return true;
if (element.isJsonArray()) {
i++;
for (JsonElement item : element.getAsJsonArray()) if (checkDepth(item)) return true;
} else if (element.isJsonObject()) {
final JsonObject object = element.getAsJsonObject();
JsonArray array;
if (object.has("extra")) array = object.get("extra").getAsJsonArray();
else if (object.has("with")) array = object.get("with").getAsJsonArray();
else return false;
i++;
for (JsonElement member : array) if (checkDepth(member)) return true;
}
return false;
}
@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 deserialize (JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
i = 0; // better way to do this?
final boolean overLimit = checkDepth(jsonElement);
if (!overLimit) return;
cir.setReturnValue(Text.empty()); // just ignores it
cir.cancel();
}
@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();

View file

@ -10,6 +10,7 @@ import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -18,6 +19,7 @@ import java.io.IOException;
@Mixin(TitleScreen.class)
public class TitleScreenMixin {
@Shadow
private SplashTextRenderer splashText;
@Inject(method = "init", at = @At("HEAD"))
@ -28,6 +30,7 @@ public class TitleScreenMixin {
Gui.addComponents();
Gui.gui = new Gui();
ModuleMemory.load();
ChipmunkMod.LOGGER.info("Initialised gui!");
}
}
}

View file

@ -0,0 +1,18 @@
package land.chipmunk.chipmunkmod.modules;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
public class Chat {
public static double secret = Math.random();
public static void sendChatMessage (String message) { sendChatMessage(message, false); }
public static void sendChatMessage (String message, boolean usePlayerChat) {
if (message == null) return;
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
if (usePlayerChat) networkHandler.sendChatMessage(secret + message);
else networkHandler.sendChatMessage(message);
}
}

View file

@ -0,0 +1,75 @@
package land.chipmunk.chipmunkmod.modules;
import com.google.common.hash.Hashing;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.text.Text;
import java.nio.charset.StandardCharsets;
import java.util.List;
public class ChomeNSAuth extends Listener {
public static final ChomeNSAuth INSTANCE = new ChomeNSAuth();
public final String id = "chomens_bot_verify";
public ChomeNSAuth () {
ListenerManager.addListener(this);
}
public void init () {}
@Override
public void chatMessageReceived(Text message) {
final String authKey = ChipmunkMod.CONFIG.bots.chomens.authKey;
if (authKey == null) return;
final Component component = message.asComponent();
if (!(component instanceof TextComponent)) return;
final String id = ((TextComponent) component).content();
if (!id.equals(this.id)) return;
final List<Component> children = component.children();
if (children.size() != 2) return;
if (!(children.get(0) instanceof TextComponent)) return;
final String hash = ((TextComponent) children.get(0)).content();
final long time = System.currentTimeMillis() / 10_000;
final String actual = Hashing.sha256()
// very pro hash input
.hashString(authKey + time, StandardCharsets.UTF_8)
.toString()
.substring(0, 8);
if (!hash.equals(actual)) return;
if (!(children.get(1) instanceof TextComponent)) return;
final String selector = ((TextComponent) children.get(1)).content();
final String toSendHash = Hashing.sha256()
// very pro hash input
.hashString(authKey + authKey + time + time, StandardCharsets.UTF_8)
.toString()
.substring(0, 8);
final Component toSend = Component.text(id)
.append(Component.text(toSendHash));
final String toSendString = GsonComponentSerializer.gson().serialize(toSend);
CommandCore.INSTANCE.run("tellraw " + selector + " " + toSendString);
}
}

View file

@ -2,20 +2,20 @@ package land.chipmunk.chipmunkmod.modules;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.data.BlockArea;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.util.MathUtilities;
import net.minecraft.block.entity.CommandBlockBlockEntity;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.c2s.play.UpdateCommandBlockC2SPacket;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.dimension.DimensionType;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.CompletableFuture;
@ -24,16 +24,19 @@ public class CommandCore {
private final MinecraftClient client;
public boolean ready = false;
public BlockPos origin;
public BlockArea relativeArea;
public BlockPos currentBlockRelative;
public BlockArea noPos;
public BlockPos block;
public BlockArea withPos;
private Timer timer;
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance(), ChipmunkMod.CONFIG.core.relativeArea);
public boolean runFillCommand = true;
public CommandCore (MinecraftClient client, BlockArea relativeArea) {
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance());
public CommandCore (MinecraftClient client) {
this.client = client;
this.relativeArea = relativeArea;
reloadRelativeArea();
}
public void init () {
@ -57,20 +60,41 @@ public class CommandCore {
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
if (networkHandler == null) cleanup();
reloadRelativeArea();
}
public void reloadRelativeArea () {
relativeArea = ChipmunkMod.CONFIG.core.relativeArea;
noPos = ChipmunkMod.CONFIG.core.relativeArea;
}
public void move (Vec3d position) {
final ClientWorld world = client.world;
if (world == null || noPos == null) return;
final DimensionType dimension = world.getDimension();
origin = new BlockPos(
((int) position.getX() / 16) * 16,
0, // TODO: Use the actual bottom of the world instead of hardcoding to 0
(int) MathUtilities.clamp(noPos.start.getY(), dimension.minY(), dimension.height()),
((int) position.getZ() / 16) * 16
);
if (currentBlockRelative == null) currentBlockRelative = new BlockPos(relativeArea.start);
withPos = new BlockArea(
new BlockPos(
noPos.start.getX() + origin.getX(),
(int) MathUtilities.clamp(noPos.start.getY(), dimension.minY(), dimension.height()),
noPos.start.getZ() + origin.getZ()
),
new BlockPos(
noPos.end.getX() + origin.getX(),
(int) MathUtilities.clamp(noPos.end.getY(), dimension.minY(), dimension.height()),
noPos.end.getZ() + origin.getZ()
)
);
block = new BlockPos(withPos.start);
refill();
for (Listener listener : ListenerManager.listeners) listener.coreMoved();
@ -82,33 +106,35 @@ public class CommandCore {
}
public void refill () {
// final PositionManager position = client.position();
final BlockPos relStart = relativeArea.start;
final BlockPos relEnd = relativeArea.end;
if (!runFillCommand || withPos == null) return;
final String command = String.format(
KaboomCheck.INSTANCE.isKaboom ?
"fill %s %s %s %s %s %s repeating_command_block replace" :
"fill %s %s %s %s %s %s command_block",
relStart.getX() + origin.getX(),
relStart.getY() + origin.getY(),
relStart.getZ() + origin.getZ(),
withPos.start.getX(),
withPos.start.getY(),
withPos.start.getZ(),
relEnd.getX() + origin.getX(),
relEnd.getY() + origin.getY(),
relEnd.getZ() + origin.getZ()
withPos.end.getX(),
withPos.end.getY(),
withPos.end.getZ()
);
client.getNetworkHandler().sendChatCommand(command);
}
public void incrementCurrentBlock () {
final BlockPos start = relativeArea.start;
final BlockPos end = relativeArea.end;
if (withPos == null) return;
int x = currentBlockRelative.getX();
int y = currentBlockRelative.getY();
int z = currentBlockRelative.getZ();
final BlockPos start = withPos.start;
final BlockPos end = withPos.end;
if (start == null || end == null) return;
int x = block.getX();
int y = block.getY();
int z = block.getZ();
x++;
@ -128,35 +154,91 @@ public class CommandCore {
z = start.getZ();
}
currentBlockRelative = new BlockPos(x, y, z);
}
public BlockPos currentBlockAbsolute () {
return currentBlockRelative.add(origin);
block = new BlockPos(x, y, z);
}
public void run (String command) {
final ClientConnection connection = client.getNetworkHandler().getConnection();
final BlockPos currentBlock = currentBlockAbsolute();
// String prefix = new Throwable().getStackTrace()[1].getClassName();
// String block = currentBlock.toShortString();
// ChipmunkMod.LOGGER.info(prefix + " ran command in block " + block + " of core");
if (block == null) return;
// TODO: Support using repeating command blocks (on kaboom-like servers) (because less packets)
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, "", CommandBlockBlockEntity.Type.REDSTONE, false, false, false));
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, command, CommandBlockBlockEntity.Type.REDSTONE, false, false, true));
if (KaboomCheck.INSTANCE.isKaboom) {
connection.send(
new UpdateCommandBlockC2SPacket(
block,
command,
CommandBlockBlockEntity.Type.AUTO,
false,
false,
true
)
);
} else {
connection.send(
new UpdateCommandBlockC2SPacket(
block,
"",
CommandBlockBlockEntity.Type.REDSTONE,
false,
false,
false
)
);
connection.send(
new UpdateCommandBlockC2SPacket(
block,
command,
CommandBlockBlockEntity.Type.REDSTONE,
false,
false,
true
)
);
}
incrementCurrentBlock();
}
public CompletableFuture<NbtCompound> runTracked (String command) {
final ClientConnection connection = client.getNetworkHandler().getConnection();
final BlockPos currentBlock = currentBlockAbsolute();
// TODO: Support using repeating command blocks (on kaboom-like servers) (because less packets)
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, "", CommandBlockBlockEntity.Type.SEQUENCE, false, false, false));
connection.send(new UpdateCommandBlockC2SPacket(currentBlock, command, CommandBlockBlockEntity.Type.REDSTONE, true, false, true));
if (block == null) return new CompletableFuture<>();
if (KaboomCheck.INSTANCE.isKaboom) {
connection.send(
new UpdateCommandBlockC2SPacket(
block,
command,
CommandBlockBlockEntity.Type.AUTO,
true,
false,
true
)
);
} else {
connection.send(
new UpdateCommandBlockC2SPacket(
block,
"",
CommandBlockBlockEntity.Type.REDSTONE,
true,
false,
false
)
);
connection.send(
new UpdateCommandBlockC2SPacket(
block,
command,
CommandBlockBlockEntity.Type.REDSTONE,
true,
false,
true
)
);
}
incrementCurrentBlock();
@ -166,7 +248,7 @@ public class CommandCore {
final TimerTask queryTask = new TimerTask() {
public void run () {
client.getNetworkHandler().getDataQueryHandler().queryBlockNbt(currentBlock, future::complete);
client.getNetworkHandler().getDataQueryHandler().queryBlockNbt(block, future::complete);
timer.cancel(); // ? Is this necesary?
timer.purge();
@ -184,8 +266,8 @@ public class CommandCore {
timer.cancel();
timer.purge();
origin = null;
currentBlockRelative = null;
withPos = null;
block = null;
ready = false;
}
}

View file

@ -4,6 +4,7 @@ import com.google.gson.JsonElement;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.commands.SayCommand;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
@ -11,12 +12,18 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.Text;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class CustomChat {
private final MinecraftClient client;
public static final CustomChat INSTANCE = new CustomChat(MinecraftClient.getInstance());
public static final Pattern RACIST_PATTERN = Pattern.compile("nigga|nigger|i hate black", Pattern.CASE_INSENSITIVE);
public boolean enabled = true;
public String format;
@ -36,9 +43,20 @@ public class CustomChat {
public void chat (String message) {
final ClientPlayerEntity player = client.player;
try {
final Matcher racistMatcher = RACIST_PATTERN.matcher(message);
if (racistMatcher.matches()) {
player.sendMessage(Text.literal("racism bad"));
return;
}
} catch (Exception e) {
e.printStackTrace();
}
if (!enabled || !player.hasPermissionLevel(2) || !player.isCreative()) {
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
networkHandler.sendChatMessage(message);
Chat.sendChatMessage(message, true);
return;
}
@ -73,7 +91,7 @@ public class CustomChat {
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")) // TODO: make this not use regex
.replace(randomized, "MESSAGE"); // ohio ohio
CommandCore.INSTANCE.run("minecraft:tellraw @a " + sanitizedFormat);
CommandCore.INSTANCE.run((KaboomCheck.INSTANCE.isKaboom ? "minecraft:tellraw @a " : "tellraw @a ") + sanitizedFormat);
} catch (Exception e) {
if (client.player == null) return;
client.player.sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));

View file

@ -10,6 +10,7 @@ import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.s2c.play.GameJoinS2CPacket;
import net.minecraft.network.packet.s2c.play.GameStateChangeS2CPacket;
import net.minecraft.network.packet.s2c.play.PlayerPositionLookS2CPacket;
import net.minecraft.text.Text;
import java.util.Timer;
@ -25,17 +26,20 @@ public class SelfCare extends Listener {
public boolean opEnabled = true;
public boolean gamemodeEnabled = true;
public boolean cspyEnabled = true;
public boolean icuEnabled = true;
private int gameMode;
public String skin;
private Timer timer = null;
private Timer chatTimer = null;
private Timer timer;
private Timer chatTimer;
private boolean cspy = false;
public boolean hasSkin = false;
private int positionPacketsPerSecond = 0;
public static final SelfCare INSTANCE = new SelfCare(MinecraftClient.getInstance(), 70L, 500L); // make the intervals in config?
public SelfCare (MinecraftClient client, long interval, long chatInterval) {
@ -113,6 +117,7 @@ public class SelfCare extends Listener {
final ClientPlayerEntity player = client.player;
if (player != null && !player.hasPermissionLevel(2) && opEnabled) { if (serverHasCommand("op")) networkHandler.sendChatCommand("op @s[type=player]"); }
else if (gameMode != 1 && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
else if (positionPacketsPerSecond >= 10 && icuEnabled) CommandCore.INSTANCE.run("sudo * icu stop");
}
public void chatTick () {
@ -127,6 +132,7 @@ public class SelfCare extends Listener {
public void packetReceived(Packet<?> packet) {
if (packet instanceof GameJoinS2CPacket) packetReceived((GameJoinS2CPacket) packet);
else if (packet instanceof GameStateChangeS2CPacket) packetReceived((GameStateChangeS2CPacket) packet);
else if (packet instanceof PlayerPositionLookS2CPacket) packetReceived((PlayerPositionLookS2CPacket) packet);
}
public void packetReceived(GameJoinS2CPacket packet) {
@ -138,4 +144,21 @@ public class SelfCare extends Listener {
gameMode = (int) packet.getValue();
}
public void packetReceived(PlayerPositionLookS2CPacket packet) {
if (timer == null) return;
try {
positionPacketsPerSecond++;
timer.schedule(new TimerTask() {
@Override
public void run() {
positionPacketsPerSecond--;
}
}, 1000);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View file

@ -214,10 +214,10 @@ public class SongPlayer {
while (currentSong.reachedNextNote()) {
final Note note = currentSong.getNextNote();
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
try {
if (!useCore && client.player != null) {
final float floatingPitch = (float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12))));
final String[] thing = note.instrument.sound.split(":");
if (thing[1] == null) return; // idk if this can be null but ill just protect it for now i guess
@ -240,6 +240,8 @@ public class SongPlayer {
clientConnectionAccessor.packetListener()
);
} else {
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
CommandCore.INSTANCE.run("execute as " + SELECTOR + " at @s run playsound " + note.instrument.sound + " record @s ~ ~ ~ " + note.volume + " " + floatingPitch);
}
} catch (Exception e) {

View file

@ -167,10 +167,6 @@ public class NBSConverter {
key += customInstrument.pitch;
}
if (key < 33 || key > 57) {
continue;
}
byte layerVolume = 100;
if (nbsLayers.size() > note.layer) {
layerVolume = nbsLayers.get(note.layer).volume;

View file

@ -3,9 +3,12 @@ package land.chipmunk.chipmunkmod.util;
import com.mojang.brigadier.Command;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.Configuration;
import land.chipmunk.chipmunkmod.commands.SayCommand;
import land.chipmunk.chipmunkmod.modules.Chat;
import land.chipmunk.chipmunkmod.modules.CustomChat;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
@ -31,7 +34,7 @@ public class BotValidationUtilities {
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
String stringHash = bigInt.toString(Character.MAX_RADIX);
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
Chat.sendChatMessage(prefix + command + " " + stringHash, true);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
@ -56,7 +59,7 @@ public class BotValidationUtilities {
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
String stringHash = bigInt.toString(Character.MAX_RADIX);
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
Chat.sendChatMessage(prefix + command + " " + stringHash, true);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
@ -65,10 +68,12 @@ public class BotValidationUtilities {
}
public static int chomens (String command) throws RuntimeException {
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.chomens;
final Configuration.ChomeNSBotInfo info = ChipmunkMod.CONFIG.bots.chomens;
final MinecraftClient client = MinecraftClient.getInstance();
final ClientPlayerEntity player = client.player;
final String prefix = info.prefix;
final String key = info.key;
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
@ -82,9 +87,27 @@ public class BotValidationUtilities {
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
String stringHash = Hexadecimal.encode(hash).substring(0, 16);
final String toSend = prefix + arguments[0] + " " + stringHash + " " + String.join(" ", Arrays.copyOfRange(arguments, 1, arguments.length));
final boolean shouldSectionSign = CustomChat.INSTANCE.enabled && player.hasPermissionLevel(2) && player.isCreative();
CustomChat.INSTANCE.chat(toSend);
if (shouldSectionSign) {
stringHash = String.join("",
Arrays.stream(stringHash.split(""))
.map((letter) -> "§" + letter)
.toArray(String[]::new)
);
}
final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
final String toSend = prefix +
arguments[0] +
" " +
stringHash +
(shouldSectionSign ? "§r" : "") +
" " +
String.join(" ", restArguments);
Chat.sendChatMessage(toSend);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
@ -108,7 +131,7 @@ public class BotValidationUtilities {
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
String stringHash = bigInt.toString(Character.MAX_RADIX);
networkHandler.sendChatMessage(prefix + command + " " + stringHash);
Chat.sendChatMessage(prefix + command + " " + stringHash, true);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

View file

@ -0,0 +1,17 @@
package land.chipmunk.chipmunkmod.util;
import jdk.jshell.JShell;
public class Eval {
public static JShell shell = JShell.create();
public static void shell(String code) {
shell.eval(code);
}
static {
shell.onSnippetEvent(event -> {
Chat.sendGold(event.value());
});
}
}

View file

@ -1,6 +1,10 @@
package land.chipmunk.chipmunkmod.util;
public class MathUtilities {
public static double clamp (double value, double min, double max) {
return Math.max(Math.min(value, max), min);
}
public static float clamp (float value, float min, float max) {
return Math.max(Math.min(value, max), min);
}

View file

@ -28,8 +28,7 @@
"SharedConstantsMixin",
"StringHelperMixin",
"TextMixin",
"TitleScreenMixin",
"WorldRendererMixin"
"TitleScreenMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -14,7 +14,7 @@
"hbot": { "prefix": "#", "key": null },
"sbot": { "prefix": ":", "key": null },
"chipmunk": { "prefix": "'", "key": null },
"chomens": { "prefix": "*", "key": null },
"chomens": { "prefix": "*", "key": null, "authKey": null },
"kittycorp": { "prefix": "^", "key": null },
"testbot": { "prefix": "-", "webhookUrl": null }
},
@ -33,7 +33,5 @@
}
},
"fullbright": true,
"autoSkinUsername": "off"
}