Compare commits

..

32 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
245c625b4c made readme better
thanks alexa
2023-10-13 10:29:52 -04:00
b5ba97afaf added .eval java with jshell and fixed TitleScreenMixin not being in mixins 2023-09-10 19:17:54 +02:00
11dbc4665a Merge remote-tracking branch 'upstream/1.20.1' into 1.20.1
# Conflicts:
#	src/main/java/land/chipmunk/chipmunkmod/Configuration.java
#	src/main/java/land/chipmunk/chipmunkmod/mixin/ChatScreenMixin.java
#	src/main/java/land/chipmunk/chipmunkmod/mixin/ClientConnectionMixin.java
#	src/main/java/land/chipmunk/chipmunkmod/mixin/TextSerializerMixin.java
#	src/main/java/land/chipmunk/chipmunkmod/modules/CommandCore.java
#	src/main/java/land/chipmunk/chipmunkmod/modules/SelfCare.java
#	src/main/resources/chipmunkmod.mixins.json
2023-09-10 13:15:01 +02:00
72bec0fbbf Removed hack features from the GUI and added selfcare and rainbowname to it, also renamed the categories 2023-09-10 12:32:56 +02:00
ec6a142b73 Stopped console from getting spammed with erros by the players module 2023-09-07 18:31:21 +02:00
a794ebd7d3 fixed antichatspam and made module memory work 2023-09-07 16:39:08 +02:00
bc35032c02 i forgot but uhh a bunch of stuff prbobaly 2023-08-26 14:29:09 +02:00
ce49c7238c Merge remote-tracking branch 'upstream/1.20.1' into 1.20.1 2023-07-21 15:23:20 +02:00
2a101f1576 made anti chat spam run in a different thread + made anti text obfuscation lag + i forgor 2023-07-15 12:10:05 +02:00
03478b3133 Fixed the hardcoded Dev_Blackilykat username
Now if the user in config is null it will use the user in the login session, else it will use defaultUsername
Also config now creates itself based on Configuration.java instead of a default config file
and it saves itself on quit
2023-07-02 03:11:12 +02:00
5a68eb0848 Merged chomens mod cummits 2023-07-01 21:28:59 +02:00
2d4e319c93 Merge pull request '1.20.1' (#1) from Luna/blackilykat-chipmunkmod:1.19 into 1.19
Reviewed-on: Blackilykat/chipmunkmod#1
2023-07-01 12:19:15 -04:00
Luna
ffa8145854 1.20.1 2023-07-01 11:57:05 -03:00
402ddef938 made anti chat spam work
thank you maniaplay for making me find out about magic algorithm
2023-06-30 20:29:04 +02:00
bf7fd7df93 honestly i forgot i hope i havent written sensitive info 2023-06-27 23:18:40 +02:00
efe2e56cb5 Renamed TextMixin to TextSerializerMixin and fixed decorated pot crash + empty name crash 2023-06-27 23:13:34 +02:00
914c9d9075 Made RainbowName not use /username and teams 2023-06-04 16:09:06 +02:00
09749e3725 Changed mod authors, sources and version 2023-06-04 16:08:18 +02:00
1b671635ce Fixed runnables at the end of client ticks not being registered in testclient modules 2023-06-04 12:21:05 +02:00
31124e4364 merged testclient into chipmunkmod 2023-06-03 19:09:03 +02:00
70 changed files with 2510 additions and 156 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

@ -3,6 +3,10 @@ plugins {
id 'maven-publish'
}
loom {
accessWidenerPath = file("src/main/resources/chipmunkmod.accesswidener")
}
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
@ -28,6 +32,8 @@ configurations {
}
dependencies {
implementation 'org.apache.commons:commons-text:1.10.0' // Use the version that best suits your project
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
@ -44,10 +50,16 @@ dependencies {
library "org.luaj:luaj-jse:3.0.1"
// Uncomment the following line to enable the deprecated Fabric API modules.
// 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.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
testCompileOnly 'org.projectlombok:lombok:1.18.34'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.34'
}
processResources {

View file

@ -9,11 +9,10 @@ org.gradle.parallel=true
loader_version=0.16.5
# Mod Properties
mod_version = 1.0.0
mod_version = 1.0.1
maven_group = land.chipmunk.chipmunkmod
archives_base_name = chipmunkmod
# Dependencies
fabric_version=0.105.0+1.21.1

Binary file not shown.

View file

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

5
gradlew vendored
View file

@ -131,10 +131,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi
# Increase the maximum file descriptors if we can.

View file

@ -1,6 +1,12 @@
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;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import land.chipmunk.chipmunkmod.util.TickRunnableHandler;
import land.chipmunk.chipmunkmod.modules.KaboomCheck;
import land.chipmunk.chipmunkmod.modules.Players;
import land.chipmunk.chipmunkmod.modules.SelfCare;
@ -17,39 +23,58 @@ import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.util.math.BlockPos;
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.
// That way, it's clear which mod wrote info, warnings, and errors.
public static final Logger LOGGER = LoggerFactory.getLogger("chipmunkmod");
public static Configuration CONFIG;
private static File CONFIG_DIR = new File("config");
private static File CONFIG_FILE = new File(CONFIG_DIR, "chipmunkmod.json");
public static Configuration CONFIG = new Configuration();
public static final File CONFIG_DIR = new File("config");
private static final File CONFIG_FILE = new File(CONFIG_DIR, "chipmunkmod.json");
public static ExecutorService executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
public static final ModuleMemory MEMORY = new ModuleMemory();
@Override
public void onInitialize () {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
try {
CONFIG = loadConfig();
} catch (IOException exception) {
throw new RuntimeException("Could not load the config", exception);
}
Keybinds.registerOpenGui();
TickRunnableHandler.registerTickEndRunnables();
if(CONFIG.defaultUsername == null) CONFIG.defaultUsername = MinecraftClient.getInstance().getSession().getUsername(); // testclient gui is not loaded yet so getUsername will not retunr the fake
Players.INSTANCE.init();
KaboomCheck.INSTANCE.init();
SelfCare.INSTANCE.init();
LOGGER.info("Loaded ChipmunkMod (chayapak's fork)");
//save on quit owo
ClientLifecycleEvents.CLIENT_STOPPING.register(client -> {
ModuleMemory.save();
try {
saveConfig();
} catch (IOException e) {
LOGGER.error("Failed to save config. Printing stacktrace.");
e.printStackTrace();
return;
}
LOGGER.info("Saved config!");
});
LOGGER.info("Loaded ChipmunkMod (Blackilykat's fork)");
}
public static Configuration loadConfig () throws IOException {
@ -57,28 +82,43 @@ public class ChipmunkMod implements ModInitializer {
final Gson gson = new GsonBuilder()
.registerTypeAdapter(BlockPos.class, new BlockPosTypeAdapter())
.serializeNulls()
.create();
final File file = CONFIG_FILE;
if (!file.exists()) {
InputStream is = ChipmunkMod.class.getClassLoader().getResourceAsStream("default_config.json");
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
final StringBuilder sb = new StringBuilder();
while (reader.ready()) sb.append((char) reader.read());
final String defaultConfig = sb.toString();
// Write the default config
BufferedWriter configWriter = new BufferedWriter(new FileWriter(file));
configWriter.write(defaultConfig);
configWriter.close();
return gson.fromJson(defaultConfig, Configuration.class);
saveConfig();
}
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 {
// 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);
configWriter.close();
}
}

View file

@ -1,26 +1,26 @@
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 boolean fullbright = true; // unused, but it is here for old configs
public AntiSpam antiSpam = new AntiSpam();
public String autoSkinUsername = "off";
// here so old configs can be migrated
public String testbotWebhook = null;
public String defaultUsername = null;
public Memory memory = new Memory();
public static class CommandManager {
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);
@ -67,6 +67,30 @@ public class Configuration {
}
public static class CustomChat {
public JsonObject format;
public JsonObject format = new Gson().fromJson("""
{
"translate": "chat.type.text",
"with": [
{
"selector": "USERNAME"
},
{
"text": "MESSAGE"
}
]
}
""", JsonObject.class);
}
public static class AntiSpam {
public int matchingMessagesToBeSpam = 20;
public int messageTimeInTicks = 100;
public int minimumLevenshteinDistanceToBeSpam = 20;
}
public static class Memory {
public HashMap<String, Boolean> categories = new HashMap<>();
public HashMap<String, Boolean> modules = new HashMap<>();
public HashMap<String, String> options = new HashMap<>(); // will convert all values to their type according to the method specified in the option type thing
}
}

View file

@ -37,7 +37,9 @@ public class CommandManager {
SayCommand.register(this.dispatcher);
AutoSkinCommand.register(this.dispatcher);
ReloadConfigCommand.register(this.dispatcher);
DebugCommand.register(this.dispatcher);
SelfCareCommand.register(this.dispatcher);
ClearAntiChatSpamQueueCommand.register(this.dispatcher);
}
public void executeCommand (String command) {

View file

@ -0,0 +1,30 @@
package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import land.chipmunk.chipmunkmod.util.Chat;
import land.chipmunk.chipmunkmod.util.Executor;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import java.util.List;
import java.util.concurrent.Executors;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
public class ClearAntiChatSpamQueueCommand {
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
final ClearAntiChatSpamQueueCommand instance = new ClearAntiChatSpamQueueCommand();
dispatcher.register(
literal("clearantichatspamqueue")
.executes(instance::run)
);
}
public int run(CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
List<Runnable> runnables = Executor.antiChatSpamService.shutdownNow();
Executor.antiChatSpamService = Executors.newFixedThreadPool(1);
Chat.sendGreen("Stopped " + runnables.size() + " chat messages from getting recieved!");
return 1;
}
}

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

@ -0,0 +1,65 @@
package land.chipmunk.chipmunkmod.commands;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import land.chipmunk.chipmunkmod.util.Debug;
import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import java.util.ArrayList;
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.string;
public class DebugCommand {
public static SuggestionProvider<FabricClientCommandSource> knownSuggestions = (context, builder) -> {
Debug.known.stream()
.filter(option -> option.startsWith(builder.getRemaining().toLowerCase()))
.forEach(builder::suggest);
return builder.buildFuture();
};
public static SuggestionProvider<FabricClientCommandSource> selectedSuggestions = (context, builder) -> {
Debug.selected.stream()
.filter(option -> option.startsWith(builder.getRemaining().toLowerCase()))
.forEach(builder::suggest);
return builder.buildFuture();
};
public static void register(CommandDispatcher<FabricClientCommandSource> dispatcher) {
dispatcher.register(
literal("debug")
.then(literal("add")
.then(argument("caller", string())
.suggests(knownSuggestions)
.executes(DebugCommand::add)))
.then(literal("remove")
.then(argument("caller", string())
.suggests(selectedSuggestions)
.executes(DebugCommand::remove)))
.then(literal("clear")
.executes(DebugCommand::clear))
);
}
public static int add(CommandContext<FabricClientCommandSource> context) {
String caller = context.getArgument("caller", String.class);
Debug.selected.add(caller);
context.getSource().sendFeedback(Text.literal("Added ").append(Text.literal(caller).formatted(Formatting.YELLOW)).append(Text.literal(" to the debug list!")));
return 0;
}
public static int remove(CommandContext<FabricClientCommandSource> context) {
String caller = context.getArgument("caller", String.class);
Debug.selected.remove(caller);
context.getSource().sendFeedback(Text.literal("Removed ").append(Text.literal(caller).formatted(Formatting.YELLOW)).append(Text.literal(" from the debug list!")));
return 0;
}
public static int clear(CommandContext<FabricClientCommandSource> context) {
Debug.selected = new ArrayList<>();
context.getSource().sendFeedback(Text.literal("Cleared the debug list!"));
return 0;
}
}

View file

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

View file

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

@ -7,6 +7,9 @@ import static com.mojang.brigadier.arguments.StringArgumentType.greedyString;
import static com.mojang.brigadier.arguments.StringArgumentType.getString;
import static land.chipmunk.chipmunkmod.command.CommandManager.literal;
import static land.chipmunk.chipmunkmod.command.CommandManager.argument;
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.TitleScreen;
@ -18,12 +21,9 @@ import net.minecraft.text.Text;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import java.util.Optional;
import java.util.UUID;
import land.chipmunk.chipmunkmod.mixin.MinecraftClientAccessor;
public class UsernameCommand {
private static final Session ORIGINAL_SESSION = ((MinecraftClientAccessor) MinecraftClient.getInstance()).session();
private static final SimpleCommandExceptionType USERNAME_TOO_LONG = new SimpleCommandExceptionType(Text.translatable("The specified username is longer than 16 characters"));
public static void register (CommandDispatcher<FabricClientCommandSource> dispatcher) {
@ -36,26 +36,21 @@ public class UsernameCommand {
.executes(c -> updateUsername(c))
)
)
.then(
literal("revert")
.executes(c -> updateSession(c, ORIGINAL_SESSION))
)
);
}
public static int updateUsername (CommandContext<FabricClientCommandSource> context) throws CommandSyntaxException {
final String username = getString(context, "username");
if (username.length() > 16) throw USERNAME_TOO_LONG.create();
final Session session = new Session(username, new UUID(0L, 0L), "", Optional.empty(), Optional.empty(), Session.AccountType.MOJANG);
return updateSession(context, session);
return updateSession(context, username);
}
public static int updateSession (CommandContext<FabricClientCommandSource> context, Session session) throws CommandSyntaxException {
public static int updateSession (CommandContext<FabricClientCommandSource> context, String username) throws CommandSyntaxException {
final FabricClientCommandSource source = context.getSource();
final MinecraftClient client = source.getClient();
((MinecraftClientAccessor) client).session(session);
ChipmunkMod.CONFIG.defaultUsername = username;
// TODO: Put this in a separate class
final ServerInfo info = client.getCurrentServerEntry();

View file

@ -0,0 +1,127 @@
package land.chipmunk.chipmunkmod.memory;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.Configuration;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import land.chipmunk.chipmunkmod.testclient.gui.components.Category;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.Option;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import static land.chipmunk.chipmunkmod.ChipmunkMod.LOGGER;
// i have realised this can also be used to save profiles
// like it would be so simple to implement that feature
// not 1.1.0 tho it's taking too long
// whyt he fuck is this here lmao i have a working config jsut use that ??1'11'!?
public class ModuleMemory {
public static class Module {
public final String name;
public boolean enabled;
public ArrayList<Option<?>> options = new ArrayList<>();
public Module(String name, boolean enabled) {
this.name = name;
this.enabled = enabled;
}
}
public static class Option<T extends Object> {
public final String name;
public T value;
public Option(String name, T value) {
this.name = name;
this.value = value;
}
public Class<T> getType() {return (Class<T>) value.getClass();} // ignore warning cause intellij has the stupid
}
public static void load() {
for (Map.Entry<String, Boolean> categoryInMemory : ChipmunkMod.CONFIG.memory.categories.entrySet()) {
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
if(categoryInMemory.getKey().equals(categoryInGui.getMessage().getString())) {
categoryInGui.isExtended = categoryInMemory.getValue();
}
}
}
for (Map.Entry<String, Boolean> moduleInMemory : ChipmunkMod.CONFIG.memory.modules.entrySet()) {
String[] split = moduleInMemory.getKey().split("\\.");
String category = split[0];
String module = split[1];
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
if(!categoryInGui.getMessage().getString().equals(category)) continue;
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
if(module.equals(moduleInGui.getMessage().getString())) {
moduleInGui.isEnabled = moduleInMemory.getValue();
}
}
}
}
for (Map.Entry<String, Boolean> moduleInMemory : ChipmunkMod.CONFIG.memory.modules.entrySet()) {
String[] split = moduleInMemory.getKey().split("\\.");
String category = split[0];
String module = split[1];
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
if(!categoryInGui.getMessage().getString().equals(category)) continue;
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
if(module.equals(moduleInGui.getMessage().getString())) {
moduleInGui.isEnabled = moduleInMemory.getValue();
}
}
}
}
for (Map.Entry<String, String> optionInMemory : ChipmunkMod.CONFIG.memory.options.entrySet()) {
String[] split = optionInMemory.getKey().split("\\.");
String category = split[0];
String module = split[1];
String option = split[2];
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
if(!categoryInGui.getMessage().getString().equals(category)) continue;
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
if(!module.equals(moduleInGui.getMessage().getString())) continue;
for (land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> optionInGui : moduleInGui.optionList) {
if(option.equals(optionInGui.name)) {
optionInGui.setValueFromString(optionInMemory.getValue());
}
}
}
}
}
LOGGER.info("Loaded module memory!");
}
public static void save() {
for (land.chipmunk.chipmunkmod.testclient.gui.components.Category categoryInGui : Gui.categoryList) {
String categoryKey = categoryInGui.getMessage().getString();
ChipmunkMod.CONFIG.memory.categories.put(categoryKey, categoryInGui.isExtended);
for (land.chipmunk.chipmunkmod.testclient.gui.components.Module moduleInGui : categoryInGui.moduleList) {
String moduleKey = categoryKey + "." + moduleInGui.getMessage().getString();
ChipmunkMod.CONFIG.memory.modules.put(moduleKey, moduleInGui.isEnabled);
for (land.chipmunk.chipmunkmod.testclient.gui.components.Option<?> optionInGui : moduleInGui.optionList) {
String key = moduleKey + "." + optionInGui.name;
ChipmunkMod.CONFIG.memory.options.put(key, optionInGui.getValueAsString());
}
}
}
}
}

