forked from ChomeNS/chipmunkmod
Compare commits
26 commits
245c625b4c
...
9d9283c70b
Author | SHA1 | Date | |
---|---|---|---|
9d9283c70b | |||
fa7a41cecd | |||
2dd7443d4c | |||
|
951d4e35c1 | ||
|
fef81cc15f | ||
42ec7a2698 | |||
31f49729fd | |||
d72b215fe4 | |||
5f00a1925b | |||
f3a259384c | |||
16472506c2 | |||
63967e407d | |||
08c3773660 | |||
c04380b420 | |||
43939452fc | |||
ee5b2a0892 | |||
e15953918d | |||
d931a8abd1 | |||
bc738a6f25 | |||
1604b0a996 | |||
e0c7804aa7 | |||
c2170ddfcd | |||
706fff00d4 | |||
78689abe93 | |||
8fce7f0ee6 | |||
fedd15b946 |
51 changed files with 566 additions and 454 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -38,3 +38,4 @@ hs_err_*.log
|
|||
replay_*.log
|
||||
*.hprof
|
||||
*.jfr
|
||||
/buildAndSend.sh
|
||||
|
|
65
build.gradle
65
build.gradle
|
@ -1,15 +1,32 @@
|
|||
plugins {
|
||||
id 'fabric-loom' version '1.2-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
|
||||
group = project.maven_group
|
||||
|
||||
repositories {
|
||||
// Add repositories to retrieve artifacts from in here.
|
||||
// You should only use this when depending on other mods because
|
||||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
// https://github.com/MeteorDevelopment/meteor-client/blob/master/build.gradle#L46
|
||||
configurations {
|
||||
implementation.extendsFrom(library)
|
||||
shadow.extendsFrom(library)
|
||||
include.extendsFrom(library)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.apache.commons:commons-text:1.10.0' // Use the version that best suits your project
|
||||
|
||||
|
@ -21,22 +38,24 @@ 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") // still works on 1.20.1
|
||||
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.14.0")
|
||||
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.
|
||||
|
||||
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
|
||||
|
||||
compileOnly 'org.projectlombok:lombok:1.18.28'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.28'
|
||||
compileOnly 'org.projectlombok:lombok:1.18.34'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.34'
|
||||
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.28'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.28'
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.34'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
@ -49,7 +68,14 @@ processResources {
|
|||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
|
||||
it.options.release = 17
|
||||
it.options.release = 21
|
||||
}
|
||||
|
||||
java {
|
||||
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
|
||||
// if it is present.
|
||||
// If you remove this line, sources will not be generated.
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
jar {
|
||||
|
@ -57,3 +83,20 @@ jar {
|
|||
rename { "${it}_${project.archivesBaseName}"}
|
||||
}
|
||||
}
|
||||
|
||||
// configure the maven publication
|
||||
publishing {
|
||||
publications {
|
||||
mavenJava(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
|
||||
repositories {
|
||||
// Add repositories to publish to here.
|
||||
// Notice: This block does NOT have the same function as the block in the top level.
|
||||
// The repositories here will be used for publishing your artifact, not for
|
||||
// retrieving dependencies.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.1
|
||||
|
@ -14,5 +14,5 @@ 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
|
||||
|
||||
|
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -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
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
1
gradlew
vendored
1
gradlew
vendored
|
@ -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
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ public class Configuration {
|
|||
public BotInfo hbot = new BotInfo("#", null);
|
||||
public BotInfo sbot = new BotInfo(":", null);
|
||||
public BotInfo chipmunk = new BotInfo("'", null);
|
||||
public ChomeNSBotInfo chomens = new ChomeNSBotInfo("*", null, 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);
|
||||
}
|
||||
|
@ -41,11 +43,13 @@ public class Configuration {
|
|||
public String prefix;
|
||||
public String key;
|
||||
public String authKey;
|
||||
public String formatKey;
|
||||
|
||||
public ChomeNSBotInfo (String prefix, String key, String authKey) {
|
||||
public ChomeNSBotInfo (String prefix, String key, String authKey, String formatKey) {
|
||||
this.prefix = prefix;
|
||||
this.key = key;
|
||||
this.authKey = authKey;
|
||||
this.formatKey = formatKey;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
@ -54,8 +53,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()));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -12,15 +12,15 @@ import land.chipmunk.chipmunkmod.ChipmunkMod;
|
|||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
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 land.chipmunk.chipmunkmod.mixin.MinecraftClientAccessor;
|
||||
|
||||
public class UsernameCommand {
|
||||
|
@ -33,7 +33,7 @@ public class UsernameCommand {
|
|||
literal("set")
|
||||
.then(
|
||||
argument("username", greedyString())
|
||||
.executes(UsernameCommand::updateUsername)
|
||||
.executes(c -> updateUsername(c))
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -52,10 +52,11 @@ public class UsernameCommand {
|
|||
|
||||
ChipmunkMod.CONFIG.defaultUsername = username;
|
||||
|
||||
// TODO: Put this in a separate class
|
||||
final ServerInfo info = client.getCurrentServerEntry();
|
||||
client.world.disconnect();
|
||||
client.disconnect();
|
||||
ConnectScreen.connect(new MultiplayerScreen(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;
|
||||
}
|
||||
|
|
|
@ -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")))))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -7,6 +7,7 @@ import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiChatSpam
|
|||
import land.chipmunk.chipmunkmod.util.Debug;
|
||||
import land.chipmunk.chipmunkmod.util.Executor;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.hud.ChatHudLine;
|
||||
import net.minecraft.client.gui.hud.MessageIndicator;
|
||||
import net.minecraft.network.message.MessageSignatureData;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -18,29 +19,37 @@ 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 org.spongepowered.asm.mixin.injection.callback.LocalCapture;
|
||||
|
||||
@Mixin(net.minecraft.client.gui.hud.ChatHud.class)
|
||||
public abstract class ChatHudMixin {
|
||||
|
||||
@Shadow protected abstract void addMessage(Text message, @Nullable MessageSignatureData signature, int ticks, @Nullable MessageIndicator indicator, boolean refresh);
|
||||
@Shadow
|
||||
public abstract void addMessage(Text message, @Nullable MessageSignatureData signature, @Nullable MessageIndicator indicator);
|
||||
|
||||
@Shadow @Final private MinecraftClient client;
|
||||
|
||||
@Shadow protected abstract void logChatMessage(Text message, @Nullable MessageIndicator indicator);
|
||||
@Shadow protected abstract void logChatMessage(ChatHudLine message);
|
||||
|
||||
|
||||
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At("HEAD"), cancellable = true)
|
||||
public void chipmunkmod$preventDoubleMessageLogging(Text message, MessageSignatureData signature, MessageIndicator indicator, CallbackInfo ci) {
|
||||
addMessage(message, signature, client.inGameHud.getTicks(), indicator, false);
|
||||
@Shadow protected abstract void addVisibleMessage(ChatHudLine message);
|
||||
@Shadow protected abstract void addMessage(ChatHudLine message);
|
||||
|
||||
@Inject(method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;logChatMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void chipmunkmod$preventDoubleMessageLogging(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci, ChatHudLine chatHudLine) {
|
||||
// addMessage(message, signature, client.inGameHud.getTicks(), indicator, false);
|
||||
addVisibleMessage(chatHudLine);
|
||||
addMessage(chatHudLine);
|
||||
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;ILnet/minecraft/client/gui/hud/MessageIndicator;Z)V", cancellable = true)
|
||||
public void chipmunkmod$generalAddMessageMixin(Text message, MessageSignatureData signature, int ticks, MessageIndicator indicator, boolean refresh, CallbackInfo ci) {
|
||||
@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/hud/ChatHud;logChatMessage(Lnet/minecraft/client/gui/hud/ChatHudLine;)V"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
|
||||
public void chipmunkmod$generalAddMessageMixin(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci, ChatHudLine chatHudLine) {
|
||||
// ChipmunkMod.LOGGER.info("gex");
|
||||
if(AntiChatSpamModule.instance.isEnabled && message.equals(AntiChatSpamModule.latestPassedThroughMessage)) {
|
||||
AntiChatSpamModule.latestPassedThroughMessage = Text.empty();
|
||||
logChatMessage(message, indicator);
|
||||
logChatMessage(chatHudLine);
|
||||
return;
|
||||
}
|
||||
// ChipmunkMod.LOGGER.info("gex2");
|
||||
|
@ -75,7 +84,7 @@ public abstract class ChatHudMixin {
|
|||
if (cmessage.hidden) return;
|
||||
AntiChatSpamModule.latestPassedThroughMessage = message;
|
||||
Debug.debug("changed variable in module class", "AntiChatSpam.addMessage.future");
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(message, signature, indicator);
|
||||
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(message, signatureData, indicator);
|
||||
Debug.debug("ended a run or wahever", "AntiChatSpam.addMessage.future");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
} else if (cursor > commandManager.prefix.length() && text.startsWith(commandManager.prefix)) {
|
||||
final StringReader reader = new StringReader(text);
|
||||
reader.setCursor(commandManager.prefix.length()); // Skip the prefix
|
||||
|
||||
return;
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (cursor < commandManager.prefix.length() || !text.startsWith(commandManager.prefix)) return;
|
||||
|
||||
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();
|
||||
|
||||
pendingSuggestions = dispatcher.getCompletionSuggestions(dispatcher.parse(reader, commandSource), cursor);
|
||||
show(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.data.ChomeNSBotCommand;
|
||||
import land.chipmunk.chipmunkmod.modules.ChomeNSBotCommandSuggestions;
|
||||
|
@ -10,7 +9,6 @@ import land.chipmunk.chipmunkmod.util.Webhook;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.screen.ChatInputSuggestor;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import net.minecraft.client.gui.widget.TextFieldWidget;
|
||||
import net.minecraft.text.MutableText;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -20,12 +18,9 @@ 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)
|
||||
|
@ -33,7 +28,7 @@ public class ChatScreenMixin extends Screen {
|
|||
@Shadow protected TextFieldWidget chatField;
|
||||
@Shadow private String originalChatText;
|
||||
@Shadow ChatInputSuggestor chatInputSuggestor;
|
||||
@Shadow private int messageHistorySize = -1;
|
||||
@Shadow private int messageHistoryIndex = -1;
|
||||
|
||||
public ChatScreenMixin(String originalChatText) {
|
||||
super(Text.translatable("chat_screen.title"));
|
||||
|
@ -44,7 +39,7 @@ public class ChatScreenMixin extends Screen {
|
|||
public void init (CallbackInfo ci) {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
this.messageHistorySize = client.inGameHud.getChatHud().getMessageHistory().size();
|
||||
this.messageHistoryIndex = 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());
|
||||
|
@ -64,7 +59,7 @@ public class ChatScreenMixin extends Screen {
|
|||
}
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
|
||||
public void sendMessage(String chatText, boolean addToHistory, CallbackInfoReturnable<Boolean> cir) {
|
||||
public void sendMessage(String chatText, boolean addToHistory, CallbackInfo ci) {
|
||||
final MinecraftClient client = MinecraftClient.getInstance();
|
||||
|
||||
if (addToHistory) {
|
||||
|
@ -87,27 +82,40 @@ 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;
|
||||
|
||||
cir.setReturnValue(true);
|
||||
cir.cancel();
|
||||
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));
|
||||
|
||||
ci.cancel();
|
||||
|
||||
return;
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
ci.cancel();
|
||||
}
|
||||
|
||||
@Unique
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ClientConnectionMixin {
|
|||
@Unique
|
||||
private static final Pattern CUSTOM_PITCH_PATTERN = Pattern.compile(".*\\.pitch\\.(.*)");
|
||||
|
||||
@Inject(at = @At("HEAD"), method = "disconnect", cancellable = true)
|
||||
@Inject(at = @At("HEAD"), method = "disconnect(Lnet/minecraft/text/Text;)V", cancellable = true)
|
||||
public void disconnect (Text disconnectReason, CallbackInfo ci) {
|
||||
if (disconnectReason == ClientPlayNetworkHandlerAccessor.chatValidationFailedText()) {
|
||||
ci.cancel();
|
||||
|
@ -79,7 +79,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()));
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
@ -63,12 +54,12 @@ public class ClientPlayNetworkHandlerMixin {
|
|||
RainbowName.INSTANCE.init();
|
||||
ChomeNSBotCommandSuggestions.INSTANCE.init();
|
||||
ChomeNSAuth.INSTANCE.init();
|
||||
CustomChat.INSTANCE.init();
|
||||
}
|
||||
|
||||
@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();
|
||||
|
@ -93,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)
|
||||
|
@ -128,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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ import land.chipmunk.chipmunkmod.util.SharedVariables;
|
|||
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;
|
||||
|
@ -13,10 +13,12 @@ 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 testClient$limitGuardianParticles(DefaultParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
||||
if(BlockGuardianParticlesModule.instance.isEnabled) cir.cancel();
|
||||
if(SharedVariables.elderGuardianParticleTimer > 0) cir.cancel();
|
||||
@Inject(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"), cancellable = true)
|
||||
private void testClient$limitGuardianParticles(SimpleParticleType defaultParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
|
||||
if(BlockGuardianParticlesModule.instance.isEnabled || SharedVariables.elderGuardianParticleTimer > 0) {
|
||||
cir.setReturnValue(null);
|
||||
cir.cancel();
|
||||
}
|
||||
SharedVariables.elderGuardianParticleTimer = 200;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ 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.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
@ -44,6 +45,7 @@ public class KeyboardInputMixin extends Input {
|
|||
}
|
||||
}
|
||||
|
||||
@Unique
|
||||
private static float getMovementMultiplier(boolean positive, boolean negative) {
|
||||
if (positive == negative) {
|
||||
return 0.0f;
|
||||
|
|
|
@ -17,13 +17,8 @@ public class KeyboardMixin {
|
|||
|
||||
// Don't @ me. It half-works
|
||||
// LUNA WHAT THE FUCK IS THIS MIXIN AM I SUPPOSED TO UNDERSTAND THIS
|
||||
@Redirect(method = "onKey(JIIII)V",
|
||||
at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.GETFIELD),
|
||||
slice = @Slice(
|
||||
from = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/Screen;wrapScreenError(Ljava/lang/Runnable;Ljava/lang/String;Ljava/lang/String;)V"),
|
||||
to = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/InputUtil;fromKeyCode(II)Lnet/minecraft/client/util/InputUtil$Key;")
|
||||
)
|
||||
)
|
||||
// lol
|
||||
@Redirect(method = "onKey(JIIII)V", at = @At(value = "FIELD", target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;", opcode = Opcodes.GETFIELD) )
|
||||
private Screen currentScreen(MinecraftClient instance) {
|
||||
// if (GuiMoveModule.instance.isEnabled) {
|
||||
// return null;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.nbt.NbtIo;
|
||||
import net.minecraft.nbt.NbtTagSizeTracker;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
import java.io.DataInput;
|
||||
|
||||
@Mixin(NbtIo.class)
|
||||
public interface NbtIoInvoker {
|
||||
@Invoker(value = "read")
|
||||
static NbtElement readInvoker(DataInput input, int depth, NbtTagSizeTracker tracker) {
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.util.Chat;
|
||||
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 testclient$preventNbtKick(DataInput input, int depth, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtElement> cir) throws IOException {
|
||||
byte b = input.readByte();
|
||||
if (b == 0) {
|
||||
cir.setReturnValue(NbtEnd.INSTANCE);
|
||||
} else {
|
||||
NbtString.skip(input);
|
||||
|
||||
try {
|
||||
cir.setReturnValue(NbtTypes.byId(b).read(input, depth, tracker));
|
||||
} catch (Exception var7) {
|
||||
Chat.sendGold("ChipmunkMod prevented an NBT kick!");
|
||||
cir.setReturnValue(NbtEnd.INSTANCE); // i don't fucking know i just copied
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "read(Ljava/io/DataInput;Lnet/minecraft/nbt/NbtTagSizeTracker;)Lnet/minecraft/nbt/NbtCompound;", at = @At("HEAD"), cancellable = true)
|
||||
private static void testclient$antiNbtKickPreventLag(DataInput input, NbtTagSizeTracker tracker, CallbackInfoReturnable<NbtCompound> cir) {
|
||||
NbtElement nbtElement = NbtIoInvoker.readInvoker(input, 0, tracker);
|
||||
if (nbtElement instanceof NbtCompound) {
|
||||
cir.setReturnValue((NbtCompound)nbtElement);
|
||||
} else {
|
||||
ChipmunkMod.LOGGER.warn("ChipmunkMod hopefully prevented lag lol idk");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package land.chipmunk.chipmunkmod.mixin;
|
||||
|
||||
import net.minecraft.network.PacketBundleHandler;
|
||||
import net.minecraft.network.listener.PacketListener;
|
||||
import net.minecraft.network.packet.BundlePacket;
|
||||
import net.minecraft.network.packet.BundleSplitterPacket;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Mixin(PacketBundleHandler.class)
|
||||
public interface PacketBundleHandlerMixin {
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@ package land.chipmunk.chipmunkmod.mixin;
|
|||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
|
||||
import land.chipmunk.chipmunkmod.util.SharedVariables;
|
||||
import net.minecraft.client.util.Session;
|
||||
import net.minecraft.client.session.Session;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
@ -70,6 +71,10 @@ public class ChomeNSAuth extends Listener {
|
|||
|
||||
final String toSendString = GsonComponentSerializer.gson().serialize(toSend);
|
||||
|
||||
System.out.println("Sending " + toSendString + " to " + selector);
|
||||
|
||||
CommandCore.INSTANCE.run("tellraw " + selector + " " + toSendString);
|
||||
|
||||
CustomChat.INSTANCE.resetTotal();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -5,6 +5,8 @@ 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.Block;
|
||||
import net.minecraft.block.CommandBlock;
|
||||
import net.minecraft.block.entity.CommandBlockBlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
|
@ -30,8 +32,12 @@ public class CommandCore {
|
|||
|
||||
private Timer timer;
|
||||
|
||||
private boolean shouldRefill = false;
|
||||
|
||||
public boolean runFillCommand = true;
|
||||
|
||||
public boolean clientPlayerEntityFilled = false;
|
||||
|
||||
public static CommandCore INSTANCE = new CommandCore(MinecraftClient.getInstance());
|
||||
|
||||
public CommandCore (MinecraftClient client) {
|
||||
|
@ -40,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 () {
|
||||
|
@ -51,15 +54,41 @@ public class CommandCore {
|
|||
}
|
||||
};
|
||||
|
||||
final TimerTask refillTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (clientPlayerEntityFilled) {
|
||||
clientPlayerEntityFilled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
check();
|
||||
|
||||
if (!shouldRefill) return;
|
||||
|
||||
refill();
|
||||
|
||||
shouldRefill = false;
|
||||
}
|
||||
};
|
||||
|
||||
timer = new Timer();
|
||||
|
||||
timer.schedule(task, 50, 50);
|
||||
|
||||
timer.schedule(refillTask, 50, 1000);
|
||||
|
||||
move(client.player.getPos());
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) cleanup();
|
||||
if (networkHandler == null) {
|
||||
cleanup();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reloadRelativeArea();
|
||||
}
|
||||
|
@ -68,6 +97,36 @@ public class CommandCore {
|
|||
noPos = ChipmunkMod.CONFIG.core.relativeArea;
|
||||
}
|
||||
|
||||
public void check () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null || withPos == null || !ready) return;
|
||||
|
||||
try {
|
||||
for (int x = withPos.start.getX(); x <= withPos.end.getX(); x++) {
|
||||
for (int y = withPos.start.getY(); y <= withPos.end.getY(); y++) {
|
||||
for (int z = withPos.start.getZ(); z <= withPos.end.getZ(); z++) {
|
||||
final BlockPos pos = new BlockPos(x, y, z);
|
||||
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
if (world == null) return;
|
||||
|
||||
final Block block = world.getBlockState(pos).getBlock();
|
||||
|
||||
if (block instanceof CommandBlock) continue;
|
||||
|
||||
shouldRefill = true;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void move (Vec3d position) {
|
||||
final ClientWorld world = client.world;
|
||||
|
||||
|
@ -162,6 +221,8 @@ public class CommandCore {
|
|||
|
||||
if (block == null) return;
|
||||
|
||||
System.out.println(command);
|
||||
|
||||
if (KaboomCheck.INSTANCE.isKaboom) {
|
||||
connection.send(
|
||||
new UpdateCommandBlockC2SPacket(
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import com.google.common.hash.Hashing;
|
||||
import com.google.gson.JsonElement;
|
||||
import land.chipmunk.chipmunkmod.ChipmunkMod;
|
||||
|
||||
|
||||
import land.chipmunk.chipmunkmod.commands.SayCommand;
|
||||
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;
|
||||
|
@ -14,6 +15,9 @@ import net.minecraft.client.network.ClientPlayNetworkHandler;
|
|||
import net.minecraft.client.network.ClientPlayerEntity;
|
||||
import net.minecraft.text.Text;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
|
@ -28,12 +32,49 @@ public class CustomChat {
|
|||
|
||||
public String format;
|
||||
|
||||
private Timer timer;
|
||||
|
||||
private int total = 0;
|
||||
|
||||
public CustomChat (MinecraftClient client) {
|
||||
this.client = client;
|
||||
|
||||
reloadFormat();
|
||||
}
|
||||
|
||||
public void init () {
|
||||
final TimerTask task = new TimerTask() {
|
||||
public void run () {
|
||||
tick();
|
||||
}
|
||||
};
|
||||
|
||||
resetTotal();
|
||||
|
||||
timer = new Timer();
|
||||
timer.schedule(task, 0, 50);
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler != null) return;
|
||||
|
||||
resetTotal();
|
||||
cleanup();
|
||||
}
|
||||
|
||||
public void resetTotal() {
|
||||
total = 0;
|
||||
}
|
||||
|
||||
private void cleanup () {
|
||||
if (timer == null) return;
|
||||
|
||||
timer.cancel();
|
||||
timer.purge();
|
||||
}
|
||||
|
||||
public void reloadFormat () {
|
||||
final JsonElement formatString = ChipmunkMod.CONFIG.customChat.format;
|
||||
|
||||
|
@ -73,6 +114,17 @@ public class CustomChat {
|
|||
final Component deserialized = serializer.deserialize(message);
|
||||
final String messageWithColor = GsonComponentSerializer.gson().serialize(deserialized).replace("MESSAGE", randomized);
|
||||
|
||||
final String key = ChipmunkMod.CONFIG.bots.chomens.formatKey;
|
||||
|
||||
final String hash = key != null ?
|
||||
Hashing.sha256()
|
||||
.hashString(key + total, StandardCharsets.UTF_8)
|
||||
.toString()
|
||||
.substring(0, 8) :
|
||||
"";
|
||||
|
||||
total++;
|
||||
|
||||
try {
|
||||
// final MutablePlayerListEntry entry = Players.INSTANCE.getEntry(client.getNetworkHandler().getProfile().getId());
|
||||
|
||||
|
@ -86,15 +138,16 @@ public class CustomChat {
|
|||
// .replace("\"PREFIX\"", prefix)
|
||||
// .replace("\"DISPLAYNAME\"", displayName)
|
||||
.replace("USERNAME", username)
|
||||
.replace("HASH", hash)
|
||||
.replace("{\"text\":\"MESSAGE\"}", messageWithColor)
|
||||
.replace("\"extra\":[\"MESSAGE\"],\"color\":", "\"extra\":[" + messageWithColor + "],\"color\":")
|
||||
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", "")) // TODO: make this not use regex
|
||||
.replace("MESSAGE", sanitizedMessage.replaceAll("&.", ""))
|
||||
.replace(randomized, "MESSAGE"); // ohio ohio
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,20 @@
|
|||
package land.chipmunk.chipmunkmod.modules;
|
||||
|
||||
import com.mojang.brigadier.suggestion.Suggestion;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import land.chipmunk.chipmunkmod.listeners.Listener;
|
||||
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
|
||||
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.network.ClientPlayNetworkHandler;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
import net.minecraft.network.packet.s2c.play.SubtitleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.TitleS2CPacket;
|
||||
import net.minecraft.network.packet.s2c.play.CommandSuggestionsS2CPacket;
|
||||
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class KaboomCheck extends Listener {
|
||||
public static final String TITLE_START_TEXT = "Welcome to ";
|
||||
public static final String TITLE_END_TEXT = "!";
|
||||
|
||||
public static final String SUBTITLE_START_TEXT = "Free OP";
|
||||
|
||||
public boolean isKaboom = false;
|
||||
|
||||
private boolean hasKaboomTitle = false;
|
||||
private boolean hasKaboomSubtitle = false;
|
||||
|
||||
private Timer timer = null;
|
||||
|
||||
private final MinecraftClient client;
|
||||
|
@ -49,50 +41,43 @@ public class KaboomCheck extends Listener {
|
|||
timer = new Timer();
|
||||
|
||||
timer.schedule(task, 50, 50);
|
||||
|
||||
check();
|
||||
}
|
||||
|
||||
private void tick () {
|
||||
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
|
||||
|
||||
if (networkHandler == null) cleanup();
|
||||
}
|
||||
|
||||
if (hasKaboomTitle && hasKaboomSubtitle) isKaboom = true;
|
||||
private void check () {
|
||||
final CompletableFuture<CommandSuggestionsS2CPacket> future = TabComplete.INSTANCE.complete("/ver ");
|
||||
|
||||
future.thenApply((packet) -> {
|
||||
final Suggestions suggestions = packet.getSuggestions();
|
||||
|
||||
for (int i = 0; i < suggestions.getList().size(); i++) {
|
||||
final Suggestion suggestion = suggestions.getList().get(i);
|
||||
|
||||
if (suggestion.getText().equals("Extras")) {
|
||||
isKaboom = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
private void cleanup () {
|
||||
if (timer == null) return;
|
||||
|
||||
isKaboom = false;
|
||||
hasKaboomTitle = false;
|
||||
hasKaboomSubtitle = false;
|
||||
|
||||
timer.purge();
|
||||
timer.cancel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetReceived(Packet<?> packet) {
|
||||
if (packet instanceof TitleS2CPacket) packetReceived((TitleS2CPacket) packet);
|
||||
else if (packet instanceof SubtitleS2CPacket) packetReceived((SubtitleS2CPacket) packet);
|
||||
}
|
||||
|
||||
// TODO: move this to a util class
|
||||
private String stripSectionSigns (String text) {
|
||||
return text.replaceAll("§.", "");
|
||||
}
|
||||
|
||||
public void packetReceived(TitleS2CPacket packet) {
|
||||
final String stripped = stripSectionSigns(packet.getTitle().getString());
|
||||
|
||||
if (
|
||||
stripped.startsWith(TITLE_START_TEXT) &&
|
||||
stripped.endsWith(TITLE_END_TEXT)
|
||||
) hasKaboomTitle = true;
|
||||
}
|
||||
|
||||
public void packetReceived(SubtitleS2CPacket packet) {
|
||||
final String stripped = stripSectionSigns(packet.getSubtitle().getString());
|
||||
|
||||
if (stripped.startsWith(SUBTITLE_START_TEXT)) hasKaboomSubtitle = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,8 +137,8 @@ public class Players extends Listener {
|
|||
|
||||
if (accessor == null) return;
|
||||
|
||||
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profile().getId());
|
||||
if(entryAccessor == null) return;
|
||||
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
|
||||
|
||||
entryAccessor.setGameMode(newEntry.gameMode());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
@ -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());
|
||||
|
||||
if(entryAccessor == null) return;
|
||||
|
||||
|
@ -171,9 +171,8 @@ public class Players extends Listener {
|
|||
final ClientPlayNetworkHandlerAccessor accessor = ((ClientPlayNetworkHandlerAccessor) MinecraftClient.getInstance().getNetworkHandler());
|
||||
|
||||
if (accessor == null) return;
|
||||
PlayerListEntry entry = accessor.playerListEntries().get(newEntry.profile().getId());
|
||||
if(entry == null) return;
|
||||
entry.setDisplayName(newEntry.displayName());
|
||||
|
||||
accessor.playerListEntries().get(newEntry.profileId()).setDisplayName(newEntry.displayName());
|
||||
}
|
||||
|
||||
private void removePlayer (UUID uuid) {
|
||||
|
@ -200,7 +199,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);
|
||||
|
@ -213,7 +212,7 @@ public class Players extends Listener {
|
|||
addToPlayerList(new PlayerListEntry(entry.profile, false));
|
||||
}
|
||||
|
||||
return packet;
|
||||
return true;
|
||||
});
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -136,7 +136,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) {
|
||||
|
|
|
@ -1,28 +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;
|
||||
|
@ -63,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;
|
||||
}
|
||||
}
|
||||
|
@ -110,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();
|
||||
}
|
||||
|
||||
|
@ -130,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();
|
||||
|
@ -141,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;
|
||||
}
|
||||
}
|
||||
|
@ -156,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));
|
||||
|
||||
|
@ -185,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)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -222,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.player.getX(),
|
||||
client.player.getY(),
|
||||
client.player.getZ(),
|
||||
note.volume,
|
||||
floatingPitch,
|
||||
Random.create().nextLong()
|
||||
),
|
||||
clientConnectionAccessor.packetListener()
|
||||
);
|
||||
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,
|
||||
true
|
||||
));
|
||||
} else {
|
||||
final float floatingPitch = MathUtilities.clamp((float) (0.5 * (Math.pow(2, ((note.pitch + (pitch / 10)) / 12)))), 0F, 2F);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -100,7 +100,7 @@ public class Category extends ButtonWidget {
|
|||
// }
|
||||
|
||||
@Override
|
||||
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
|
||||
MinecraftClient minecraftClient = MinecraftClient.getInstance();
|
||||
context.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
|
||||
|
|
|
@ -126,7 +126,7 @@ public class Module extends ButtonWidget {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderButton(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
public void renderWidget(DrawContext context, int mouseX, int mouseY, float delta) {
|
||||
boolean hovered = (mouseX>=getX() && mouseY>=getY() && mouseX<getWidth()+getX() && mouseY<getHeight()+getY());
|
||||
context.fill(getX(), getY(), getX()+getWidth(), getY()+getHeight(), hovered ? hoveredColor : defaultColor);
|
||||
context.fill(getX(), getY(), getX()+2, getY()+getHeight(), isEnabled ? enabledBarColor : disabledBarColor);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
|
||||
|
||||
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gui.widget.CheckboxWidget;
|
||||
import net.minecraft.client.gui.widget.SliderWidget;
|
||||
import net.minecraft.text.Text;
|
||||
|
@ -10,20 +11,22 @@ import java.lang.reflect.Field;
|
|||
public class BooleanCheckboxOption extends Option<Boolean> {
|
||||
private RunnableWithParameter<Boolean> onPress = value -> {};
|
||||
|
||||
CheckboxWidget checkboxWidget = new CheckboxWidget(0, 0, 20, 20, Text.empty(), optionValue) {
|
||||
@Override
|
||||
public void onPress() {
|
||||
optionValue = !optionValue;
|
||||
onPress.run(optionValue);
|
||||
CheckboxWidget checkboxWidget = CheckboxWidget.builder(Text.empty(), MinecraftClient.getInstance().textRenderer)
|
||||
.pos(0, 0)
|
||||
.maxWidth(20)
|
||||
.checked(optionValue)
|
||||
.callback((checkbox, checked) -> {
|
||||
optionValue = !optionValue;
|
||||
onPress.run(optionValue);
|
||||
|
||||
// equivalent of `checked = optionValue`, but checked is private so i have to use this :(
|
||||
try {
|
||||
Field checked = CheckboxWidget.class.getDeclaredField("checked");
|
||||
checked.setAccessible(true);
|
||||
checked.set(this, optionValue);
|
||||
} catch(NoSuchFieldException | IllegalAccessException e) {e.printStackTrace();}
|
||||
}
|
||||
};
|
||||
// equivalent of `checked = optionValue`, but checked is private so i have to use this :(
|
||||
try {
|
||||
Field checkedField = CheckboxWidget.class.getDeclaredField("checked");
|
||||
checkedField.setAccessible(true);
|
||||
checkedField.set(this, optionValue);
|
||||
} catch(NoSuchFieldException | IllegalAccessException e) {e.printStackTrace();}
|
||||
})
|
||||
.build();
|
||||
|
||||
public BooleanCheckboxOption(String name, boolean defaultValue) {
|
||||
super(name, defaultValue);
|
||||
|
|
|
@ -4,6 +4,8 @@ import net.minecraft.client.MinecraftClient;
|
|||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class AttributeModifier {
|
||||
/*
|
||||
|
@ -26,8 +28,8 @@ public class AttributeModifier {
|
|||
this.operation = operation;
|
||||
name = "TestClient@"+(new Throwable().getStackTrace()[1].getClassName())+"."+(new Throwable().getStackTrace()[1].getMethodName());
|
||||
// Chat.send("Created new attribute modifier " + name);
|
||||
instance = MinecraftClient.getInstance().player.getAttributeInstance(attribute);
|
||||
modifier = new EntityAttributeModifier(name, value, operation);
|
||||
instance = MinecraftClient.getInstance().player.getAttributeInstance(new RegistryEntry.Direct<>(attribute));
|
||||
modifier = new EntityAttributeModifier(Identifier.of(name), value, operation);
|
||||
}
|
||||
|
||||
public void add() {
|
||||
|
@ -39,12 +41,12 @@ public class AttributeModifier {
|
|||
}
|
||||
|
||||
public boolean isOnPlayer() {
|
||||
return instance.hasModifier(modifier);
|
||||
return instance.hasModifier(modifier.id());
|
||||
}
|
||||
|
||||
public void setValue(float value) {
|
||||
this.value = value;
|
||||
modifier = new EntityAttributeModifier(name, value, operation);
|
||||
modifier = new EntityAttributeModifier(Identifier.of(name), value, operation);
|
||||
// remove and add multiplier to refresh value
|
||||
if(isOnPlayer()){
|
||||
remove();
|
||||
|
|
|
@ -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;
|
||||
|
@ -29,7 +30,7 @@ public class BotValidationUtilities {
|
|||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("SHA-256");
|
||||
String time = String.valueOf(System.currentTimeMillis() / 10000);
|
||||
String input = command.replaceAll("&[0-9a-fklmnor]", "") + ";" + client.player.getUuidAsString() + ";" + time + ";" + key;
|
||||
String input = prefix + command.replaceAll("&[0-9a-fklmnor]", "") + ";" + client.player.getUuidAsString() + ";" + 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);
|
||||
|
@ -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,80 @@ 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;
|
||||
}
|
||||
|
||||
// !!! broken (for now)
|
||||
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();
|
||||
|
||||
long bigInt = ByteBuffer.wrap(new byte[] {0, 0, hash[0], hash[1], hash[2], hash[3], hash[4], hash[5]}).getLong();
|
||||
|
||||
String stringHash = Long.toUnsignedString(bigInt, 36).substring(0, 6);
|
||||
|
||||
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();
|
||||
|
|
|
@ -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()
|
||||
);
|
||||
}
|
||||
}
|
Binary file not shown.
Before Width: | Height: | Size: 453 B After Width: | Height: | Size: 3.5 MiB |
|
@ -2,7 +2,7 @@
|
|||
"required": true,
|
||||
"minVersion": "0.8",
|
||||
"package": "land.chipmunk.chipmunkmod.mixin",
|
||||
"compatibilityLevel": "JAVA_17",
|
||||
"compatibilityLevel": "JAVA_21",
|
||||
"client": [
|
||||
"ChatHudMixin",
|
||||
"ChatInputSuggestorMixin",
|
||||
|
@ -13,8 +13,7 @@
|
|||
"ClientPlayerEntityMixin",
|
||||
"ClientPlayNetworkHandlerAccessor",
|
||||
"ClientPlayNetworkHandlerMixin",
|
||||
"DecoderHandlerMixin",
|
||||
"DecoratedPotBlockEntitySherdsMixin",
|
||||
"CommandDispatcherMixin",
|
||||
"ElderGuardianAppearanceParticleMixin",
|
||||
"FontStorageMixin",
|
||||
"IdentifierMixin",
|
||||
|
@ -22,22 +21,18 @@
|
|||
"KeyboardMixin",
|
||||
"MinecraftClientAccessor",
|
||||
"MultiplayerScreenMixin",
|
||||
"NbtIoMixin",
|
||||
"PlayerEntityMixin",
|
||||
"PlayerListEntryAccessor",
|
||||
"SessionMixin",
|
||||
"SharedConstantsMixin",
|
||||
"SoundSystemMixin",
|
||||
"StringHelperMixin",
|
||||
"TextFieldWidgetMixin",
|
||||
"TextMixin",
|
||||
"TitleScreenMixin"
|
||||
"TextSerializerMixin",
|
||||
"TitleScreenMixin",
|
||||
"WorldRendererMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
},
|
||||
"mixins": [
|
||||
"NbtIoInvoker",
|
||||
"PacketBundleHandlerMixin",
|
||||
"PlayerEntityMixin",
|
||||
"TextMixin",
|
||||
"TextSerializerMixin"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,9 @@
|
|||
"hbot": { "prefix": "#", "key": null },
|
||||
"sbot": { "prefix": ":", "key": null },
|
||||
"chipmunk": { "prefix": "'", "key": null },
|
||||
"chomens": { "prefix": "*", "key": null, "authKey": 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 }
|
||||
},
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
"Blackilykat"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": "https://chayapak.chipmunk.land/",
|
||||
"homepage": "https://code.chipmunk.land/Blackilykat/chipmunkmod",
|
||||
"sources": "https://code.chipmunk.land/Blackilykat/chipmunkmod",
|
||||
"issues": "https://code.chipmunk.land/Blackilykat/chipmunkmod/issues"
|
||||
},
|
||||
|
@ -30,9 +30,11 @@
|
|||
],
|
||||
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"fabricloader": ">=0.16.5",
|
||||
"fabric-api": "*",
|
||||
"minecraft": ">1.20",
|
||||
"java": ">=17"
|
||||
"minecraft": ">=1.21",
|
||||
"java": ">=21"
|
||||
},
|
||||
"suggests": {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue