Compare commits

...

38 commits

Author SHA1 Message Date
bf46a9ef4f Move testbot auth location in config (doesnt break old configs) 2024-11-04 23:39:20 +01:00
23c4b60f00 forgor to delete 2 idiots 2024-11-04 23:23:27 +01:00
98ec1f7741 Add core gui module (breaks current configs!!!) 2024-11-04 23:21:45 +01:00
9260fb46b2 Add custom chat to gui 2024-11-04 22:40:19 +01:00
8b6b7b71fc Readded selfcare command + other selfcare fixes 2024-11-04 22:30:04 +01:00
4dbf7925cc Add saturation and value to rainbowname + a preview in gui settings 2024-11-04 19:07:36 +01:00
dcfbdfc544 Add way too many debug messages to antichatspam cause this makes 0 sense 2024-11-04 13:19:03 +01:00
9e6b14de91 hopefully fix core pos and size variable names getting fucked 2024-11-02 20:54:48 +01:00
5416cbf6f9 Fix more gui stuff 2024-11-02 19:05:08 +01:00
deeb89bb45 Fix some gui stuff 2024-11-02 18:18:29 +01:00
de55b8208e fix a bunch of stuff 2024-11-02 17:31:31 +01:00
9d9283c70b Merge upstream 2024-11-02 12:58:42 +01: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
245c625b4c made readme better
thanks alexa
2023-10-13 10:29:52 -04: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
ee5b2a0892 IC ON . 2023-09-27 17:20:57 +07:00
e15953918d reset on authenticated 2023-09-26 18:06:13 +07:00
d931a8abd1 fix kaboom check 2023-09-25 19:11:57 +07:00
bc738a6f25 fix 2023-09-24 18:16:05 +07:00
1604b0a996 FIXIES AUTO REFILL ?? 2023-09-24 09:12:33 +07:00
e0c7804aa7 better version of the imposter format 2023-09-24 08:52:37 +07:00
c2170ddfcd sexy 2023-09-22 20:19:48 +07:00
706fff00d4 the custom chat format HASHING >...... :) 2023-09-22 18:46:12 +07:00
78689abe93 get it on 900 2023-09-20 20:01:28 +07:00
8fce7f0ee6 CORE UH UH AUTO REFILL YEAH AND SOME SONG PLAYER SHIT 2023-09-20 19:25:40 +07:00
fedd15b946 fix hbot 2023-09-16 18:20:30 +07:00
75 changed files with 1005 additions and 807 deletions

1
.gitignore vendored
View file

@ -38,3 +38,4 @@ hs_err_*.log
replay_*.log
*.hprof
*.jfr
/buildAndSend.sh

View file

@ -1,4 +1,9 @@
# ChipmunkMod
My fork of [Chipmunk Sex Mod](https://code.chipmunk.land/ChipmunkMC/chipmunkmod)
My fork of [chipmunkmod (chayapak fork)](https://code.chipmunk.land/ChomeNS/chipmunkmod)
ignore messy code pls,. .,,.,...,.,.,
## alexa how to install
go to [releases](https://code.chipmunk.land/Blackilykat/chipmunkmod/releases) then on the latest one click `chipmunkmod-x.x.x.jar` to download then get [fabricmc](https://fabricmc.net/use/installer/) if you dont have it and then put the downloaded file in your `.minecraft/mods/` folder
if thats not clear enough ask your search engine how to install a fabric mod
if it pops up with errors you dont understand [create an issue](https://code.chipmunk.land/Blackilykat/chipmunkmod/issues/new) about it

View file

@ -1,15 +1,36 @@
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
loom {
accessWidenerPath = file("src/main/resources/chipmunkmod.accesswidener")
}
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 +42,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 +72,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 +87,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.
}
}

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.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

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
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

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

@ -1,5 +1,7 @@
package land.chipmunk.chipmunkmod;
import com.google.gson.ExclusionStrategy;
import com.google.gson.FieldAttributes;
import com.google.gson.GsonBuilder;
import land.chipmunk.chipmunkmod.memory.ModuleMemory;
import land.chipmunk.chipmunkmod.util.Keybinds;
@ -28,6 +30,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gson.Gson;
// what the fuck is this indentation who is responsible for this nightmare
public class ChipmunkMod implements ModInitializer {
// This logger is used to write text to the console and the log file.
// It is considered best practice to use your mod id as the logger's name.
@ -90,11 +93,29 @@ public class ChipmunkMod implements ModInitializer {
InputStream is = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
return gson.fromJson(reader, Configuration.class);
Configuration configuration = gson.fromJson(reader, Configuration.class);
if(configuration.bots.testbot.webhookUrl == null && configuration.testbotWebhook != null) {
LOGGER.info("Updating testbot auth url location in config!");
configuration.bots.testbot.webhookUrl = configuration.testbotWebhook;
configuration.testbotWebhook = null;
}
return configuration;
}
public static void saveConfig() throws IOException {
Gson otherGson = new GsonBuilder().serializeNulls().setLenient().setPrettyPrinting().create();
// to migrate old configs and avoid confusion on which field to use. Exclusion strategy should be removed once no one has the old auth location
// in their configs anymore
Gson otherGson = new GsonBuilder().serializeNulls().setLenient().setPrettyPrinting().addSerializationExclusionStrategy(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return f.getName().equals("testbotWebhook");
}
@Override
public boolean shouldSkipClass(Class<?> clazz) {
return false;
}
}).create();
String defaultConfig = otherGson.toJson(CONFIG);
BufferedWriter configWriter = new BufferedWriter(new FileWriter(CONFIG_FILE));
configWriter.write(defaultConfig);

View file

@ -2,20 +2,17 @@ package land.chipmunk.chipmunkmod;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import land.chipmunk.chipmunkmod.data.BlockArea;
import net.minecraft.util.math.BlockPos;
import java.util.HashMap;
public class Configuration {
public CommandManager commands = new CommandManager();
public CommandCore core = new CommandCore();
public Bots bots = new Bots();
public CustomChat customChat = new CustomChat();
public AntiSpam antiSpam = new AntiSpam();
public boolean fullbright = true; // unused, but it is here for old configs
public String autoSkinUsername = "off";
// here so old configs can be migrated
public String testbotWebhook = null;
public String defaultUsername = null;
public Memory memory = new Memory();
@ -24,15 +21,13 @@ public class Configuration {
public String prefix = ".";
}
public static class CommandCore {
public BlockArea relativeArea = new BlockArea(new BlockPos(0, 0, 0), new BlockPos(15, 0, 15));
}
public static class Bots {
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 +36,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;
}
}

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;
@ -38,8 +37,8 @@ public class CommandManager {
SayCommand.register(this.dispatcher);
AutoSkinCommand.register(this.dispatcher);
ReloadConfigCommand.register(this.dispatcher);
// LoopCrouchCommand.register(this.dispatcher); // ^???????????????????
DebugCommand.register(this.dispatcher);
SelfCareCommand.register(this.dispatcher);
ClearAntiChatSpamQueueCommand.register(this.dispatcher);
}
@ -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()));
}

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