View file

@ -0,0 +1,7 @@
package land.chipmunk.chipmunkmod.memory;
public class UnknownOptionTypeException extends RuntimeException { //runtime exception because i dont wanna catch this i just want it to crash me when something goes wrong
public UnknownOptionTypeException(Class<?> type) {
super(String.format("An option with type %s is not handled by ModuleMemory.", type.getTypeName()));
}
}

View file

@ -0,0 +1,127 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.modules.RainbowName;
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.AntiChatSpamModule;
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;
@Mixin(net.minecraft.client.gui.hud.ChatHud.class)
public abstract class ChatHudMixin {
@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(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);
//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();
}
@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();
customLogChatMessage(chatHudLine);
addVisibleMessage(chatHudLine);
addMessage(chatHudLine);
ci.cancel();
return;
}
try {
if (RainbowName.INSTANCE.enabled) {
if (message.getString().contains("Your nickname is now ") || message.getString().contains("Nickname changed.")) {
ci.cancel();
return;
}
}
if (((TranslatableTextContent) message.getContent()).getKey().equals("advMode.setCommand.success")) {
ci.cancel();
return;
}
} catch (ClassCastException ignored) {}
for (Listener listener : ListenerManager.listeners) {
listener.chatMessageReceived(message);
}
// for (AntiChatSpamModule.BlockedPattern pattern : AntiChatSpamModule.instance.patterns) {
// if(pattern.pattern().matcher(message.getString()).matches()) ci.cancel();
// }
// ChipmunkMod.LOGGER.info("gex3");
if(AntiChatSpamModule.INSTANCE.isEnabled) {
Executor.antiChatSpamService.submit(() -> {
try {
Debug.debug("started a run or wahever", "AntiChatSpam.addMessage.future");
AntiChatSpamModule.ChatMessage cmessage = new AntiChatSpamModule.ChatMessage(message.getString());
Debug.debug("hidden: " + cmessage.hidden, "AntiChatSpam.addMessage.future");
if (cmessage.hidden) return;
AntiChatSpamModule.latestPassedThroughMessage = message;
Debug.debug("changed variable in module class", "AntiChatSpam.addMessage.future");
MinecraftClient.getInstance().inGameHud.getChatHud().addMessage(message, signatureData, indicator);
Debug.debug("ended a run or wahever", "AntiChatSpam.addMessage.future");
} catch (Exception e) {
e.printStackTrace();
}
});
} else {
customLogChatMessage(chatHudLine);
addVisibleMessage(chatHudLine);
addMessage(chatHudLine);
}
ci.cancel();
}
}

