Compare commits

...

17 commits

Author SHA1 Message Date
6a93cf8aae
fix: MORE FIXIES FOR NBOT 2024-11-10 15:11:53 +07:00
285513a332
fix: nbot hashing finaly fix 2024/11/10 14:30-40 or something 2024-11-10 14:47:09 +07:00
71a28fc0b7
still broken nbot hashing 2024-11-10 13:58:56 +07:00
fa7a41cecd NBot hashing (BROKEN !!!!!!!!) 2024-10-31 18:19:14 +07:00
2dd7443d4c Update SBot hashing 2024-10-21 13:38:57 +07:00
Chayapak Supasakul
951d4e35c1 Support FNFBoyfriendBot Validation 2024-10-21 10:22:53 +07:00
Chayapak Supasakul
fef81cc15f Update to 1.21.1
it was such a pain to do this. for some reason core runTracked doesn't seem to work yet
2024-10-12 18:54:04 +07:00
42ec7a2698 fix infinite chat not working with other mods (specifically symbol chat) 2023-10-07 11:07:56 +07:00
31f49729fd chomens discord 2023-10-06 11:55:10 +07:00
d72b215fe4 FIX AUTO REFILL NTO WORKING AFTER RECONNECt (MAJOR) 2023-10-04 14:28:00 +07:00
5f00a1925b yeah i fixed core auto refill sp[am !! 2023-10-04 09:02:08 +07:00
f3a259384c exploit 2023-10-01 19:45:39 +07:00
16472506c2 core fax? 2023-10-01 18:12:56 +07:00
63967e407d add alias to chome ns bot suggestions 2023-10-01 17:35:33 +07:00
08c3773660 FIX THE FUCKING SHIT BY A SINGLE FUCKING LINE OF THE FUCKING CODE 2023-10-01 17:03:41 +07:00
c04380b420 i am not sure 2023-10-01 11:37:48 +07:00
43939452fc 1.20.2 2023-09-29 10:04:51 +07:00
39 changed files with 319 additions and 328 deletions

View file

@ -1,10 +1,10 @@
plugins {
id 'fabric-loom' version '1.0-SNAPSHOT'
id 'fabric-loom' version '1.7-SNAPSHOT'
id 'maven-publish'
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
archivesBaseName = project.archives_base_name
version = project.mod_version
@ -20,6 +20,13 @@ repositories {
mavenCentral()
}
// https://github.com/MeteorDevelopment/meteor-client/blob/master/build.gradle#L46
configurations {
implementation.extendsFrom(library)
shadow.extendsFrom(library)
include.extendsFrom(library)
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@ -29,11 +36,13 @@ dependencies {
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation include("net.kyori:adventure-platform-fabric:5.8.0") // for Minecraft 1.19.4
library "net.kyori:adventure-platform-fabric:5.14.1" // for Minecraft 1.21-1.21.1
modImplementation include("net.kyori:adventure-text-serializer-legacy:4.13.1")
library "net.kyori:adventure-text-serializer-gson:4.17.0"
modImplementation include("org.luaj:luaj-jse:3.0.1")
library "net.kyori:adventure-text-serializer-legacy:4.17.0"
library "org.luaj:luaj-jse:3.0.1"
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
@ -51,7 +60,7 @@ processResources {
tasks.withType(JavaCompile).configureEach {
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
it.options.release = 17
it.options.release = 21
}
java {

View file

@ -4,9 +4,9 @@ org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.9
loader_version=0.14.21
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
loader_version=0.16.5
# Mod Properties
mod_version = 1.0.0
@ -14,6 +14,6 @@ org.gradle.parallel=true
archives_base_name = chipmunkmod
# Dependencies
fabric_version=0.84.0+1.20.1
fabric_version=0.105.0+1.21.1

View file

@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

1
gradlew vendored
View file

@ -122,6 +122,7 @@ if [ -n "$JAVA_HOME" ] ; then
else
JAVACMD=$JAVA_HOME/bin/java
fi
JAVACMD=/usr/bin/java
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME

View file

@ -26,6 +26,8 @@ public class Configuration {
public BotInfo sbot = new BotInfo(":", null);
public BotInfo chipmunk = new BotInfo("'", null);
public ChomeNSBotInfo chomens = new ChomeNSBotInfo("*", null, null, null);
public BotInfo fnfboyfriend = new BotInfo("~", null);
public BotInfo nbot = new BotInfo("?", null);
public BotInfo kittycorp = new BotInfo("^", null);
public TestBotInfo testbot = new TestBotInfo("-", null);
}

View file

@ -5,7 +5,6 @@ import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.command.CommandException;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.Text;
import net.minecraft.text.Texts;
@ -52,8 +51,6 @@ public class CommandManager {
commandSource.sendError(Texts.toText(e.getRawMessage()));
final Text context = getContext(e);
if (context != null) commandSource.sendError(context);
} catch (CommandException e) {
commandSource.sendError(e.getTextMessage());
} catch (Exception e) {
commandSource.sendError(Text.of(e.getMessage()));
}

View file

@ -1,5 +1,6 @@
package land.chipmunk.chipmunkmod.commands;
import com.google.common.base.Suppliers;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
@ -10,6 +11,8 @@ 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.util.TextUtilities;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
import net.minecraft.nbt.NbtCompound;
@ -64,8 +67,9 @@ public class CoreCommand {
future.thenApply(tag -> {
try {
final String output = tag.getString("LastOutput");
if (output != null) source.sendFeedback(Text.Serializer.fromJson(output));
} catch (Exception ignored) {
if (output != null) source.sendFeedback(TextUtilities.fromJson(output));
} catch (Exception e) {
e.printStackTrace();
}
return tag;

View file

@ -8,6 +8,7 @@ import land.chipmunk.chipmunkmod.command.CommandManager;
import land.chipmunk.chipmunkmod.modules.SongPlayer;
import land.chipmunk.chipmunkmod.song.Song;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.event.ClickEvent;
@ -219,7 +220,7 @@ public class MusicCommand {
mergedList.addAll(files);
final Component component = Component.translatable("Songs - %s", Component.join(JoinConfiguration.separator(Component.space()), mergedList)).color(NamedTextColor.GREEN);
MinecraftClient.getInstance().player.sendMessage(component);
((Audience) MinecraftClient.getInstance().player).sendMessage(component);
return 1;
}

View file

@ -9,16 +9,17 @@ import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ConnectScreen;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.util.Session;
import net.minecraft.client.session.Session;
import net.minecraft.text.Text;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import java.util.Optional;
import java.util.UUID;
import land.chipmunk.chipmunkmod.mixin.MinecraftClientAccessor;
public class UsernameCommand {
@ -45,7 +46,7 @@ public class UsernameCommand {
public static int updateUsername (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
final String username = getString(context, "username");
if (username.length() > 16) throw USERNAME_TOO_LONG.create();
final Session session = new Session(username, "", "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);
final Session session = new Session(username, new UUID(0L, 0L), "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);
return updateSession(context, session);
}
@ -60,7 +61,7 @@ public class UsernameCommand {
final ServerInfo info = client.getCurrentServerEntry();
client.world.disconnect();
client.disconnect();
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false);
ConnectScreen.connect(new TitleScreen(), client, ServerAddress.parse(info.address), info, false, null);
return Command.SINGLE_SUCCESS;
}

View file

@ -18,10 +18,12 @@ public class ValidateCommand {
.then(literal("sbot").then(argument("command", greedyString()).executes(c -> sbot(getString(c, "command")))))
// .then(literal("chipmunk").then(argument("command", greedyString()).executes(c -> chipmunk(getString(c, "command")))))
.then(literal("chomens").then(argument("command", greedyString()).executes(c -> {
c.getSource().sendFeedback(Text.literal("Warning: Manual ChomeNS Bot validation is deprecated"));
c.getSource().sendFeedback(Text.literal("Warning: Manual ChomeNS Bot validation is deprecated. Please use the completions from typing the bot's prefix."));
return chomens(getString(c, "command"));
})))
.then(literal("fnfboyfriend").then(argument("command", greedyString()).executes(c -> fnfboyfriend(getString(c, "command")))))
.then(literal("nbot").then(argument("command", greedyString()).executes(c -> nbot(getString(c, "command")))))
.then(literal("kittycorp").then(argument("command", greedyString()).executes(c -> kittycorp(getString(c, "command")))))
);
}

View file

@ -1,8 +1,12 @@
package land.chipmunk.chipmunkmod.data;
import java.util.ArrayList;
import java.util.List;
public class ChomeNSBotCommand {
public final String name;
public final TrustLevel trustLevel;
public final List<String> aliases = new ArrayList<>();
public ChomeNSBotCommand (
String name,

View file

@ -6,11 +6,11 @@ import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.command.CommandManager;
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.command.CommandSource;
import org.spongepowered.asm.mixin.Final;
@ -29,10 +29,6 @@ public class ChatInputSuggestorMixin {
@Shadow
private CompletableFuture<Suggestions> pendingSuggestions;
@Final
@Shadow
private boolean slashOptional;
@Shadow
public void show (boolean narrateFirstSuggestion) {}
@ -52,8 +48,6 @@ public class ChatInputSuggestorMixin {
@Inject(at = @At("TAIL"), method = "refresh()V")
public void refresh (CallbackInfo ci) {
if (slashOptional) return;
final CommandManager commandManager = CommandManager.INSTANCE;
final String text = this.textField.getText();
@ -84,20 +78,21 @@ public class ChatInputSuggestorMixin {
show(true);
});
return;
}
if (cursor < commandManager.prefix.length() || !text.startsWith(commandManager.prefix)) return;
} else if (cursor > commandManager.prefix.length() && text.startsWith(commandManager.prefix)) {
final StringReader reader = new StringReader(text);
reader.setCursor(commandManager.prefix.length()); // Skip the prefix
final CommandDispatcher<FabricClientCommandSource> dispatcher = commandManager.dispatcher;
final MinecraftClient client = MinecraftClient.getInstance();
final FabricClientCommandSource commandSource = (FabricClientCommandSource) client.getNetworkHandler().getCommandSource();
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
if (networkHandler == null) return;
final CommandDispatcher<FabricClientCommandSource> dispatcher = commandManager.dispatcher;
final FabricClientCommandSource commandSource = (FabricClientCommandSource) networkHandler.getCommandSource();
pendingSuggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(reader, commandSource), cursor);
show(true);
}
}
}

View file

@ -6,62 +6,32 @@ import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ChatInputSuggestor;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
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;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@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(method = "sendMessage", at = @At("HEAD"), cancellable = true)
private void sendMessage (String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
private void sendMessage (String chatText, boolean addToHistory, CallbackInfo cir) {
final MinecraftClient client = MinecraftClient.getInstance();
if (addToHistory) {
@ -103,11 +73,24 @@ public class ChatScreenMixin extends Screen {
.map((command) -> command.name.toLowerCase())
.toList();
if (moreOrTrustedCommands.contains(chatText.toLowerCase().split("\\s")[0])) {
try {
BotValidationUtilities.chomens(chatText.substring(ChipmunkMod.CONFIG.bots.chomens.prefix.length()));
final List<String> aliases = new ArrayList<>();
for (ChomeNSBotCommand command : commands) {
if (command.trustLevel == ChomeNSBotCommand.TrustLevel.PUBLIC) continue;
aliases.addAll(command.aliases);
}
final String chatCommand = chatText.toLowerCase().split("\\s")[0];
final int prefixLength = ChipmunkMod.CONFIG.bots.chomens.prefix.length();
if (
moreOrTrustedCommands.contains(chatCommand) ||
aliases.contains(chatCommand.substring(prefixLength))
) {
try {
BotValidationUtilities.chomens(chatText.substring(prefixLength));
cir.setReturnValue(true);
cir.cancel();
return;
@ -115,21 +98,14 @@ public class ChatScreenMixin extends Screen {
}
}
if (client == null) return;
if (chatText.startsWith("/")) {
client.player.networkHandler.sendChatCommand(chatText.substring(1));
} else {
client.player.networkHandler.sendChatMessage(chatText);
}
cir.setReturnValue(true);
cir.cancel();
}
@Unique
private void onChatFieldUpdate(String chatText) {
String string = this.chatField.getText();
this.chatInputSuggestor.setWindowActive(!string.equals(this.originalChatText));
this.chatInputSuggestor.refresh();
}
}

View file

@ -76,7 +76,7 @@ public class ClientConnectionMixin {
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())));
final SoundEvent newSound = SoundEvent.of(Identifier.of(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()));

View file

@ -16,9 +16,6 @@ public interface ClientPlayNetworkHandlerAccessor {
@Accessor("CHAT_VALIDATION_FAILED_TEXT")
static Text chatValidationFailedText () { throw new AssertionError(); }
@Accessor("connection")
ClientConnection connection();
@Accessor("playerListEntries")
Map<UUID, PlayerListEntry> playerListEntries();

View file

@ -1,33 +1,30 @@
package land.chipmunk.chipmunkmod.mixin;
import com.mojang.authlib.GameProfile;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.command.CommandManager;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.modules.*;
import net.kyori.adventure.platform.fabric.FabricAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.network.ClientDynamicRegistryType;
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;
import net.minecraft.registry.CombinedDynamicRegistries;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.resource.featuretoggle.FeatureSet;
import net.minecraft.text.PlainTextContent;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableTextContent;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -38,22 +35,16 @@ import java.time.Instant;
@Mixin(value = net.minecraft.client.network.ClientPlayNetworkHandler.class, priority = 1001)
public class ClientPlayNetworkHandlerMixin {
@Final
@Shadow private FeatureSet enabledFeatures;
@Shadow private CombinedDynamicRegistries<ClientDynamicRegistryType> combinedDynamicRegistries;
@Final
@Shadow private DynamicRegistryManager.Immutable 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) {
}
@Inject(method = "onGameJoin", at = @At("TAIL"))
private void onGameJoin (GameJoinS2CPacket packet, CallbackInfo ci) {
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries.getCombinedRegistryManager(), this.enabledFeatures);
final CommandRegistryAccess commandRegistryAccess = CommandRegistryAccess.of(this.combinedDynamicRegistries, this.enabledFeatures);
KaboomCheck.INSTANCE.onJoin();
CommandManager.INSTANCE = new CommandManager(ChipmunkMod.CONFIG.commands.prefix, commandRegistryAccess);
@ -69,7 +60,6 @@ public class ClientPlayNetworkHandlerMixin {
@Inject(method = "onPlayerRemove", at = @At("HEAD"), cancellable = true)
private void onPlayerRemove (PlayerRemoveS2CPacket packet, CallbackInfo ci) { ci.cancel(); }
@Inject(method = "onGameMessage", at = @At("HEAD"), cancellable = true)
private void onGameMessage (GameMessageS2CPacket packet, CallbackInfo ci) {
final Text message = packet.content();
@ -94,16 +84,14 @@ public class ClientPlayNetworkHandlerMixin {
}
try {
final TextComponent suggestionId = ((TextComponent) message.asComponent().children().get(0));
final TextComponent authId = (TextComponent) message.asComponent();
final String suggestionId = message.getSiblings().getFirst().getString();
final String authId = ((PlainTextContent) message.getContent()).string();
if (suggestionId.content().equals(ChomeNSBotCommandSuggestions.ID) || authId.content().equals(ChomeNSAuth.INSTANCE.id)) {
if (suggestionId.equals(ChomeNSBotCommandSuggestions.ID) || authId.equals(ChomeNSAuth.INSTANCE.id)) {
ci.cancel();
}
} catch (Exception ignored) {}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception ignored) {}
}
@Inject(method = "sendChatMessage", at = @At("HEAD"), cancellable = true)
@ -129,7 +117,7 @@ public class ClientPlayNetworkHandlerMixin {
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()));
MinecraftClient.getInstance().getNetworkHandler().sendPacket(new ChatMessageC2SPacket(content, instant, l, messageSignatureData, lastSeenMessages.update()));
ci.cancel();
}

View file

@ -30,6 +30,9 @@ public class ClientPlayerEntityMixin {
final BlockPos origin = CommandCore.INSTANCE.origin;
if (origin == null) { CommandCore.INSTANCE.move(position); return; }
final int distance = (int) Math.sqrt(new Vec2f(origin.getX() / 16, origin.getZ() / 16).distanceSquared(new Vec2f((int) position.getX() / 16, (int) position.getZ() / 16)));
if (distance > world.getSimulationDistance()) CommandCore.INSTANCE.move(position);
if (distance > world.getSimulationDistance()) {
CommandCore.INSTANCE.clientPlayerEntityFilled = true;
CommandCore.INSTANCE.move(position);
}
}
}

View file

@ -1,46 +0,0 @@
package land.chipmunk.chipmunkmod.mixin;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import net.minecraft.network.*;
import net.minecraft.network.packet.Packet;
import net.minecraft.util.profiling.jfr.FlightProfiler;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
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;
import java.util.List;
import static land.chipmunk.chipmunkmod.ChipmunkMod.LOGGER;
@Mixin(DecoderHandler.class)
public class DecoderHandlerMixin {
@Final @Mutable @Shadow private final NetworkSide side;
public DecoderHandlerMixin(NetworkSide side) {
this.side = side;
}
@Inject(method = "decode", at = @At("HEAD"), cancellable = true)
private void decode (ChannelHandlerContext ctx, ByteBuf buf, List<Object> objects, CallbackInfo ci) {
int i = buf.readableBytes();
if (i != 0) {
PacketByteBuf packetByteBuf = new PacketByteBuf(buf);
int j = packetByteBuf.readVarInt();
Packet<?> packet = ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get().getPacketHandler(this.side, j, packetByteBuf);
if (packet != null) {
int k = ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get().getId();
FlightProfiler.INSTANCE.onPacketReceived(k, j, ctx.channel().remoteAddress(), i);
objects.add(packet);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(ClientConnection.PACKET_RECEIVED_MARKER, " IN: [{}:{}] {}", ctx.channel().attr(ClientConnection.PROTOCOL_ATTRIBUTE_KEY).get(), j, packet.getClass().getName());
}
}
}
ci.cancel();
}
}

View file

@ -1,22 +0,0 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.block.entity.DecoratedPotBlockEntity;
import net.minecraft.item.Item;
import net.minecraft.item.Items;
import net.minecraft.nbt.NbtElement;
import net.minecraft.nbt.NbtList;
import net.minecraft.util.Identifier;
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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
// https://github.com/LunaWasFlaggedAgain/Mojang-ResourceLocation-Challenge/blob/main/src/main/java/com/github/lunawasflaggedagain/mojangresourcelocationchallenge/mixin/DecoratedPotBlockEntitySherdsMixin.java
@Mixin(DecoratedPotBlockEntity.Sherds.class)
public class DecoratedPotBlockEntitySherdsMixin {
@Inject(method = "getSherd(Lnet/minecraft/nbt/NbtList;I)Lnet/minecraft/item/Item;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Identifier;<init>(Ljava/lang/String;)V"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private static void getSherd(NbtList list, int index, CallbackInfoReturnable<Item> cir, NbtElement nbtElement) {
if (!Identifier.isValid(nbtElement.asString())) cir.setReturnValue(Items.BRICK);
}
}

View file

@ -3,7 +3,7 @@ package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.particle.DefaultParticleType;
import net.minecraft.particle.SimpleParticleType;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
@ -11,8 +11,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
public class ElderGuardianAppearanceParticleMixin {
@Inject(method = "createParticle(Lnet/minecraft/particle/DefaultParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true)
private void createParticle (DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
@Inject(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"))
private void createParticle (SimpleParticleType simpleParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
if (cir.isCancelled() || !cir.isCancellable()) return;
cir.cancel();

View file

@ -1,9 +1,9 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.client.session.Session;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.client.util.Session;
@Mixin(net.minecraft.client.MinecraftClient.class)
public interface MinecraftClientAccessor {

View file

@ -1,28 +0,0 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.nbt.*;
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.io.DataInput;
import java.io.IOException;
@Mixin(NbtIo.class)
public class NbtIoMixin {
@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) {
try {
byte b = input.readByte();
if (b == 0) {
cir.setReturnValue(NbtEnd.INSTANCE);
}
NbtString.skip(input);
cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker));
} catch (IOException e) {
e.printStackTrace();
}
}
}

View file

@ -1,16 +0,0 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.SharedConstants;
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(SharedConstants.class)
public class SharedConstantsMixin {
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
cir.cancel();
}
}

View file

@ -19,4 +19,10 @@ public class StringHelperMixin {
cir.setReturnValue(text);
cir.cancel();
}
@Inject(method = "isValidChar", at = @At("HEAD"), cancellable = true)
private static void isValidChar (char chr, CallbackInfoReturnable<Boolean> cir) {
cir.setReturnValue(chr >= ' ' && chr != '\u007f');
cir.cancel();
}
}

View file

@ -0,0 +1,20 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.client.gui.widget.TextFieldWidget;
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(TextFieldWidget.class)
public class TextFieldWidgetMixin {
@Shadow private int maxLength;
@Inject(method = "setMaxLength", at = @At("HEAD"), cancellable = true)
private void setMaxLength (int length, CallbackInfo ci) {
this.maxLength = Integer.MAX_VALUE;
ci.cancel();
}
}

View file

@ -5,9 +5,10 @@ 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.PlainTextContent;
import net.minecraft.text.Text;
import net.minecraft.text.TextContent;
import java.nio.charset.StandardCharsets;
import java.util.List;
@ -24,26 +25,26 @@ public class ChomeNSAuth extends Listener {
public void init () {}
@Override
public void chatMessageReceived(Text message) {
public void chatMessageReceived(Text text) {
final String authKey = ChipmunkMod.CONFIG.bots.chomens.authKey;
if (authKey == null) return;
final Component component = message.asComponent();
final TextContent message = text.getContent();
if (!(component instanceof TextComponent)) return;
if (!(message instanceof PlainTextContent)) return;
final String id = ((TextComponent) component).content();
final String id = ((PlainTextContent) message).string();
if (!id.equals(this.id)) return;
final List<Component> children = component.children();
final List<Text> children = text.getSiblings();
if (children.size() != 2) return;
if (!(children.get(0) instanceof TextComponent)) return;
if (!(children.getFirst().getContent() instanceof PlainTextContent)) return;
final String hash = ((TextComponent) children.get(0)).content();
final String hash = ((PlainTextContent) children.getFirst().getContent()).string();
final long time = System.currentTimeMillis() / 10_000;
@ -55,9 +56,9 @@ public class ChomeNSAuth extends Listener {
if (!hash.equals(actual)) return;
if (!(children.get(1) instanceof TextComponent)) return;
if (!(children.get(1).getContent() instanceof PlainTextContent)) return;
final String selector = ((TextComponent) children.get(1)).content();
final String selector = ((PlainTextContent) children.get(1).getContent()).string();
final String toSendHash = Hashing.sha256()
// very pro hash input

View file

@ -6,14 +6,13 @@ import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.util.UUIDUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.text.PlainTextContent;
import net.minecraft.text.Text;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class ChomeNSBotCommandSuggestions extends Listener {
@ -55,23 +54,35 @@ public class ChomeNSBotCommandSuggestions extends Listener {
@Override
public void chatMessageReceived(Text message) {
try {
final Component component = message.asComponent();
final List<Text> children = message.getSiblings();
final List<Component> children = component.children();
if (children.isEmpty()) return;
if (children.size() == 0) return;
final Text textComponent = children.getFirst();
final TextComponent textComponent = (TextComponent) children.get(0);
if (!textComponent.content().equals(ID)) return;
if (!textComponent.getString().equals(ID)) return;
commands = children.subList(1, children.size())
.stream()
.map(
(eachCum) -> new ChomeNSBotCommand(
ChipmunkMod.CONFIG.bots.chomens.prefix + ((TextComponent) eachCum).content(),
ChomeNSBotCommand.TrustLevel.valueOf(((TextComponent) eachCum.children().get(0)).content())
)
(eachComponent) -> {
final ChomeNSBotCommand command = new ChomeNSBotCommand(
ChipmunkMod.CONFIG.bots.chomens.prefix + ((PlainTextContent) eachComponent.getContent()).string(),
ChomeNSBotCommand.TrustLevel.valueOf(eachComponent.getSiblings().getFirst().getString())
);
if (!Boolean.parseBoolean(eachComponent.getSiblings().get(1).getString())) return command;
final List<Text> subList = eachComponent.getSiblings().subList(2, eachComponent.getSiblings().size());
for (Text aliasComponent : subList) {
final String alias = aliasComponent.getString();
command.aliases.add(alias);
}
return command;
}
)
.toList();
} catch (Exception ignored) {}

View file

@ -36,6 +36,8 @@ public class CommandCore {
public boolean runFillCommand = true;
public boolean clientPlayerEntityFilled = false;
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance());
public CommandCore (MinecraftClient client) {
@ -44,10 +46,7 @@ public class CommandCore {
}
public void init () {
if (timer != null) {
cleanup();
return;
}
if (timer != null) cleanup();
final TimerTask task = new TimerTask() {
public void run () {
@ -58,6 +57,13 @@ public class CommandCore {
final TimerTask refillTask = new TimerTask() {
@Override
public void run() {
if (clientPlayerEntityFilled) {
clientPlayerEntityFilled = false;
return;
}
check();
if (!shouldRefill) return;
refill();
@ -71,6 +77,8 @@ public class CommandCore {
timer.schedule(task, 50, 50);
timer.schedule(refillTask, 50, 1000);
move(client.player.getPos());
}
private void tick () {
@ -83,8 +91,6 @@ public class CommandCore {
}
reloadRelativeArea();
check();
}
public void reloadRelativeArea () {
@ -94,7 +100,7 @@ public class CommandCore {
public void check () {
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
if (networkHandler == null || withPos == null) return;
if (networkHandler == null || withPos == null || !ready) return;
try {
for (int x = withPos.start.getX(); x <= withPos.end.getX(); x++) {

View file

@ -5,6 +5,7 @@ import com.google.gson.JsonElement;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
@ -146,7 +147,7 @@ public class CustomChat {
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));
((Audience) client.player).sendMessage(Component.text(e.toString()).color(NamedTextColor.RED));
}
}
}

View file

@ -66,7 +66,7 @@ public class KaboomCheck extends Listener {
}
}
return packet;
return true;
});
}

View file

@ -107,7 +107,7 @@ public class Players extends Listener {
}
private MutablePlayerListEntry getEntry (PlayerListS2CPacket.Entry other) {
return getEntry(other.profile().getId());
return getEntry(other.profileId());
}
private void addPlayer (PlayerListS2CPacket.Entry newEntry) {
@ -137,7 +137,7 @@ public class Players extends Listener {
if (accessor == null) return;
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
entryAccessor.setGameMode(newEntry.gameMode());
} catch (Exception e) {
@ -155,7 +155,7 @@ public class Players extends Listener {
if (accessor == null) return;
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
entryAccessor.setLatency(newEntry.latency());
}
@ -170,7 +170,7 @@ public class Players extends Listener {
if (accessor == null) return;
accessor.playerListEntries().get(newEntry.profile().getId()).setDisplayName(newEntry.displayName());
accessor.playerListEntries().get(newEntry.profileId()).setDisplayName(newEntry.displayName());
}
private void removePlayer (UUID uuid) {
@ -197,7 +197,7 @@ public class Players extends Listener {
final Message tooltip = suggestion.getTooltip();
if (tooltip != null || !suggestion.getText().equals(username)) continue;
return packet;
return true;
}
list.remove(target);
@ -210,7 +210,7 @@ public class Players extends Listener {
addToPlayerList(new PlayerListEntry(entry.profile, false));
}
return packet;
return true;
});
} catch (Exception e) {
e.printStackTrace();

View file

@ -131,7 +131,7 @@ public class SelfCare extends Listener {
}
public void packetReceived(GameJoinS2CPacket packet) {
gameMode = packet.gameMode().getId();
gameMode = packet.commonPlayerSpawnInfo().gameMode().getId();
}
public void packetReceived(GameStateChangeS2CPacket packet) {

View file

@ -1,26 +1,21 @@
package land.chipmunk.chipmunkmod.modules;
import land.chipmunk.chipmunkmod.mixin.ClientConnectionAccessor;
import land.chipmunk.chipmunkmod.mixin.ClientConnectionInvoker;
import land.chipmunk.chipmunkmod.mixin.ClientPlayNetworkHandlerAccessor;
import land.chipmunk.chipmunkmod.song.Note;
import land.chipmunk.chipmunkmod.song.Song;
import land.chipmunk.chipmunkmod.song.SongLoaderException;
import land.chipmunk.chipmunkmod.song.SongLoaderThread;
import land.chipmunk.chipmunkmod.util.MathUtilities;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.network.packet.s2c.play.PlaySoundS2CPacket;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvent;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.random.Random;
import java.io.File;
import java.net.URL;
@ -61,34 +56,34 @@ public class SongPlayer {
public void loadSong (Path location) {
if (loaderThread != null) {
client.player.sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
((Audience) client.player).sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
return;
}
try {
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
client.player.sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
((Audience) client.player).sendMessage(Component.translatable("Loading %s", Component.text(location.getFileName().toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
_loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) {
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message).color(NamedTextColor.RED));
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED));
loaderThread = null;
}
}
public void loadSong (URL location) {
if (loaderThread != null) {
client.player.sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
((Audience) client.player).sendMessage(Component.translatable("Already loading a song, cannot load another", NamedTextColor.RED));
return;
}
try {
final SongLoaderThread _loaderThread = new SongLoaderThread(location);
client.player.sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
((Audience) client.player).sendMessage(Component.translatable("Loading %s", Component.text(location.toString(), NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
_loaderThread.start();
loaderThread = _loaderThread;
} catch (SongLoaderException e) {
client.player.sendMessage(Component.translatable("Failed to load song: %s", e.message).color(NamedTextColor.RED));
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", e.message.getString()).color(NamedTextColor.RED));
loaderThread = null;
}
}
@ -108,19 +103,19 @@ public class SongPlayer {
if (loaderThread != null && !loaderThread.isAlive()) {
if (loaderThread.exception != null) {
client.player.sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message).color(NamedTextColor.RED));
((Audience) client.player).sendMessage(Component.translatable("Failed to load song: %s", loaderThread.exception.message.getString()).color(NamedTextColor.RED));
} else {
songQueue.add(loaderThread.song);
client.player.sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
((Audience) client.player).sendMessage(Component.translatable("Added %s to the song queue", Component.empty().append(loaderThread.song.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
}
loaderThread = null;
}
if (currentSong == null) {
if (songQueue.size() == 0) return;
if (songQueue.isEmpty()) return;
currentSong = songQueue.poll();
client.player.sendMessage(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
((Audience) client.player).sendMessage(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
currentSong.play();
}
@ -128,7 +123,7 @@ public class SongPlayer {
else ticksUntilPausedActionbar = 20;
try {
if (!useCore && actionbar) client.player.sendActionBar(generateActionbar());
if (!useCore && actionbar && client.player != null) ((Audience) client.player).sendActionBar(generateActionbar());
else if (actionbar) CommandCore.INSTANCE.run("title " + SELECTOR + " actionbar " + GsonComponentSerializer.gson().serialize(generateActionbar()));
} catch (Exception e) {
e.printStackTrace();
@ -139,7 +134,7 @@ public class SongPlayer {
handlePlaying();
if (currentSong.finished()) {
client.player.sendMessage(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
((Audience) client.player).sendMessage(Component.translatable("Finished playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN));
currentSong = null;
}
}
@ -154,11 +149,11 @@ public class SongPlayer {
final ClientPlayerEntity player = client.player;
Component component = Component.empty()
.append(Component.translatable("%s", player.getName()).color(NamedTextColor.GREEN))
.append(Component.translatable("%s", player.getName().getString()).color(NamedTextColor.GREEN))
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
.append(Component.translatable("Now playing %s", Component.empty().append(currentSong.name).color(NamedTextColor.DARK_GREEN)).color(NamedTextColor.GREEN))
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
.append(Component.translatable("%s / %s", formatTime(currentSong.time).asComponent().color(NamedTextColor.GREEN), formatTime(currentSong.length).asComponent().color(NamedTextColor.GREEN)).color(NamedTextColor.GRAY))
.append(Component.translatable("%s / %s", formatTime(currentSong.time).color(NamedTextColor.GREEN), formatTime(currentSong.length).color(NamedTextColor.GREEN)).color(NamedTextColor.GRAY))
.append(Component.translatable(" | ", NamedTextColor.DARK_GRAY))
.append(Component.translatable("%s / %s", Component.text(currentSong.position, NamedTextColor.GREEN), Component.text(currentSong.size(), NamedTextColor.GREEN)).color(NamedTextColor.GRAY));
@ -183,16 +178,16 @@ public class SongPlayer {
return component;
}
public Text formatTime (long millis) {
public Component formatTime (long millis) {
final int seconds = (int) millis / 1000;
final String minutePart = String.valueOf(seconds / 60);
final String unpaddedSecondPart = String.valueOf(seconds % 60);
return Text.translatable(
return Component.translatable(
"%s:%s",
Text.literal(minutePart),
Text.literal(unpaddedSecondPart.length() < 2 ? "0" + unpaddedSecondPart : unpaddedSecondPart)
Component.text(minutePart),
Component.text(unpaddedSecondPart.length() < 2 ? "0" + unpaddedSecondPart : unpaddedSecondPart)
);
}
@ -220,23 +215,16 @@ public class SongPlayer {
if (thing[1] == null) return; // idk if this can be null but ill just protect it for now i guess
final ClientPlayNetworkHandlerAccessor networkHandlerAccessor = (ClientPlayNetworkHandlerAccessor) client.getNetworkHandler();
final ClientConnectionAccessor clientConnectionAccessor = (ClientConnectionAccessor) networkHandlerAccessor.connection();
ClientConnectionInvoker.handlePacket(
new PlaySoundS2CPacket(
RegistryEntry.of(SoundEvent.of(Identifier.of(thing[0], thing[1]))),
SoundCategory.RECORDS,
client.submit(() -> client.world.playSound(
client.player.getX(),
client.player.getY(),
client.player.getZ(),
SoundEvent.of(Identifier.of(thing[0], thing[1])),
SoundCategory.RECORDS,
note.volume,
floatingPitch,
Random.create().nextLong()
),
clientConnectionAccessor.packetListener()
);
true
));
} else {
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);

View file

@ -50,7 +50,7 @@ public class TabComplete extends Listener {
}
public void packetReceived (CommandSuggestionsS2CPacket packet) {
final CompletableFuture<CommandSuggestionsS2CPacket> future = transactions.get(packet.getCompletionId());
final CompletableFuture<CommandSuggestionsS2CPacket> future = transactions.get(packet.id());
if (future == null) return;
future.complete(packet);

View file

@ -11,6 +11,7 @@ import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
@ -52,9 +53,9 @@ public class BotValidationUtilities {
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
try {
MessageDigest md = MessageDigest.getInstance("SHA-256");
MessageDigest md = MessageDigest.getInstance("MD5");
String time = String.valueOf(System.currentTimeMillis() / 20000);
String input = prefix + command.replaceAll("&[0-9a-fklmnorx]", "") + ";" + client.player.getName() + ";" + time + ";" + key;
String input = prefix + command.replaceAll("&[0-9a-fklmnorx]", "") + ";" + client.player.getName().getString() + ";" + time + ";" + key;
byte[] hash = md.digest(input.getBytes(StandardCharsets.UTF_8));
BigInteger bigInt = new BigInteger(1, Arrays.copyOfRange(hash, 0, 4));
String stringHash = bigInt.toString(Character.MAX_RADIX);
@ -115,6 +116,79 @@ public class BotValidationUtilities {
return Command.SINGLE_SUCCESS;
}
public static int fnfboyfriend (String command) {
try {
final String prefix = ChipmunkMod.CONFIG.bots.fnfboyfriend.prefix;
String[] arguments = command.split(" ");
long currentTime = System.currentTimeMillis() / 1000;
final String key = ChipmunkMod.CONFIG.bots.fnfboyfriend.key;
if (key == null) throw new RuntimeException("The key of the bot is unspecified (null), did you incorrectly add it to your config?");
String input = currentTime + key;
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(input.getBytes());
StringBuilder hexString = new StringBuilder();
for (byte b : hash) {
String hex = Integer.toHexString(0xff & b);
if (hex.length() == 1) hexString.append('0');
hexString.append(hex);
}
final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
final String result = hexString.substring(0, 16);
Chat.sendChatMessage(prefix + arguments[0] + " " + result + " " + String.join(" ", restArguments));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return Command.SINGLE_SUCCESS;
}
public static int nbot (String command) throws RuntimeException {
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.nbot;
final MinecraftClient client = MinecraftClient.getInstance();
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?");
try {
String[] arguments = command.split(" ");
MessageDigest md = MessageDigest.getInstance("SHA-256");
String time = String.valueOf(System.currentTimeMillis() / 5_000);
String input = arguments[0].replaceAll("&[0-9a-fklmnor]", "") + ";" + client.player.getUuidAsString() + ";" + time + ";" + key;
md.update(input.getBytes(StandardCharsets.UTF_8));
byte[] hash = md.digest();
ByteBuffer buffer = ByteBuffer.wrap(hash, 0, 4);
long bigInt = (buffer.getInt() & 0xFFFFFFFFL);;
String stringHash = Long.toString(bigInt, 36);
final String[] restArguments = Arrays.copyOfRange(arguments, 1, arguments.length);
final String toSend = prefix +
arguments[0] +
" " +
stringHash +
" " +
String.join(" ", restArguments);
Chat.sendChatMessage(toSend, true);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return Command.SINGLE_SUCCESS;
}
public static int kittycorp (String command) throws RuntimeException {
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.kittycorp;
final ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();

View file

@ -0,0 +1,16 @@
package land.chipmunk.chipmunkmod.util;
import com.google.common.base.Suppliers;
import net.minecraft.registry.DynamicRegistryManager;
import net.minecraft.registry.Registries;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
public class TextUtilities {
public static MutableText fromJson (String json) {
return Text.Serialization.fromJson(
json,
Suppliers.ofInstance(DynamicRegistryManager.of(Registries.REGISTRIES)).get()
);
}
}

View file

@ -2,7 +2,7 @@
"required": true,
"minVersion": "0.8",
"package": "land.chipmunk.chipmunkmod.mixin",
"compatibilityLevel": "JAVA_17",
"compatibilityLevel": "JAVA_21",
"client": [
"ChatInputSuggestorMixin",
"ChatScreenMixin",
@ -11,20 +11,17 @@
"ClientPlayNetworkHandlerAccessor",
"ClientPlayNetworkHandlerMixin",
"MinecraftClientAccessor",
"DecoderHandlerMixin",
"StringHelperMixin",
"NbtIoMixin",
"ElderGuardianAppearanceParticleMixin",
"IdentifierMixin",
"DecoratedPotBlockEntitySherdsMixin",
"TextMixin",
"ClientConnectionInvoker",
"ClientConnectionAccessor",
"PlayerListEntryAccessor",
"SharedConstantsMixin",
"TextSerializerMixin",
"CommandDispatcherMixin",
"SoundSystemMixin"
"SoundSystemMixin",
"TextFieldWidgetMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -15,6 +15,8 @@
"sbot": { "prefix": ":", "key": null },
"chipmunk": { "prefix": "'", "key": null },
"chomens": { "prefix": "*", "key": null, "authKey": null, "formatKey": null },
"fnfboyfriend": { "prefix": "~", "key": null },
"nbot": { "prefix": "?", "key": null },
"kittycorp": { "prefix": "^", "key": null },
"testbot": { "prefix": "-", "webhookUrl": null }
},

View file

@ -12,7 +12,8 @@
"contact": {
"homepage": "https://chayapak.chipmunk.land/",
"sources": "https://code.chipmunk.land/ChomeNS/chipmunkmod",
"issues": "https://code.chipmunk.land/ChomeNS/chipmunkmod/issues"
"issues": "https://code.chipmunk.land/ChomeNS/chipmunkmod/issues",
"discord": "https://discord.gg/xdgCkUyaA4"
},
"license": "CC0-1.0",
@ -29,10 +30,10 @@
],
"depends": {
"fabricloader": ">=0.14.11",
"fabricloader": ">=0.16.5",
"fabric-api": "*",
"minecraft": ">1.20",
"java": ">=17"
"minecraft": ">=1.21",
"java": ">=21"
},
"suggests": {
"another-mod": "*"