@ -4,6 +4,7 @@ import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import land.chipmunk.chipmunkmod.modules.CustomChat;
import land.chipmunk.chipmunkmod.testclient.modules.fun.CustomChatModule;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.text.Text;
@ -39,6 +40,7 @@ public class CustomChatCommand {
final FabricClientCommandSource source = context.getSource();
final boolean bool = getBool(context, "boolean");
CustomChat.INSTANCE.enabled = bool;
CustomChatModule.INSTANCE.isEnabled = bool;
source.sendFeedback(Text.literal("Custom chat is now " + (bool ? "on" : "off")));
return Command.SINGLE_SUCCESS;

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

@ -2,10 +2,21 @@ package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.modules.SelfCare;
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.SelfCareModule;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.PlayerListEntry;
import net.minecraft.text.Text;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import static com.mojang.brigadier.arguments.BoolArgumentType.bool;
import static com.mojang.brigadier.arguments.BoolArgumentType.getBool;
@ -13,6 +24,8 @@ import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
public class SelfCareCommand {
private static final Logger log = LoggerFactory.getLogger(SelfCareCommand.class);
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(
literal("selfcare")
@ -44,6 +57,57 @@ public class SelfCareCommand {
.executes(m -> setSelfCare(m, "icu"))
)
)
.then(
literal("skin")
.then(
argument("skin", StringArgumentType.string())
.executes(context -> {
final FabricClientCommandSource source = context.getSource();
final String skin = StringArgumentType.getString(context, "skin");
SelfCare.INSTANCE.hasSkin = false;
SelfCare.INSTANCE.skin = skin;
if(skin.equals("off")) {
SelfCareModule.INSTANCE.skinOption.setOptionValue(false);
source.sendFeedback(Text.literal("Disabled skin self care"));
} else {
SelfCareModule.INSTANCE.skinOption.setOptionValue(true);
SelfCareModule.INSTANCE.skinUsernameOption.setOptionValue(skin);
source.sendFeedback(Text.literal("Skin self care enabled for " + skin + "'s skin"));
}
return Command.SINGLE_SUCCESS;
})
.suggests((context, builder) -> {
List<String> possibilities = new ArrayList<>();
possibilities.add("off");
String currentContext;
try {
currentContext = StringArgumentType.getString(context, "skin");
} catch(IllegalArgumentException e) {
currentContext = "";
}
ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler();
if(networkHandler == null) {
// probably impossible, but can't hurt having this
possibilities.add(ChipmunkMod.CONFIG.defaultUsername);
} else {
for(PlayerListEntry player : networkHandler.getPlayerList()) {
log.info("Found possibility {}", player.getProfile().getName());
possibilities.add(player.getProfile().getName());
}
}
for(String possibility : possibilities) {
if(possibility.toLowerCase().startsWith(currentContext.toLowerCase())) {
builder.suggest(possibility);
}
}
return builder.buildFuture();
})
)
)
);
}
@ -55,18 +119,22 @@ public class SelfCareCommand {
switch (type) {
case "op" -> {
SelfCare.INSTANCE.opEnabled = bool;
SelfCareModule.INSTANCE.opOption.setOptionValue(bool);
source.sendFeedback(Text.literal("The op self care is now " + (bool ? "enabled" : "disabled")));
}
case "gamemode" -> {
SelfCare.INSTANCE.gamemodeEnabled = bool;
SelfCareModule.INSTANCE.gmcOption.setOptionValue(bool);
source.sendFeedback(Text.literal("The gamemode self care is now " + (bool ? "enabled" : "disabled")));
}
case "cspy" -> {
SelfCare.INSTANCE.cspyEnabled = bool;
SelfCareModule.INSTANCE.cspyOption.setOptionValue(bool);
source.sendFeedback(Text.literal("The CommandSpy self care is now " + (bool ? "enabled" : "disabled")));
}
case "icu" -> {
SelfCare.INSTANCE.icuEnabled = bool;
SelfCareModule.INSTANCE.icuOption.setOptionValue(bool);
source.sendFeedback(Text.literal("The iControlU self care is now " + (bool ? "enabled" : "disabled")));
}
}

View file

@ -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;
}

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