View file

@ -1,67 +1,76 @@
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;
import land.chipmunk.chipmunkmod.util.BotValidationUtilities;
import land.chipmunk.chipmunkmod.util.Executor;
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 net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import javax.net.ssl.HttpsURLConnection;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
@Mixin(value = net.minecraft.client.gui.screen.ChatScreen.class)
public class ChatScreenMixin extends Screen {
@Shadow protected TextFieldWidget chatField;
@Shadow private String originalChatText;
@Shadow ChatInputSuggestor chatInputSuggestor;
@Shadow private int messageHistoryIndex = -1;
public ChatScreenMixin(String originalChatText) {
super(Text.translatable("chat_screen.title"));
this.originalChatText = originalChatText;
}
@Inject(method = "sendMessage", at = @At("HEAD"), cancellable = true)
private void sendMessage (String chatText, boolean addToHistory, CallbackInfo cir) {
final MinecraftClient client = MinecraftClient.getInstance();
if (addToHistory) {
client.inGameHud.getChatHud().addToMessageHistory(chatText);
public ChatScreenMixin(String originalChatText) {
super(Text.translatable("chat_screen.title"));
this.originalChatText = originalChatText;
}
if (ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith(ChipmunkMod.CONFIG.bots.testbot.prefix)) {
ChipmunkMod.executorService.submit(() -> {
@Inject(at = @At("TAIL"), method = "init", cancellable = true)
public void init (CallbackInfo ci) {
final MinecraftClient client = MinecraftClient.getInstance();
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());
}
};
this.chatField.setMaxLength(Integer.MAX_VALUE);
this.chatField.setDrawsBackground(false);
this.chatField.setText(this.originalChatText);
this.chatField.setChangedListener(this::onChatFieldUpdate);
this.chatField.setFocusUnlocked(false);
this.addSelectableChild(this.chatField);
this.chatInputSuggestor = new ChatInputSuggestor(this.client, this, this.chatField, this.textRenderer, false, false, 1, 10, true, -805306368);
this.chatInputSuggestor.refresh();
this.setInitialFocus(this.chatField);
ci.cancel();
}
@Inject(at = @At("HEAD"), method = "sendMessage", cancellable = true)
public void sendMessage(String chatText, boolean addToHistory, CallbackInfo ci) {
final MinecraftClient client = MinecraftClient.getInstance();
if (addToHistory) {
client.inGameHud.getChatHud().addToMessageHistory(chatText);
}
if(ChipmunkMod.CONFIG.bots.testbot.webhookUrl != null && chatText.startsWith("-")) {
Executor.service.submit(() -> {
try {
final URL url = new URL(ChipmunkMod.CONFIG.bots.testbot.webhookUrl);
final HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.addRequestProperty("Content-Type", "application/json");
connection.addRequestProperty("User-Agent", "ChipmunkMod");
connection.setDoOutput(true);
connection.setRequestMethod("POST");
final JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("username", "ChipmunkMod UwU");
jsonObject.addProperty("content", MinecraftClient.getInstance().getSession().getUsername());
final OutputStream stream = connection.getOutputStream();
stream.write(jsonObject.toString().getBytes());
stream.flush();
stream.close();
connection.getInputStream().close();
connection.disconnect();
Webhook.send(ChipmunkMod.CONFIG.bots.testbot.webhookUrl, ChipmunkMod.CONFIG.defaultUsername);
} catch (IOException e) {
ChipmunkMod.LOGGER.error("fard webhook url !!!t");
e.printStackTrace();
}
});
@ -91,7 +100,7 @@ public class ChatScreenMixin extends Screen {
try {
BotValidationUtilities.chomens(chatText.substring(prefixLength));
cir.cancel();
ci.cancel();
return;
} catch (Exception ignored) {}
@ -106,6 +115,13 @@ public class ChatScreenMixin extends Screen {
client.player.networkHandler.sendChatMessage(chatText);
}
cir.cancel();
ci.cancel();
}
@Unique
private void onChatFieldUpdate(String chatText) {
String string = this.chatField.getText();
this.chatInputSuggestor.setWindowActive(!string.equals(this.originalChatText));
this.chatInputSuggestor.refresh();
}
}

View file

@ -1,9 +1,10 @@
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;
import land.chipmunk.chipmunkmod.util.Chat;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.world.ClientWorld;
import net.minecraft.network.listener.PacketListener;
@ -28,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();
@ -37,6 +38,7 @@ public class ClientConnectionMixin {
@Inject(method = "exceptionCaught", at = @At("HEAD"), cancellable = true)
private void exceptionCaught (ChannelHandlerContext context, Throwable ex, CallbackInfo ci) {
Chat.sendGold("ChipmunkMod caught an exception in ClientConnection.");
ci.cancel();
ex.printStackTrace();
}
@ -51,10 +53,10 @@ public class ClientConnectionMixin {
// please don't skid this.,.
// mabe mabe mabe
if (packet instanceof ParticleS2CPacket t_packet) {
final double max = 1000;
if (t_packet.getCount() > max) {
// 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(((ParticleS2CPacket) packet).getCount()>1000) Chat.sendGold("ChipmunkMod prevented a particle kick!");
ci.cancel();
}
} else if (packet instanceof PlaySoundS2CPacket t_packet) {
@ -92,7 +94,7 @@ public class ClientConnectionMixin {
@Inject(at = @At("HEAD"), method = "send(Lnet/minecraft/network/packet/Packet;)V", cancellable = true)
private void sendPacket (Packet<?> packet, CallbackInfo ci) {
if (packet instanceof RequestCommandCompletionsC2SPacket t_packet) {
if (t_packet.getPartialCommand().length() > 2048) {
if (t_packet.getPartialCommand().length() > 2048) { // why was this comment here
ci.cancel();
return;
}

View file

@ -1,5 +1,7 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.BlockGuardianParticlesModule;
import land.chipmunk.chipmunkmod.util.SharedVariables;
import net.minecraft.client.particle.ElderGuardianAppearanceParticle;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.world.ClientWorld;
@ -11,10 +13,12 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(ElderGuardianAppearanceParticle.Factory.class)
public class ElderGuardianAppearanceParticleMixin {
@Inject(method = "createParticle(Lnet/minecraft/particle/SimpleParticleType;Lnet/minecraft/client/world/ClientWorld;DDDDDD)Lnet/minecraft/client/particle/Particle;", at = @At("HEAD"))
private void createParticle (SimpleParticleType simpleParticleType, ClientWorld clientWorld, double d, double e, double f, double g, double h, double i, CallbackInfoReturnable<Particle> cir) {
if (cir.isCancelled() || !cir.isCancellable()) return;
cir.cancel();
@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

@ -0,0 +1,28 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
import net.minecraft.client.font.FontStorage;
import net.minecraft.client.font.Glyph;
import net.minecraft.client.font.GlyphRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.time.Instant;
@Mixin(FontStorage.class)
public class FontStorageMixin {
@Shadow private GlyphRenderer blankGlyphRenderer;
@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;
cir.setReturnValue(blankGlyphRenderer);
}
// Debug.debug("Render time: "+(Instant.now().toEpochMilli() - AntiTextObfuscationLagModule.instance.renderTimeStart.toEpochMilli()), "AntiTextObfuscationLag.mixin");
}
}

View file

@ -0,0 +1,55 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.client.input.Input;
import net.minecraft.client.input.KeyboardInput;
import net.minecraft.client.option.GameOptions;
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;
@Mixin(KeyboardInput.class)
public class KeyboardInputMixin extends Input {
@Final
@Mutable
@Shadow
private final GameOptions settings;
public KeyboardInputMixin (GameOptions settings) {
this.settings = settings;
}
@Inject(method = "tick", at = @At("TAIL"))
private void tick (boolean slowDown, float f, CallbackInfo ci) {
this.pressingForward = this.settings.forwardKey.isPressed();
this.pressingBack = this.settings.backKey.isPressed();
this.pressingLeft = this.settings.leftKey.isPressed();
this.pressingRight = this.settings.rightKey.isPressed();
this.movementForward = getMovementMultiplier(this.pressingForward, this.pressingBack);
this.movementSideways = getMovementMultiplier(this.pressingLeft, this.pressingRight);
this.jumping = this.settings.jumpKey.isPressed();
// wtf loopcrougchs gone??????????????
// this.sneaking = LoopCrouch.INSTANCE.enabled() ?
// !LoopCrouch.INSTANCE.sneaking() :
// this.settings.sneakKey.isPressed();
// LoopCrouch.INSTANCE.sneaking(!LoopCrouch.INSTANCE.sneaking());
if (slowDown) {
this.movementSideways *= f;
this.movementForward *= f;
}
}
@Unique
private static float getMovementMultiplier(boolean positive, boolean negative) {
if (positive == negative) {
return 0.0f;
}
return positive ? 1.0f : -1.0f;
}
}

View file

@ -0,0 +1,29 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.client.Keyboard;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import org.lwjgl.glfw.GLFW;
import org.objectweb.asm.Opcodes;
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.Redirect;
import org.spongepowered.asm.mixin.injection.Slice;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(Keyboard.class)
public class KeyboardMixin {
// Don't @ me. It half-works
// LUNA WHAT THE FUCK IS THIS MIXIN AM I SUPPOSED TO UNDERSTAND THIS
// 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;
// } else {
return instance.currentScreen;
// }
}
}

View file

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

View file

@ -0,0 +1,12 @@
package land.chipmunk.chipmunkmod.mixin;
import net.minecraft.block.Block;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Block.class)
public class PlayerEntityMixin {
//slippery world was here
//TODO: remove
}

View file

@ -0,0 +1,22 @@
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.session.Session;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(Session.class)
public abstract class SessionMixin {
@Shadow public abstract Session.AccountType getAccountType();
@Inject(method = "getUsername", at=@At("RETURN"), cancellable = true)
void testclient$overrideUsernameGetter(CallbackInfoReturnable<String> cir) {
// only overrides when gui has been initialized cause issues
if(Gui.gui != null) cir.setReturnValue(ChipmunkMod.CONFIG.defaultUsername);
}
}

View file

@ -14,13 +14,12 @@ import java.util.Optional;
@Mixin(Text.class)
public interface TextMixin {
@Inject(method = "visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private <T> void visit (StringVisitable.StyledVisitor<T> styledVisitor, Style style, CallbackInfoReturnable<Optional<T>> cir, Style style2, Optional optional, Iterator var5, Text text) {
if (text == null) cir.setReturnValue(Optional.empty());
@Inject(method = "visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private <T> void testclient$preventVisitMethodCrash(StringVisitable.Visitor<T> visitor, CallbackInfoReturnable<Optional<T>> cir, Optional optional, Iterator var3, Text text) {
if(text == null) cir.setReturnValue(Optional.empty());
}
@Inject(method = "visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$Visitor;)Ljava/util/Optional;"), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private <T> void visit (StringVisitable.Visitor<T> visitor, CallbackInfoReturnable<Optional<T>> cir, Optional optional, Iterator var3, Text text) {
if (text == null) cir.setReturnValue(Optional.empty());
@Inject(method = "visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;", at = @At(value = "INVOKE", target = "Lnet/minecraft/text/Text;visit(Lnet/minecraft/text/StringVisitable$StyledVisitor;Lnet/minecraft/text/Style;)Ljava/util/Optional;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private <T> void testclient$preventVisitMethodCrash2(StringVisitable.StyledVisitor<T> styledVisitor, Style style, CallbackInfoReturnable<Optional<T>> cir, Style style2, Optional optional, Iterator var5, Text text) {
if(text == null) cir.setReturnValue(Optional.empty());
}
}

View file

@ -59,4 +59,9 @@ public class TextSerializerMixin {
cir.cancel();
}
@Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lnet/minecraft/text/MutableText;", at = @At("HEAD"), cancellable = true)
private void testclient$preventChatOverflowExploit(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext, CallbackInfoReturnable<MutableText> cir) {
Throwable throwable = new Throwable();
if(throwable.getStackTrace().length >= 700) cir.setReturnValue(Text.literal("TestClient prevented a text overflow exploit i think ("+throwable.getStackTrace().length+")").formatted(Formatting.GOLD));
}
}

View file

@ -0,0 +1,36 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.memory.ModuleMemory;
import land.chipmunk.chipmunkmod.testclient.gui.Gui;
import net.minecraft.client.gui.screen.SplashTextRenderer;
import net.minecraft.client.gui.screen.TitleScreen;
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.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.io.IOException;
@Mixin(TitleScreen.class)
public class TitleScreenMixin {
@Shadow
private SplashTextRenderer splashText;
@Inject(method = "init", at = @At("HEAD"))
void testclient$initializeGui(CallbackInfo ci) {
splashText = new SplashTextRenderer("uwu");
if(Gui.gui == null){
Gui.initAutoRefresher();
Gui.addComponents();
Gui.gui = new Gui();
ModuleMemory.load();
ChipmunkMod.LOGGER.info("Initialised gui!");
}
}
}

View file

@ -0,0 +1,19 @@
package land.chipmunk.chipmunkmod.mixin;
import land.chipmunk.chipmunkmod.testclient.modules.lag_prevention.AntiTextObfuscationLagModule;
import net.minecraft.client.render.WorldRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.time.Instant;
@Mixin(WorldRenderer.class)
public class WorldRendererMixin {
@Inject(method = "render", at = @At("HEAD"))
private void chipmunkmod$saveRenderStartTime(CallbackInfo ci) {
AntiTextObfuscationLagModule.INSTANCE.renderTimeStart = Instant.now();
AntiTextObfuscationLagModule.INSTANCE.exceededLimitThisTick = false;
}
}

View file

@ -4,6 +4,7 @@ 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;
@ -50,6 +51,7 @@ public class CommandCore {
final TimerTask task = new TimerTask() {
public void run () {
if(!CommandCoreModule.INSTANCE.isEnabled) return;
tick();
}
};
@ -57,6 +59,7 @@ public class CommandCore {
final TimerTask refillTask = new TimerTask() {
@Override
public void run() {
if(!CommandCoreModule.INSTANCE.isEnabled) return;
if (clientPlayerEntityFilled) {
clientPlayerEntityFilled = false;
return;
@ -94,7 +97,10 @@ public class CommandCore {
}
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 () {
@ -217,12 +223,12 @@ 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;
System.out.println(command);
if (KaboomCheck.INSTANCE.isKaboom) {
connection.send(
new UpdateCommandBlockC2SPacket(
@ -262,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

@ -139,7 +139,9 @@ public class Players extends Listener {
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
entryAccessor.setGameMode(newEntry.gameMode());
if(entryAccessor != null) {
entryAccessor.setGameMode(newEntry.gameMode());
}
} catch (Exception e) {
e.printStackTrace();
}
@ -157,6 +159,8 @@ public class Players extends Listener {
final PlayerListEntryAccessor entryAccessor = (PlayerListEntryAccessor) accessor.playerListEntries().get(newEntry.profileId());
if(entryAccessor == null) return;
entryAccessor.setLatency(newEntry.latency());
}
@ -170,7 +174,10 @@ public class Players extends Listener {
if (accessor == null) return;
accessor.playerListEntries().get(newEntry.profileId()).setDisplayName(newEntry.displayName());
PlayerListEntry oldEntry = accessor.playerListEntries().get(newEntry.profileId());
if(oldEntry != null) {
oldEntry.setDisplayName(newEntry.displayName());
}
}
private void removePlayer (UUID uuid) {

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.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
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;
@ -25,11 +31,13 @@ public class RainbowName {
public boolean enabled = false;
private String[] team;
public String displayName;
private int startHue = 0;
public double speed = 1;
public int saturation = 255;
public int value = 255;
public void init () {
final TimerTask task = new TimerTask() {
@ -90,24 +98,11 @@ public class RainbowName {
}
public void enable () {
final String[] colorCodes = generateColorCodes(8);
client.getNetworkHandler().sendChatCommand("extras:username " + generateUsername(colorCodes));
team = generateTeamName();
CommandCore.INSTANCE.run("minecraft:team add " + String.join("", team));
CommandCore.INSTANCE.run("minecraft:execute as " + client.getNetworkHandler().getProfile().getId() + " run team join " + String.join("", team));
enabled = true;
this.displayName = ChipmunkMod.CONFIG.defaultUsername;
}
public void disable () {
client.getNetworkHandler().sendChatCommand("extras:username " + client.getSession().getUsername());
CommandCore.INSTANCE.run("minecraft:team remove " + String.join("", team));
team = null;
CommandCore.INSTANCE.run("essentials:nick " + client.getSession().getUsername() + " off");
enabled = false;
@ -115,7 +110,7 @@ public class RainbowName {
public RainbowName (MinecraftClient client) {
this.client = client;
this.displayName = client.getSession().getUsername();
this.displayName = ChipmunkMod.CONFIG.defaultUsername;
}
private void tick () {
@ -128,22 +123,25 @@ public class RainbowName {
}
if (!enabled) return;
int hue = startHue;
int increment = (int) (360.0 / Math.max(displayName.length(), 20));
int increment = (int) (360.0 / Math.max(displayName.length(), 20) * speed);
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("minecraft:team modify " + String.join("", team) + " prefix " + GsonComponentSerializer.gson().serialize(component));
CommandCore.INSTANCE.run("essentials:nick " + client.getSession().getUsername() + " " + essentialsNickname);
CommandCore.INSTANCE.run("essentials:nick " + ChipmunkMod.CONFIG.defaultUsername + " " + essentialsNickname);
((RainbowNameModule.MutableTextWidget)RainbowNameModule.preview.widget).setText(preview);
startHue = (startHue + increment) % 360;
} catch (Exception e) {

View file

@ -3,6 +3,7 @@ package land.chipmunk.chipmunkmod.modules;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.listeners.Listener;
import land.chipmunk.chipmunkmod.listeners.ListenerManager;
import land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances.SelfCareModule;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayNetworkHandler;
import net.minecraft.client.network.ClientPlayerEntity;
@ -86,6 +87,8 @@ public class SelfCare extends Listener {
hasSkin = false;
cspy = false;
// cspy too mabe?
// why was cspy not here lol
}
@Override
@ -103,20 +106,22 @@ public class SelfCare extends Listener {
}
public void tick () {
final ClientPlayerEntity player = client.player;
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
if (networkHandler == null) {
cleanup();
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]"); }
else if (gameMode != 1 && gamemodeEnabled) networkHandler.sendChatCommand("gamemode creative");
else if (positionPacketsPerSecond >= 10 && icuEnabled) CommandCore.INSTANCE.run("sudo * icu stop");
}
public void chatTick () {
if(!SelfCareModule.INSTANCE.isEnabled) return;
final ClientPlayNetworkHandler networkHandler = client.getNetworkHandler();
if (!cspy && cspyEnabled) { if (serverHasCommand("c")) networkHandler.sendChatCommand("c on"); }

View file

@ -0,0 +1,185 @@
package land.chipmunk.chipmunkmod.testclient.gui;
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;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.Selectable;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
public class
Gui extends Screen{
public static ArrayList<Category> categoryList = new ArrayList<>();
public static Gui gui;
public <T extends Element & Drawable & Selectable> void publicAddDrawableChild(T element) {
addDrawableChild(element);
}
public void publicRemove(Element child) {
remove(child);
}
public Gui() {
super(Text.literal("TestClient menu"));
AtomicInteger categoryX = new AtomicInteger(20);
AtomicInteger categoryY = new AtomicInteger(20);
categoryList.forEach(category -> {
category.setFullHeight(categoryY.get());
addDrawableChild(category); // adapt category to be buttons
category.setX(categoryX.get());
category.setY(categoryY.get());
// category.setWidth(Main.MC.textRenderer.getWidth(category.getMessage()) + 20);
ChipmunkMod.LOGGER.info("Created category " + category.getMessage().getString() + " at x " + categoryX.get() + "(" + category.getX() + ") and y " + categoryY + "(" + category.getY() + ") and is " + category.getWidth() + " wide and " + category.getFullHeight() + " high");
categoryX.addAndGet(category.getWidth() + 20);
if(categoryX.get() + category.getWidth() + 20 > MinecraftClient.getInstance().getWindow().getWidth()) {
categoryX.set(20);
categoryY.addAndGet(40); //TODO make a max height per row at some point
/* Something like:
+----------------------+
| #### ### #### ##### |
| //// /// ///// |
| /// |
| ### ##### ### |
| /// ///// |
| ///// |
| ///// |
+----------------------+
actually nvm its good as it is now
*/
}
AtomicInteger yPos = new AtomicInteger(category.getY());
if(category.isExtended) category.moduleList.forEach(module -> {
publicAddDrawableChild(module);
module.setX(category.getX());
module.setY(yPos.addAndGet(20));
module.setWidth(category.getWidth());
});
});
}
public void render(DrawContext context, int mouseX, int mouseY, float delta) {
// this.renderBackground(matrices);
super.render(context, mouseX, mouseY, delta);
}
public static void open() {
gui = new Gui();
MinecraftClient.getInstance().setScreen(gui);
}
// private class ScreenGui extends LightweightGuiDescription {
// public ScreenGui() {
// int scale = Main.MC.options.getGuiScale().getValue();
// // create invisible panel
// root = new Root();
// // set it as root
// setRootPanel(root);
// // make panel size big as the screen
// root.setSize(Main.MC.getWindow().getWidth()/scale, Main.MC.getWindow().getHeight()/scale); // still broken but fuck it idc
// root.setInsets(Insets.ROOT_PANEL);
//
// // set initial positions for the buttons
// AtomicInteger categoryX = new AtomicInteger(20);
// AtomicInteger categoryY = new AtomicInteger(20);
// categoryList.forEach(category -> {
// category.setFullHeight(categoryY.get());
// root.add(category, categoryX.get(), categoryY.get());
// category.setWidth(Main.MC.textRenderer.getWidth(category.getLabel()) + 20);
//
// Main.LOGGER.info("Created category " + category.getLabel().getString() + " at x " + categoryX.get() + "(" + category.getX() + ") and y " + categoryY + "(" + category.getY() + ") and is " + category.getWidth() + " wide and " + category.getFullHeight() + " high");
// categoryX.addAndGet(category.getWidth() + 20);
// if(categoryX.get() + category.getWidth() + 20 > root.getWidth()) {
// categoryX.set(20);
// categoryY.addAndGet(40); //TODO make a max height per row at some point
// /* Something like:
// +----------------------+
// | #### ### #### ##### |
// | //// /// ///// |
// | /// |
// | ### ##### ### |
// | /// ///// |
// | ///// |
// | ///// |
// +----------------------+
// actually nvm its good as it is now
// */
// }
// });
//
// root.validate(this);
// }
// }
public static void refreshGui() {
gui = new Gui();
}
public static void initAutoRefresher() {
// ClientTickEvents.END_CLIENT_TICK.register(listener -> {
// int scale = Main.MC.options.getGuiScale().getValue();
//// scale = 1;
// if(
// Main.MC.getWindow().getWidth()/scale != gui.root.getWidth()
// || Main.MC.getWindow().getHeight()/scale != gui.root.getHeight()
// ) {
// Main.LOGGER.info("Refreshed GUI size because "
// + Main.MC.getWindow().getWidth()/scale
// + " != "
// + gui.root.getWidth()
// + " or "
// + Main.MC.getWindow().getHeight()/scale
// + " != "
// + gui.root.getHeight()
// );
// refreshGui();
// }
// });
}
public static void addComponents() {
new Category("Lag prevention")
.withModule(AntiParticleKickModule.INSTANCE)
.withModule(BlockGuardianParticlesModule.INSTANCE)
.withModule(AntiTextObfuscationLagModule.INSTANCE)
.register();
new Category("Anti annoyances")
.withModule(AntiChatSpamModule.INSTANCE)
.withModule(new AntiTeleportModule())
.withModule(SelfCareModule.INSTANCE)
.register();
new Category("Fun")
.withModule(RainbowNameModule.INSTANCE)
.withModule(CustomChatModule.INSTANCE)
.register();
new Category("Other")
.withModule(CommandCoreModule.INSTANCE)
.register();
}
}

View file

@ -0,0 +1,50 @@
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;
import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;
public class OptionsScreen extends Screen {
public static int backgroundColor = 0x99000000;
ArrayList<Option<?>> optionList = new ArrayList<>();
public OptionsScreen(Module module) {
super(module.getMessage().copy().append("'s options"));
for (Option<?> option : module.optionList) {
optionList.add(option);
addDrawableChild(option.widget);
}
}
@Override
public void render(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);
AtomicInteger textY = new AtomicInteger(50);
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, getTitle(), width/2 - textWidth/2, 50, 0xFFFFFFFF);
context.fill(45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
for (Option<?> option : optionList) {
lineY.addAndGet(30);
context.drawTextWithShadow(MinecraftClient.getInstance().textRenderer, option.name, 50, textY.addAndGet(30), 0xFFFFFFFF);
context.fill(45, lineY.get()-1, width-45, lineY.get(), 0x33FFFFFF);
// drawHorizontalLine(matrices, 45, width-45, lineY.addAndGet(30), 0x33FFFFFF);
option.widget.setX(width - 50 - option.widget.getWidth());
option.widget.setY(textY.get() - ((option.widget.getHeight()-9)/2));
}
// 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

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

View file

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

View file

@ -0,0 +1,23 @@
package land.chipmunk.chipmunkmod.testclient.gui.components;
import land.chipmunk.chipmunkmod.memory.ModuleMemory;
import net.minecraft.client.gui.widget.ClickableWidget;
public abstract class Option<ValueType> {
public String name;
public ValueType optionValue;
public ClickableWidget widget;
public Option(String name, ValueType defaultValue) {
this.name = name;
optionValue = defaultValue;
}
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();
public abstract void setOptionValue(ValueType optionValue);
}

View file

@ -0,0 +1,58 @@
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;
import java.lang.reflect.Field;
public class BooleanCheckboxOption extends Option<Boolean> {
private RunnableWithParameter<Boolean> onPress = value -> {};
CheckboxWidget checkboxWidget = CheckboxWidget.builder(Text.empty(), MinecraftClient.getInstance().textRenderer)
.pos(0, 0)
.maxWidth(20)
.checked(optionValue)
.callback((checkbox, checked) -> {
optionValue = !optionValue;
onPress.run(optionValue);
checkbox.checked = optionValue;
})
.build();
public BooleanCheckboxOption(String name, boolean defaultValue) {
super(name, defaultValue);
optionValue = defaultValue;
widget = checkboxWidget;
}
public BooleanCheckboxOption(String name, boolean defaultValue, RunnableWithParameter<Boolean> onPress) {
super(name, defaultValue);
optionValue = defaultValue;
widget = checkboxWidget;
this.onPress = onPress;
}
@Override
public void setValueFromString(String string) {
setOptionValue(Boolean.valueOf(string));
}
@Override
public String getValueAsString() {
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

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

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

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

@ -0,0 +1,47 @@
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 StringOption extends Option<String> {
TextFieldWidget textFieldWidget = new TextFieldWidget(MinecraftClient.getInstance().textRenderer, 0, 0, 200, 20, Text.empty());
public StringOption(String name, String defaultValue) {
super(name, defaultValue);
textFieldWidget.setText(defaultValue);
textFieldWidget.setChangedListener(text -> {
optionValue = text;
});
widget = textFieldWidget;
}
public StringOption(String name, String defaultValue, Consumer<String> onChanged) {
super(name, defaultValue);
textFieldWidget.setText(defaultValue);
textFieldWidget.setChangedListener(text -> {
optionValue = text;
onChanged.accept(text);
});
widget = textFieldWidget;
}
@Override
public void setValueFromString(String string) {
setOptionValue(string);
}
@Override
public void setOptionValue(String optionValue) {
this.optionValue = optionValue;
textFieldWidget.setText(optionValue);
}
@Override
public String getValueAsString() {
return optionValue;
}
}

View file

@ -0,0 +1,96 @@
package land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.util.Debug;
import lombok.Getter;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.text.Text;
import org.apache.commons.text.similarity.LevenshteinDistance;
import java.util.ArrayList;
public class AntiChatSpamModule extends Module {
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");
isEnabled = true;
ClientTickEvents.END_CLIENT_TICK.register(client -> {
// ChipmunkMod.LOGGER.info("gex");
for (int i = 0; i < messages.size(); i++) {
if(messages.get(i) == null) continue;
Debug.debug("Ticked message: " + messages.get(i).content, debugTickedCaller);
messages.get(i).tick();
}
});
}
public static class ChatMessage {
private @Getter final String content;
public boolean hidden = false;
public int timer = ChipmunkMod.CONFIG.antiSpam.messageTimeInTicks;
public ChatMessage(String content) {
Debug.debug("AAAA", debugLevenshteinDistanceCallerSpamful);
this.content = content;
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;
// for (int j = 0; j < chatMessageArrayList.size(); j++) {
// ChatMessage message1 = chatMessageArrayList.get(j);
// if (pattern.matcher(message1.content()).matches()) matching++;
// }
// if (matching >= ChipmunkMod.CONFIG.antiSpam.matchingMessagesToBeSpam) {
// 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);
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
// });
}
public void tick() {
timer--;
if (timer <= 0) INSTANCE.messages.remove(this);
}
}
}

View file

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

View file

@ -0,0 +1,62 @@
package land.chipmunk.chipmunkmod.testclient.modules.anti_annoyances;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import land.chipmunk.chipmunkmod.modules.SelfCare;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.BooleanCheckboxOption;
import land.chipmunk.chipmunkmod.testclient.gui.components.options.StringOption;
public class SelfCareModule extends Module {
public static final SelfCareModule INSTANCE = new SelfCareModule();
public BooleanCheckboxOption opOption = new BooleanCheckboxOption(
"OP",
SelfCare.INSTANCE.opEnabled,
value -> SelfCare.INSTANCE.opEnabled = value
);
public BooleanCheckboxOption gmcOption = new BooleanCheckboxOption(
"Creative mode",
SelfCare.INSTANCE.gamemodeEnabled,
value -> SelfCare.INSTANCE.gamemodeEnabled = value
);
public BooleanCheckboxOption cspyOption = new BooleanCheckboxOption(
"Command spy",
SelfCare.INSTANCE.cspyEnabled,
value -> SelfCare.INSTANCE.cspyEnabled = value
);
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";
}
);
withOption(opOption);
withOption(gmcOption);
withOption(cspyOption);
withOption(icuOption);
withOption(skinOption);
withOption(skinUsernameOption);
/*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

@ -0,0 +1,70 @@
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 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

@ -0,0 +1,13 @@
package land.chipmunk.chipmunkmod.testclient.modules.lag_prevention;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
public class AntiParticleKickModule extends Module {
public static final AntiParticleKickModule INSTANCE = new AntiParticleKickModule();
public AntiParticleKickModule() {
super("Anti particle crash");
isEnabled = true;
}
}

View file

@ -0,0 +1,15 @@
package land.chipmunk.chipmunkmod.testclient.modules.lag_prevention;
import land.chipmunk.chipmunkmod.testclient.gui.components.Module;
import java.time.Instant;
public class AntiTextObfuscationLagModule extends Module {
public static final AntiTextObfuscationLagModule INSTANCE = new AntiTextObfuscationLagModule();
public Instant renderTimeStart = Instant.now();
public boolean exceededLimitThisTick = false;
public AntiTextObfuscationLagModule() {
super("Anti Text Obfuscation");
isEnabled = true;
}
}

View file

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

View file

@ -0,0 +1,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

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

View file

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

View file

@ -147,6 +147,7 @@ public class BotValidationUtilities {
return Command.SINGLE_SUCCESS;
}
// !!! broken (for now)
public static int nbot (String command) throws RuntimeException {
final Configuration.BotInfo info = ChipmunkMod.CONFIG.bots.nbot;
@ -168,9 +169,9 @@ public class BotValidationUtilities {
byte[] hash = md.digest();
ByteBuffer buffer = ByteBuffer.wrap(hash, 0, 4);
long bigInt = (buffer.getInt() & 0xFFFFFFFFL);;
String stringHash = Long.toString(bigInt, 36);
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);

View file

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

View file

@ -0,0 +1,14 @@
package land.chipmunk.chipmunkmod.util;
import land.chipmunk.chipmunkmod.ChipmunkMod;
import java.util.ArrayList;
public class Debug {
public static ArrayList<String> known = new ArrayList<>();
public static ArrayList<String> selected = new ArrayList<>();
public static void debug(String string, String caller) {
if(selected.contains(caller)) ChipmunkMod.LOGGER.info(String.format("[DEBUG|%s] %s", caller, string));
if(!known.contains(caller)) known.add(caller);
}
}

View file

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

View file

@ -0,0 +1,13 @@
package land.chipmunk.chipmunkmod.util;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
public class Executor {
public static ExecutorService service = Executors.newFixedThreadPool(20);
public static ExecutorService antiChatSpamService = Executors.newFixedThreadPool(1);
public static Future<?> submit(Runnable runnable) {
return service.submit(runnable);
}
}

View file

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

View file

@ -0,0 +1,12 @@
package land.chipmunk.chipmunkmod.util;
import net.minecraft.server.MinecraftServer;
/**
* This class is used when there isn't a specific class where you'd store a variable, but you still need it somewhere.
* It's mostly used by mixins which can't hold public variables themselves.
*/
public class SharedVariables {
public static MinecraftServer serverConnectedTo = null;
public static int elderGuardianParticleTimer = 0;
}

View file

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

View file

@ -0,0 +1,39 @@
package land.chipmunk.chipmunkmod.util;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import javax.net.ssl.HttpsURLConnection;
import java.awt.*;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Array;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.*;
/**
* unskidded 25/07/2023
*/
public class Webhook {
public static void send(String surl, String message) throws IOException {
Gson gson = new Gson();
JsonObject obj = new JsonObject();
URL url = new URL(surl);
obj.addProperty("content", message);
obj.addProperty("username", "chipmunkmod blackilykat fork (uwu)");
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.addRequestProperty("User-Agent", "chipmunkmod blackilykat fork (uwu)");
connection.addRequestProperty("Content-Type", "application/json");
connection.setDoOutput(true);
final OutputStream stream = connection.getOutputStream();
stream.write(obj.toString().getBytes());
stream.flush();
stream.close();
connection.getInputStream().close();
}
}

View file

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

View file

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

@ -4,24 +4,33 @@
"package": "land.chipmunk.chipmunkmod.mixin",
"compatibilityLevel": "JAVA_21",
"client": [
"ChatHudMixin",
"ChatInputSuggestorMixin",
"ChatScreenMixin",
"ClientConnectionAccessor",
"ClientConnectionInvoker",
"ClientConnectionMixin",
"ClientPlayerEntityMixin",
"ClientPlayNetworkHandlerAccessor",
"ClientPlayNetworkHandlerMixin",
"MinecraftClientAccessor",
"StringHelperMixin",
"ElderGuardianAppearanceParticleMixin",
"IdentifierMixin",
"TextMixin",
"ClientConnectionInvoker",
"ClientConnectionAccessor",
"PlayerListEntryAccessor",
"TextSerializerMixin",
"CommandDispatcherMixin",
"ElderGuardianAppearanceParticleMixin",
"FontStorageMixin",
"IdentifierMixin",
"KeyboardInputMixin",
"KeyboardMixin",
"MinecraftClientAccessor",
"MultiplayerScreenMixin",
"PlayerEntityMixin",
"PlayerListEntryAccessor",
"SessionMixin",
"SoundSystemMixin",
"TextFieldWidgetMixin"
"StringHelperMixin",
"TextFieldWidgetMixin",
"TextMixin",
"TextSerializerMixin",
"TitleScreenMixin",
"WorldRendererMixin"
],
"injectors": {
"defaultRequire": 1

View file

@ -3,17 +3,19 @@
"id": "chipmunkmod",
"version": "${version}",
"name": "ChipmunkMod (chayapak's fork)",
"accessWidener" : "chipmunkmod.accesswidener",
"name": "ChipmunkMod (Blackilykat's fork)",
"description": "My fork of ChipmunkMod",
"authors": [
"_ChipMC_",
"chayapak"
"chayapak",
"Blackilykat"
],
"contact": {
"homepage": "https://chayapak.chipmunk.land/",
"sources": "https://code.chipmunk.land/ChomeNS/chipmunkmod",
"issues": "https://code.chipmunk.land/ChomeNS/chipmunkmod/issues",
"discord": "https://discord.gg/xdgCkUyaA4"
"homepage": "https://code.chipmunk.land/Blackilykat/chipmunkmod",
"sources": "https://code.chipmunk.land/Blackilykat/chipmunkmod",
"issues": "https://code.chipmunk.land/Blackilykat/chipmunkmod/issues"
},
"license": "CC0-1.0",
@ -36,6 +38,5 @@
"java": ">=21"
},
"suggests": {
"another-mod": "*"
}
}