@ -22,278 +22,6 @@ import static land.chipmunk.chipmunkmod.ChipmunkMod.LOGGER;
// whyt he fuck is this here lmao i have a working config jsut use that ??1'11'!?
public class ModuleMemory {
private static final File MEMORY_FILE = new File(ChipmunkMod.CONFIG_DIR, "chipmunkmodmemory.data");
public ArrayList<Category> categories = new ArrayList<>();
public void loadButOld() throws IOException {
if(!MEMORY_FILE.exists()) {
saveDefaults();
return;
}
// get the default values for everything and port it all to the local variables
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category category : Gui.categoryList) {
Category localCategory = new Category(category.getMessage().getString(), false);
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module module : category.moduleList) {
Module localModule = new Module(module.getMessage().getString(), module.isEnabled);
for (land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> option : module.optionList) {
localModule.options.add(option.toMemoryOption());
}
localCategory.modules.add(localModule);
}
categories.add(localCategory);
}
FileReader reader = null;
try{
reader = new FileReader(MEMORY_FILE);
} catch(FileNotFoundException ignored) {} // this should never happen
// all the constant keywords for easy switchery
final String startKeyword = "start";
final String endKeyword = "end";
final String categoryKeyword = "category";
final String moduleKeyword = "module";
final String optionKeyword = "option";
final String commentKeyword = "comment";
// declare all variables needed
boolean hasStarted = false;
boolean hasEnded = false;
int charCode;
char character;
boolean isReading = false;
StringBuilder buffer = new StringBuilder();
int reading = 0; // 0=keyword, 1=category, 2=module, 3=option, 4=comment
int argument = 0;
String firstArgument = null;
String secondArgument = null;
String currentCategory = null;
String currentModule = null;
// do the magic reading
assert reader != null;
while(reader.ready() && !hasEnded) {
charCode = reader.read(); character = (char) charCode;
LOGGER.info("i read ac haracter woo "+character);
LOGGER.info("buffer is "+buffer.toString());
switch(character) {
case '\n' -> {} // nothing else will get executed (i think)
case ';' -> {
if(argument==2) {
LOGGER.info("arg is 2");
secondArgument = buffer.toString();
switch (reading) {
case 1 -> { // category
LOGGER.info("doing magic category thing owo AAAAAAAAAAAAAAAAAAAAAAAAAAAA");
// first argument is the name
boolean extended = Boolean.parseBoolean(secondArgument);// second argument is if it's extended
for (Category category : categories) {
LOGGER.info("comparing category "+category.name+" with argument "+firstArgument);
if(!category.name.equals(firstArgument)) continue;
LOGGER.info("found category "+category.name);
category.extended = extended;
break;
}
currentCategory = firstArgument;
}
case 2 -> { // module
// first argument is the name
if(currentCategory == null) {
LOGGER.warn(String.format("Found module %s before a category was declared! ignoring", firstArgument));
continue;
}
boolean enabled = Boolean.parseBoolean(secondArgument); // second argument is if it's enabled
for(Category category : categories) {
if(!category.name.equals(currentCategory)) continue;
for (Module module : category.modules) {
if(!module.name.equals(firstArgument)) continue;
module.enabled = enabled;
break;
}
break;
}
currentModule = firstArgument;
}
case 3 -> { // option
if(currentModule == null) {
LOGGER.warn(String.format("Found option %s before a module was declared! ignoring", firstArgument));
continue;
}
if(currentCategory == null) {
LOGGER.warn(String.format("Found option %s before a category was declared! ignoring", firstArgument));
continue;
}
for(Category category : categories) {
if(!category.name.equals(currentCategory)) continue;
for (Module module : category.modules) {
if(!module.name.equals(firstArgument)) continue;
for(Option<?> option : module.options) {
if(!option.name.equals(firstArgument)) continue;
setOptionValue(option, secondArgument);
break;
}
break;
}
break;
}
}
}
}
if(reading==0) switch (buffer.toString()) {
case startKeyword -> {
if(hasStarted) LOGGER.warn("Found multiple ;start statements, only accepting the first one.");
hasStarted = true;
LOGGER.info("found start astyemtnttnnnt owo");
}
case endKeyword -> hasEnded = true;
}
buffer = new StringBuilder();
isReading = true;
reading = 0;
argument = 0;
}
case ':' -> {
argument++;
switch (reading) {
case 0 -> {
switch (buffer.toString()) {
case categoryKeyword -> reading = 1;
case moduleKeyword -> reading = 2;
case optionKeyword -> reading = 3;
case commentKeyword -> reading = 4;
default -> LOGGER.warn("Unknown argumentful keyword '" + buffer + "', ignoring");
}
}
case 4 -> {} // comment
default -> { // category, module and option all have 2 args so I can treat them equally
if(argument==2) firstArgument = buffer.toString();
argument++;
}
}
buffer = new StringBuilder();
}
default -> {
if(!isReading) continue;
buffer.append(character);
}
}
}
if(!hasStarted) {
LOGGER.warn("Memory file exists but has no ;start statement! Overriding file...");
saveDefaults();
}
if(!hasEnded) {
LOGGER.warn("Memory file exists but has no ;end statement! Overriding file...");
saveDefaults();
}
}
public void apply() {
for (Category category : categories) {
// find matching category and set extended
// then loop through every module and do the same thing
// then loop through every option and do the same thing
// get the matching category
land.chipmunk.chipmunkmod.testclient.gui.components.Category realCategory = null;
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
if(category.name.equals(categoryInGui.getMessage().getString())) {
// it's the right category
realCategory = categoryInGui;
break;
}
}
if(realCategory == null) {
LOGGER.warn(String.format("Category '%s' somehow not found in categoryInGui?? report to dev on discord @blackilykat because this is not supposed to be possible :DD", category.name));
continue;
}
LOGGER.info(String.format("Restoring category '%s' extended: %s", category.name, category.extended));
realCategory.isExtended = category.extended;
for(Module module : category.modules) {
land.chipmunk.chipmunkmod.testclient.gui.components.Module realModule = null;
for(land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInRealCategory : realCategory.moduleList) {
if(module.name.equals(moduleInRealCategory.getMessage().getString())) {
realModule = moduleInRealCategory;
break;
}
}
if(realModule == null) {
LOGGER.warn(String.format("Module '%s' somehow not found in category '%s'?? report to dev on discord @blackilykat because this is not supposed to be possible :DD", module.name, category.name));
continue;
}
LOGGER.info(String.format("Restoring module '%s' enabled: %s", module.name, module.enabled));
realModule.isEnabled = module.enabled;
for(Option<?> option : module.options) {
land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> realOption = null;
for(land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> optionInRealModule : realModule.optionList) {
if(option.name.equals(optionInRealModule.name)) {
realOption = optionInRealModule;
break;
}
}
if(realOption == null) {
LOGGER.warn(String.format("Option '%s' somehow not found in module '%s' in category '%s'?? report to dev on discord @blackilykat because this is not supposed to be possible :DD", option.name, module.name, category.name));
continue;
}
LOGGER.info(String.format("Restoring option '%s' value: %s", option.name, option.value));
setRealOptionValue(realOption, option);
}
}
}
}
public void saveDefaults() {
}
public <T> void setRealOptionValue(land.chipmunk.chipmunkmod.testclient.gui.components.Option<T> real, Option<?> fake) {
real.optionValue = (T) fake.value; // shut the fuck up intellij this cast is fine
}
public <T> void setOptionValue(Option<T> option, String value) {
if(option.getType() == String.class) {
option.value = (T) value; // ignore warning it's (String) string
} else if (option.getType() == Integer.class) {
Integer newValue = null;
try {
newValue = Integer.valueOf(value);
} catch (NumberFormatException e) {
LOGGER.warn(String.format("Option %s expects an integer, however the value '%s' cannot be parsed as one.", option.name, value));
return;
}
option.value = (T) newValue;
} else if (option.getType() == Double.class) {
Double newValue = null;
try {
newValue = Double.valueOf(value);
} catch (NumberFormatException e) {
LOGGER.warn(String.format("Option %s expects a double, however the value '%s' cannot be parsed as one.", option.name, value));
return;
}
option.value = (T) newValue;
} else {
throw new UnknownOptionTypeException(option.getType());
// no need to catch
// because pro runtime exception
}
}
public static class Category {
public final String name;
public boolean extended;
public ArrayList<Module> modules = new ArrayList<>();
public Category(String name, boolean extended) {
this.name = name;
this.extended = extended;
}
}
public static class Module {
public final String name;
public boolean enabled;

View file

@ -7,14 +7,18 @@ 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;
import net.minecraft.text.TranslatableTextContent;
import net.minecraft.util.Nullables;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@ -22,28 +26,59 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@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 @Final private static Logger LOGGER;
@Shadow protected abstract void logChatMessage(Text message, @Nullable MessageIndicator indicator);
@Shadow protected abstract void logChatMessage(ChatHudLine message);
@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);
@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);
//ci.cancel();
new Throwable().printStackTrace();
}
*/
// super jank
@Inject(method = "logChatMessage", at = @At("HEAD"), cancellable = true)
public void chipmunkmod$temp(ChatHudLine message, CallbackInfo ci) {
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) {
// ChipmunkMod.LOGGER.info("gex");
if(AntiChatSpamModule.instance.isEnabled && message.equals(AntiChatSpamModule.latestPassedThroughMessage)) {
@Unique
private void customLogChatMessage(ChatHudLine message) {
String string = message.content().getString().replaceAll("\r", "\\\\r").replaceAll("\n", "\\\\n");
String string2 = Nullables.map(message.indicator(), MessageIndicator::loggedName);
if (string2 != null) {
LOGGER.info("[{}] [CHAT] {}", string2, string);
} else {
LOGGER.info("[CHAT] {}", string);
}
}
@Inject(at = @At("HEAD"), method = "addMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/message/MessageSignatureData;Lnet/minecraft/client/gui/hud/MessageIndicator;)V", cancellable = true)
public void chipmunkmod$generalAddMessageMixin(Text message, MessageSignatureData signatureData, MessageIndicator indicator, CallbackInfo ci) {
ChatHudLine chatHudLine = new ChatHudLine(this.client.inGameHud.getTicks(), message, signatureData, indicator);
if(AntiChatSpamModule.INSTANCE.isEnabled && message.equals(AntiChatSpamModule.latestPassedThroughMessage)) {
AntiChatSpamModule.latestPassedThroughMessage = Text.empty();
logChatMessage(message, indicator);
customLogChatMessage(chatHudLine);
addVisibleMessage(chatHudLine);
addMessage(chatHudLine);
ci.cancel();
return;
}
// ChipmunkMod.LOGGER.info("gex2");
try {
if (RainbowName.INSTANCE.enabled) {
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
@ -66,7 +101,7 @@ public abstract class ChatHudMixin {
// if(pattern.pattern().matcher(message.getString()).matches()) ci.cancel();
// }
// ChipmunkMod.LOGGER.info("gex3");
if(AntiChatSpamModule.instance.isEnabled) {
if(AntiChatSpamModule.INSTANCE.isEnabled) {
Executor.antiChatSpamService.submit(() -> {
try {
Debug.debug("started a run or wahever", "AntiChatSpam.addMessage.future");
@ -75,14 +110,18 @@ 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();
}
});
ci.cancel();
} else {
customLogChatMessage(chatHudLine);
addVisibleMessage(chatHudLine);
addMessage(chatHudLine);
}
ci.cancel();
}
}

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

@ -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,16 +59,16 @@ 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) {
client.inGameHud.getChatHud().addToMessageHistory(chatText);
}
if(ChipmunkMod.CONFIG.testbotWebhook != null && chatText.startsWith("-")) {
if(ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith("-")) {
Executor.service.submit(() -> {
try {
Webhook.send(ChipmunkMod.CONFIG.testbotWebhook, ChipmunkMod.CONFIG.defaultUsername);
Webhook.send(ChipmunkMod.CONFIG.bots.testbot.webhookUrl, ChipmunkMod.CONFIG.defaultUsername);
} catch (IOException e) {
ChipmunkMod.LOGGER.error("fard webhook url !!!t");
e.printStackTrace();
@ -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

View file

@ -1,7 +1,6 @@
package land.chipmunk.chipmunkmod.mixin;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.DecoderException;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiParticleKickModule;
@ -30,7 +29,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();
@ -56,7 +55,7 @@ public class ClientConnectionMixin {
// mabe mabe mabe
// lol i had my own im just gonna cop ypaste that :D
if(packet instanceof ParticleS2CPacket) {
if(AntiParticleKickModule.instance.isEnabled && ((ParticleS2CPacket) packet).getCount()>1000) {
if(AntiParticleKickModule.INSTANCE.isEnabled && ((ParticleS2CPacket) packet).getCount()>1000) {
if(((ParticleS2CPacket) packet).getCount()>1000) Chat.sendGold("ChipmunkMod prevented a particle kick!");
ci.cancel();
}
@ -79,7 +78,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);
@ -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();
}

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

@ -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;
}
}

View file

@ -18,9 +18,9 @@ public class FontStorageMixin {
@Inject(method = "getObfuscatedGlyphRenderer", at = @At("HEAD"), cancellable = true)
private void chipmunkmod$preventObfuscatedGlyphLag(Glyph glyph, CallbackInfoReturnable<GlyphRenderer> cir) {
if(!AntiTextObfuscationLagModule.instance.isEnabled) return;
if(AntiTextObfuscationLagModule.instance.exceededLimitThisTick || Instant.now().toEpochMilli() - AntiTextObfuscationLagModule.instance.renderTimeStart.toEpochMilli() > 18) {
AntiTextObfuscationLagModule.instance.exceededLimitThisTick = true;
if(!AntiTextObfuscationLagModule.INSTANCE.isEnabled) return;
if(AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick || Instant.now().toEpochMilli() - AntiTextObfuscationLagModule.INSTANCE.renderTimeStart.toEpochMilli() > 18) {
AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick = true;
cir.setReturnValue(blankGlyphRenderer);
}
// Debug.debug("Render time: "+(Instant.now().toEpochMilli() - AntiTextObfuscationLagModule.instance.renderTimeStart.toEpochMilli()), "AntiTextObfuscationLag.mixin");

View file

@ -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;

View file

@ -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;

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,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();
}
}

View file

@ -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");
}
}
}

View file

@ -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 {
}

View file

@ -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;

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

@ -13,7 +13,7 @@ import java.time.Instant;
public class WorldRendererMixin {
@Inject(method = "render", at = @At("HEAD"))
private void chipmunkmod$saveRenderStartTime(CallbackInfo ci) {
AntiTextObfuscationLagModule.instance.renderTimeStart = Instant.now();
AntiTextObfuscationLagModule.instance.exceededLimitThisTick = false;
AntiTextObfuscationLagModule.INSTANCE.renderTimeStart = Instant.now();
AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick = false;
}
}

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
@ -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();
}
}

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

@ -4,7 +4,10 @@ import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.data.BlockArea;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.testclient.modules.other.CommandCoreModule;
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 +33,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,32 +47,90 @@ public class CommandCore {
}
public void init () {
if (timer != null) {
cleanup();
return;
}
if (timer != null) cleanup();
final TimerTask task = new TimerTask() {
public void run () {
if(!CommandCoreModule.INSTANCE.isEnabled) return;
tick();
}
};
final TimerTask refillTask = new TimerTask() {
@Override
public void run() {
if(!CommandCoreModule.INSTANCE.isEnabled) return;
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();
}
public void reloadRelativeArea () {
noPos = ChipmunkMod.CONFIG.core.relativeArea;
noPos = new BlockArea(new BlockPos(0, 0, 0),
new BlockPos(CommandCoreModule.INSTANCE.coreSizeX.optionValue-1,
CommandCoreModule.INSTANCE.coreSizeY.optionValue-1,
CommandCoreModule.INSTANCE.coreSizeZ.optionValue-1));
}
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) {
@ -158,6 +223,8 @@ public class CommandCore {
}
public void run (String command) {
// should probably throw an illegalstateexception but i dont feel like handling it everywhere
if(!CommandCoreModule.INSTANCE.isEnabled) return;
final ClientConnection connection = client.getNetworkHandler().getConnection();
if (block == null) return;
@ -201,6 +268,7 @@ public class CommandCore {
}
public CompletableFuture<NbtCompound> runTracked (String command) {
if(!CommandCoreModule.INSTANCE.isEnabled) return CompletableFuture.failedFuture(new IllegalStateException("The core is disabled!"));
final ClientConnection connection = client.getNetworkHandler().getConnection();
if (block == null) return new CompletableFuture<>();

View file

@ -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));
}
}
}

View file

@ -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;
}
}

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,9 +137,11 @@ 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());
if(entryAccessor != null) {
entryAccessor.setGameMode(newEntry.gameMode());
}
} catch (Exception e) {
e.printStackTrace();
}
@ -155,7 +157,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 +173,11 @@ 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());
PlayerListEntry oldEntry = accessor.playerListEntries().get(newEntry.profileId());
if(oldEntry != null) {
oldEntry.setDisplayName(newEntry.displayName());
}
}
private void removePlayer (UUID uuid) {
@ -200,7 +204,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 +217,7 @@ public class Players extends Listener {
addToPlayerList(new PlayerListEntry(entry.profile, false));
}
return packet;
return true;
});
} catch (Exception e) {
e.printStackTrace();

View file

@ -1,13 +1,19 @@
package land.chipmunk.chipmunkmod.modules;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.modules.fun.RainbowNameModule;
import land.chipmunk.chipmunkmod.util.ColorUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.TextWidget;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TextContent;
import java.util.Random;
import java.util.Timer;
@ -30,6 +36,8 @@ public class RainbowName {
private int startHue = 0;
public double speed = 1;
public int saturation = 255;
public int value = 255;
public void init () {
final TimerTask task = new TimerTask() {
@ -120,16 +128,21 @@ public class RainbowName {
Component component = Component.empty();
StringBuilder essentialsNickname = new StringBuilder();
MutableText preview = Text.empty();
for (char character : displayName.toCharArray()) {
String color = String.format("%06x", ColorUtilities.hsvToRgb(hue, 100, 100));
int colorRaw = ColorUtilities.hsvToRgb(hue, saturation, value);
String color = String.format("%06x", colorRaw);
component = component.append(Component.text(character).color(TextColor.fromHexString("#" + color)));
essentialsNickname.append("\u00a7#").append(color).append(character != ' ' ? character : '_');
preview.append(Text.of(character+"").copy().withColor(colorRaw));
hue = (hue + increment) % 360;
}
CommandCore.INSTANCE.run("essentials:nick " + ChipmunkMod.CONFIG.defaultUsername + " " + essentialsNickname);
((RainbowNameModule.MutableTextWidget)RainbowNameModule.preview.widget).setText(preview);
startHue = (startHue + increment) % 360;
} catch (Exception e) {
e.printStackTrace();

View file

@ -112,7 +112,7 @@ public class SelfCare extends Listener {
cleanup();
return;
}
if(!SelfCareModule.instance.isEnabled) return;
if(!SelfCareModule.INSTANCE.isEnabled) return;
final ClientPlayerEntity player = client.player;
if (player != null && !player.hasPermissionLevel(2) && opEnabled) { if (serverHasCommand("op")) networkHandler.sendChatCommand("op @s[type=player]"); }
@ -121,7 +121,7 @@ public class SelfCare extends Listener {
}
public void chatTick () {
if(!SelfCareModule.instance.isEnabled) return;
if(!SelfCareModule.INSTANCE.isEnabled) return;
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
if (!cspy && cspyEnabled) { if (serverHasCommand("c")) networkHandler.sendChatCommand("c on"); }
@ -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) {

View file

@ -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.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

@ -1,15 +1,16 @@
package land.chipmunk.chipmunkmod.testclient.gui;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.gui.components.Category;
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiChatSpamModule;
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.SelfCareModule;
import land.chipmunk.chipmunkmod.testclient.modules.fun.CustomChatModule;
import land.chipmunk.chipmunkmod.testclient.modules.fun.RainbowNameModule;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiParticleKickModule;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.BlockGuardianParticlesModule;
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiTeleportModule;
import land.chipmunk.chipmunkmod.testclient.modules.other.CommandCoreModule;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
@ -162,21 +163,22 @@ Gui extends Screen{
public static void addComponents() {
new Category("Lag prevention")
.withModule(AntiParticleKickModule.instance) //TODO: make kick prevention module
.withModule(BlockGuardianParticlesModule.instance)
.withModule(AntiTextObfuscationLagModule.instance)
.withModule(AntiParticleKickModule.INSTANCE)
.withModule(BlockGuardianParticlesModule.INSTANCE)
.withModule(AntiTextObfuscationLagModule.INSTANCE)
.register();
new Category("Anti annoyances")
.withModule(AntiChatSpamModule.instance)
.withModule(AntiChatSpamModule.INSTANCE)
.withModule(new AntiTeleportModule())
.withModule(SelfCareModule.instance)
.withModule(SelfCareModule.INSTANCE)
.register();
new Category("Fun")
.withModule(RainbowNameModule.instance)
.withModule(RainbowNameModule.INSTANCE)
.withModule(CustomChatModule.INSTANCE)
.register();
new Category("Other")
.withModule(CommandCoreModule.INSTANCE)
.register();
// new Category("OP")
// .withModule(AutoOpModule.instance) //TODO: make selfcare module
// .register();
}

View file

@ -1,9 +1,11 @@
package land.chipmunk.chipmunkmod.testclient.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.util.math.MatrixStack;
@ -23,6 +25,7 @@ public class OptionsScreen extends Screen {
@Override
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
renderBackground(context, mouseX, mouseY, delta);
context.fill(40, 40, width-40, height-40, backgroundColor);
int textWidth = MinecraftClient.getInstance().textRenderer.getWidth(getTitle());
AtomicInteger lineY = new AtomicInteger(70);
@ -39,7 +42,9 @@ public class OptionsScreen extends Screen {
option.widget.setX(width - 50 - option.widget.getWidth());
option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2));
}
super.render(context, mouseX, mouseY, delta);
// had to use access widener cause minecraft is silly and wont lemme separate background and foreground manually
for (Drawable drawable : this.drawables) {
drawable.render(context, mouseX, mouseY, delta);
}
}
}

View file

@ -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);

View file

@ -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);

View file

@ -13,9 +13,11 @@ public abstract class Option<ValueType> {
optionValue = defaultValue;
}
public ModuleMemory.Option<ValueType> toMemoryOption() {return new ModuleMemory.Option<>(name, optionValue);}
public Class<ValueType> getType() {return (Class<ValueType>) optionValue.getClass();} // ignore this error intellij has the stupid
// these two should match perfectly, meaning that setValueFromString(getValueAsString()); should do nothing
public abstract void setValueFromString(String string);
public abstract String getValueAsString();
// these two should match perfectly, meaning that setValueFromString(getValueAsString()); should do nothing
public abstract void setOptionValue(ValueType optionValue);
}

View file

@ -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,17 @@ 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() {
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();}
}
};
checkbox.checked = optionValue;
})
.build();
public BooleanCheckboxOption(String name, boolean defaultValue) {
super(name, defaultValue);
@ -39,7 +37,7 @@ public class BooleanCheckboxOption extends Option<Boolean> {
@Override
public void setValueFromString(String string) {
optionValue = Boolean.valueOf(string);
setOptionValue(Boolean.valueOf(string));
}
@Override
@ -47,6 +45,12 @@ public class BooleanCheckboxOption extends Option<Boolean> {
return Boolean.toString(optionValue);
}
@Override
public void setOptionValue(Boolean optionValue) {
this.optionValue = optionValue;
this.checkboxWidget.checked = optionValue;
}
public interface RunnableWithParameter<T> {
void run(T value);
}

View file

@ -10,13 +10,14 @@ public class DoubleSliderOption extends Option<Double> {
int roundTo = 4;
SliderWidget sliderWidget = new SliderWidget(0, 0, 100, 20, Text.literal("text ig"), 0.0) {
@Override
protected void updateMessage() {
public void updateMessage() {
setMessage(Text.literal(round((value * (maxValue - minValue) + minValue), roundTo)+""));
}
@Override
protected void applyValue() {
optionValue = round((value * (maxValue - minValue) + minValue), roundTo);
System.out.println("Saving value " + optionValue + " from " + value);
}
public double getValue() {
@ -55,9 +56,17 @@ public class DoubleSliderOption extends Option<Double> {
}
public void setValueFromString(String string) {
optionValue = Double.valueOf(string);
setOptionValue(Double.valueOf(string));
}
public String getValueAsString() {
return Double.toString(optionValue);
}
@Override
public void setOptionValue(Double optionValue) {
this.optionValue = optionValue;
sliderWidget.value = (optionValue - minValue) / (maxValue - minValue);
sliderWidget.updateMessage();
}
}

View file

@ -9,7 +9,7 @@ public class IntSliderOption extends Option<Integer> {
public int minValue = 0;
SliderWidget sliderWidget = new SliderWidget(0, 0, 100, 20, Text.literal("text ig"), 0.0) {
@Override
protected void updateMessage() {
public void updateMessage() {
setMessage(Text.literal(((int) (value * (maxValue - minValue) + minValue))+""));
}
@ -38,7 +38,14 @@ public class IntSliderOption extends Option<Integer> {
@Override
public void setValueFromString(String string) {
optionValue = Integer.valueOf(string);
this.setOptionValue(Integer.valueOf(string));
}
@Override
public void setOptionValue(Integer optionValue) {
this.optionValue = optionValue;
sliderWidget.value = (double) (optionValue - minValue) / (maxValue - minValue);
sliderWidget.updateMessage();
}
@Override

View file

@ -0,0 +1,54 @@
package land.chipmunk.chipmunkmod.testclient.gui.components.options;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.Text;
import java.util.function.Consumer;
public class IntTextFieldOption extends Option<Integer> {
TextFieldWidget textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 200, 20, Text.empty());
public IntTextFieldOption(String name, Integer defaultValue) {
super(name, defaultValue);
textFieldWidget.setText(defaultValue.toString());
textFieldWidget.setChangedListener(text -> {
try {
IntTextFieldOption.this.optionValue = Integer.valueOf(text);
} catch(NumberFormatException ignored) {
}
});
this.widget = textFieldWidget;
}
public IntTextFieldOption(String name, Integer defaultValue, Consumer<Integer> onChanged) {
super(name, defaultValue);
textFieldWidget.setText(defaultValue.toString());
textFieldWidget.setChangedListener(text -> {
try {
int i = Integer.parseInt(text);
IntTextFieldOption.this.optionValue = i;
onChanged.accept(i);
} catch(NumberFormatException ignored) {
}
});
this.widget = textFieldWidget;
}
@Override
public void setValueFromString(String string) {
setOptionValue(Integer.valueOf(string));
}
@Override
public String getValueAsString() {
return optionValue.toString();
}
@Override
public void setOptionValue(Integer optionValue) {
this.optionValue = optionValue;
textFieldWidget.setText(optionValue.toString());
}
}

View file

@ -30,7 +30,13 @@ public class StringOption extends Option<String> {
@Override
public void setValueFromString(String string) {
optionValue = string; // pro conversion
setOptionValue(string);
}
@Override
public void setOptionValue(String optionValue) {
this.optionValue = optionValue;
textFieldWidget.setText(optionValue);
}
@Override

View file

@ -11,13 +11,14 @@ import org.apache.commons.text.similarity.LevenshteinDistance;
import java.util.ArrayList;
public class AntiChatSpamModule extends Module {
public static Text latestPassedThroughMessage = Text.empty();
public static AntiChatSpamModule instance = new AntiChatSpamModule();
public ArrayList<ChatMessage> messages = new ArrayList<>();
public static final AntiChatSpamModule INSTANCE = new AntiChatSpamModule();
private static final String debugCallerPrefix = "AntiChatSpam.";
private static final String debugTickedCaller = debugCallerPrefix + "tick";
private static final String debugLevenshteinDistanceCaller = debugCallerPrefix + "levenshtein_distance";
private static final String debugLevenshteinDistanceCallerSpamless = debugCallerPrefix + "levenshtein_distance_spamless";
private static final String debugLevenshteinDistanceCallerSpamful = debugCallerPrefix + "levenshtein_distance_spamful";
public static Text latestPassedThroughMessage = Text.empty();
public ArrayList<ChatMessage> messages = new ArrayList<>();
public AntiChatSpamModule() {
super("Anti chat spam");
@ -39,17 +40,28 @@ public class AntiChatSpamModule extends Module {
public int timer = ChipmunkMod.CONFIG.antiSpam.messageTimeInTicks;
public ChatMessage(String content) {
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
this.content = content;
ArrayList<ChatMessage> chatMessages = instance.messages;
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
ArrayList<ChatMessage> chatMessages = INSTANCE.messages;
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
int similarMessages = 0;
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
LevenshteinDistance ld = new LevenshteinDistance(); // thanks maniaplay fo r teaching me about levenshtein distance
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
for (int i = 0; i < chatMessages.size(); i++) {
Debug.debug("BBBBB1", debugLevenshteinDistanceCallerSpamful);
ChatMessage message = chatMessages.get(i);
Debug.debug("BBBBB2", debugLevenshteinDistanceCallerSpamful);
if(message == null) continue;
Debug.debug("BBBBB3", debugLevenshteinDistanceCallerSpamful);
int distance = ld.apply(content, message.content);
Debug.debug("BBBBB4", debugLevenshteinDistanceCallerSpamful);
Debug.debug("Distance: " + distance, debugLevenshteinDistanceCaller);
Debug.debug("BBBBB5", debugLevenshteinDistanceCallerSpamful);
if (distance <= ChipmunkMod.CONFIG.antiSpam.minimumLevenshteinDistanceToBeSpam) similarMessages++;
Debug.debug("BBBBB6", debugLevenshteinDistanceCallerSpamful);
// Pattern pattern = getPattern(new ComparableString(this.content()), new ComparableString(message.content()));
// int matching = 0;
// ArrayList<ChatMessage> chatMessageArrayList = instance.messages;
@ -61,12 +73,15 @@ public class AntiChatSpamModule extends Module {
// instance.patterns.add(new BlockedPattern(pattern));
// }
}
Debug.debug("CCCC", debugLevenshteinDistanceCallerSpamful);
Debug.debug("Similar messages: " + similarMessages, debugLevenshteinDistanceCaller);
Debug.debug("Similar messages: " + similarMessages, debugLevenshteinDistanceCallerSpamless);
if (similarMessages >= ChipmunkMod.CONFIG.antiSpam.matchingMessagesToBeSpam) hidden = true;
Debug.debug("CCCC", debugLevenshteinDistanceCallerSpamful);
Debug.debug("Hidden: " + hidden, debugLevenshteinDistanceCaller);
Debug.debug("Hidden: " + hidden, debugLevenshteinDistanceCallerSpamless);
instance.messages.add(this);
INSTANCE.messages.add(this);
Debug.debug("CCCC", debugLevenshteinDistanceCallerSpamful);
// threadQueue.add(() -> {
// // code above used to be here but i cant decide if i should show it or not depending on the thread cuz i cant make it wait
// });
@ -75,7 +90,7 @@ public class AntiChatSpamModule extends Module {
public void tick() {
timer--;
if (timer <= 0) instance.messages.remove(this);
if (timer <= 0) INSTANCE.messages.remove(this);
}
}
}

View file

@ -7,46 +7,56 @@ import land.chipmunk.chipmunkmod.testclient.gui.components.options.BooleanCheckb
import land.chipmunk.chipmunkmod.testclient.gui.components.options.StringOption;
public class SelfCareModule extends Module {
public static SelfCareModule instance = new SelfCareModule();
BooleanCheckboxOption opOption = new BooleanCheckboxOption(
public static final SelfCareModule INSTANCE = new SelfCareModule();
public BooleanCheckboxOption opOption = new BooleanCheckboxOption(
"OP",
SelfCare.INSTANCE.opEnabled,
value -> SelfCare.INSTANCE.opEnabled = value
);
BooleanCheckboxOption gmcOption = new BooleanCheckboxOption(
public BooleanCheckboxOption gmcOption = new BooleanCheckboxOption(
"Creative mode",
SelfCare.INSTANCE.gamemodeEnabled,
value -> SelfCare.INSTANCE.gamemodeEnabled = value
);
BooleanCheckboxOption cspyOption = new BooleanCheckboxOption(
public BooleanCheckboxOption cspyOption = new BooleanCheckboxOption(
"Command spy",
SelfCare.INSTANCE.cspyEnabled,
value -> SelfCare.INSTANCE.cspyEnabled = value
);
StringOption skinUsernameOption = new StringOption(
public BooleanCheckboxOption icuOption = new BooleanCheckboxOption(
"ICU",
SelfCare.INSTANCE.icuEnabled,
value -> SelfCare.INSTANCE.icuEnabled = value
);
// split because skinUsernameOption and skinOption need to reference each other in their onChanged
public StringOption skinUsernameOption;
public BooleanCheckboxOption skinOption = new BooleanCheckboxOption(
"Skin",
SelfCare.INSTANCE.skin.equals("off"),
value -> {
SelfCare.INSTANCE.skin = value ? skinUsernameOption.optionValue : "off";
}
);
public SelfCareModule() {
super("Self care");
skinUsernameOption = new StringOption(
"Skin's username",
ChipmunkMod.CONFIG.defaultUsername,
s -> {
SelfCare.INSTANCE.hasSkin = false;
SelfCare.INSTANCE.skin = skinOption.optionValue ? s : "off";
}
);
BooleanCheckboxOption skinOption = new BooleanCheckboxOption(
"Skin",
SelfCare.INSTANCE.skin.equals("off")
// value -> {
// SelfCare.INSTANCE.skin = value ? skinUsernameOption.optionValue : "off";
// }
);
public SelfCareModule() {
super("Self care");
withOption(opOption);
withOption(gmcOption);
withOption(cspyOption);
withOption(icuOption);
withOption(skinOption);
withOption(skinUsernameOption);
endTickRunnable = () -> {
/*endTickRunnable = () -> {
// make it update the skin self acre username
SelfCare.INSTANCE.skin = skinOption.optionValue ? skinUsernameOption.optionValue : "off";
};
};*/
}
}

View file

@ -0,0 +1,20 @@
package land.chipmunk.chipmunkmod.testclient.modules.fun;
import land.chipmunk.chipmunkmod.modules.CustomChat;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
public class CustomChatModule extends Module {
public static final CustomChatModule INSTANCE = new CustomChatModule();
// no format option cause horrors
public CustomChatModule() {
super("Custom chat");
onActivate(() -> {
CustomChat.INSTANCE.enabled = true;
});
onDeactivate(() -> {
CustomChat.INSTANCE.enabled = false;
});
}
}

View file

@ -2,22 +2,69 @@ package land.chipmunk.chipmunkmod.testclient.modules.fun;
import land.chipmunk.chipmunkmod.modules.RainbowName;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.DoubleSliderOption;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.IntSliderOption;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.widget.TextWidget;
import net.minecraft.text.Text;
public class RainbowNameModule extends Module {
public static RainbowNameModule instance = new RainbowNameModule();
public static final RainbowNameModule INSTANCE = new RainbowNameModule();
public static DoubleSliderOption speedOption;
public static IntSliderOption saturationOption;
public static IntSliderOption valueOption;
public static Preview preview;
public RainbowNameModule() {
super("Rainbow name");
speedOption = new DoubleSliderOption("Speed", 1, 0.1, 2, 2);
withOption(speedOption);
saturationOption = new IntSliderOption("Saturation", 100, 0, 100);
withOption(saturationOption);
valueOption = new IntSliderOption("Value", 100, 0, 100);
withOption(valueOption);
preview = new Preview("Preview");
withOption(preview);
needsInWorld = true;
// onActivate(RainbowName.INSTANCE::enable);
onDeactivate(RainbowName.INSTANCE::disable);
atEndTick(() -> {
RainbowName.INSTANCE.enable();
RainbowName.INSTANCE.speed = speedOption.optionValue;
RainbowName.INSTANCE.saturation = saturationOption.optionValue;
RainbowName.INSTANCE.value = valueOption.optionValue;
});
}
public static class Preview extends Option<Void> {
public Preview(String name) {
super(name, null);
widget = new MutableTextWidget(Text.empty(), MinecraftClient.getInstance().textRenderer);
}
@Override
public void setValueFromString(String string) { }
@Override
public String getValueAsString() {
return "null";
}
@Override
public void setOptionValue(Void optionValue) { }
}
public static class MutableTextWidget extends TextWidget {
public MutableTextWidget(Text message, TextRenderer textRenderer) {
super(100, 20, message, textRenderer);
}
public void setText(Text text) {
this.message = text;
}
}
}

View file

@ -3,7 +3,7 @@ package land.chipmunk.chipmunkmod.testclient.modules.lag_prevention;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
public class AntiParticleKickModule extends Module {
public static AntiParticleKickModule instance = new AntiParticleKickModule();
public static final AntiParticleKickModule INSTANCE = new AntiParticleKickModule();
public AntiParticleKickModule() {
super("Anti particle crash");

View file

@ -5,7 +5,7 @@ import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import java.time.Instant;
public class AntiTextObfuscationLagModule extends Module {
public static AntiTextObfuscationLagModule instance = new AntiTextObfuscationLagModule();
public static final AntiTextObfuscationLagModule INSTANCE = new AntiTextObfuscationLagModule();
public Instant renderTimeStart = Instant.now();
public boolean exceededLimitThisTick = false;
public AntiTextObfuscationLagModule() {

View file

@ -5,7 +5,7 @@ import land.chipmunk.chipmunkmod.testclient.gui.components.options.StringOption;
import land.chipmunk.chipmunkmod.util.Chat;
public class BlockGuardianParticlesModule extends Module {
public static BlockGuardianParticlesModule instance = new BlockGuardianParticlesModule();
public static final BlockGuardianParticlesModule INSTANCE = new BlockGuardianParticlesModule();
public BlockGuardianParticlesModule() {
super("No guardian particles");

View file

@ -0,0 +1,25 @@
package land.chipmunk.chipmunkmod.testclient.modules.other;
import land.chipmunk.chipmunkmod.modules.CommandCore;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.IntTextFieldOption;
public class CommandCoreModule extends Module {
public static final CommandCoreModule INSTANCE = new CommandCoreModule();
public IntTextFieldOption coreSizeX = new IntTextFieldOption("Core size X", 16, ignored -> {
CommandCore.INSTANCE.reloadRelativeArea();
});
public IntTextFieldOption coreSizeY = new IntTextFieldOption("Core size X", 1, ignored -> {
CommandCore.INSTANCE.reloadRelativeArea();
});
public IntTextFieldOption coreSizeZ = new IntTextFieldOption("Core size X", 16, ignored -> {
CommandCore.INSTANCE.reloadRelativeArea();
});
public CommandCoreModule() {
super("Core");
withOption(coreSizeX);
withOption(coreSizeY);
withOption(coreSizeZ);
}
}

View file

@ -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();

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;
@ -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();

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()
);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 453 B

After

Width:  |  Height:  |  Size: 3.5 MiB

View file

@ -0,0 +1,6 @@
accessWidener v2 named
accessible field net/minecraft/client/gui/screen/Screen drawables Ljava/util/List;
accessible field net/minecraft/client/gui/widget/CheckboxWidget checked Z
accessible field net/minecraft/client/gui/widget/SliderWidget value D
accessible method net/minecraft/client/gui/widget/SliderWidget updateMessage ()V
accessible field net/minecraft/client/gui/widget/ClickableWidget message Lnet/minecraft/text/Text;

View file

@ -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"
]
}
}

View file

@ -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 }
},

View file

@ -3,6 +3,8 @@
"id": "chipmunkmod",
"version": "${version}",
"accessWidener" : "chipmunkmod.accesswidener",
"name": "ChipmunkMod (Blackilykat's fork)",
"description": "My fork of ChipmunkMod",
"authors": [
@ -11,7 +13,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 +32,11 @@
],
"depends": {
"fabricloader": ">=0.14.21",
"fabricloader": ">=0.16.5",
"fabric-api": "*",
"minecraft": ">1.20",
"java": ">=17"
"minecraft": ">=1.21",
"java": ">=21"
},
"suggests": {
}
}