Skip to content

Commit

Permalink
- Update version to 1.21.1
Browse files Browse the repository at this point in the history
- Optimized the logic for adding modules and commands in the project.
- Integrated Kotlin to enhance code readability and maintainability.
- Reduced boilerplate code and improved expressiveness in the codebase.
  • Loading branch information
qingshu-ui committed Oct 15, 2024
1 parent 63da778 commit b5ad781
Show file tree
Hide file tree
Showing 82 changed files with 412 additions and 119 deletions.
53 changes: 28 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ val kotlin_loader_version: String by project
plugins {
kotlin("jvm") version "2.0.21"
id("fabric-loom") version "1.7-SNAPSHOT"
id("com.google.devtools.ksp") version "2.0.21-1.0.25"
}

version = project.property("mod_version") as String
Expand Down Expand Up @@ -49,12 +50,17 @@ configurations {
}
}

fun DependencyHandlerScope.extraLibs(dependencyNotation: String, configure: ModuleDependency.() -> Unit = {}) {
add("extraLibs", dependencyNotation, configure)
}

dependencies {
// This will make it work on most platforms. It automatically chooses the right dependencies at runtime.
"extraLibs"("dev.duti.acheong:cubiomes:1.22.3") { isTransitive = false }
"extraLibs"("dev.duti.acheong:cubiomes:1.22.3:linux64") { isTransitive = false }
"extraLibs"("dev.duti.acheong:cubiomes:1.22.3:osx") { isTransitive = false }
"extraLibs"("dev.duti.acheong:cubiomes:1.22.3:windows64") { isTransitive = false }
val cubiomesVersion = "dev.duti.acheong:cubiomes:1.22.3"
listOf("linux64", "osx", "windows64").forEach { os ->
extraLibs("$cubiomesVersion:$os") { isTransitive = false }
}
extraLibs(cubiomesVersion) { isTransitive = false }
// To change the versions see the gradle.properties file
minecraft("com.mojang:minecraft:$minecraft_version")
mappings("net.fabricmc:yarn:$yarn_version:v2")
Expand All @@ -65,17 +71,22 @@ dependencies {
modCompileOnly("meteordevelopment:baritone:$baritone_version-SNAPSHOT")

// seed .locate and ore sim
"extraLibs"("com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91") { isTransitive = false }
"extraLibs"("com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409") { isTransitive = false }
"extraLibs"("com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f") { isTransitive = false }
"extraLibs"("com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962") { isTransitive = false }
"extraLibs"("com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78") { isTransitive = false }
"extraLibs"("com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126") { isTransitive = false }
"extraLibs"("com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229") { isTransitive = false }

val seedFindingDependencies = setOf(
"com.seedfinding:mc_math:ffd2edcfcc0d18147549c88cc7d8ec6cf21b5b91",
"com.seedfinding:mc_seed:1ead6fcefe7e8de4b3d60cd6c4e993f1e8f33409",
"com.seedfinding:mc_core:d64d5f90be66300da41ef58f4f1736db2499784f",
"com.seedfinding:mc_noise:7e3ba65e181796c4a2a1c8881d840b2254b92962",
"com.seedfinding:mc_biome:41a42cb9019a552598f12089059538853e18ec78",
"com.seedfinding:mc_terrain:b4246cbd5880c4f8745ccb90e1b102bde3448126",
"com.seedfinding:mc_feature:919b7e513cc1e87e029a9cd703fc4e2dc8686229"
)
seedFindingDependencies.forEach { dependency ->
extraLibs(dependency) { isTransitive = false }
}
// seedcracker api
implementation("com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:2.10.1") { isTransitive = false }
// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false}
// implementation (include('com.github.19MisterX98.SeedcrackerX:seedcrackerx-api:master-SNAPSHOT')) {transitive = false}
ksp(project(":processor"))
}

loom {
Expand All @@ -84,17 +95,17 @@ loom {

tasks.processResources {
inputs.property("version", project.version)
inputs.property("minecraft_version", project.property("minecraft_version"))
inputs.property("loader_version", project.property("loader_version"))
inputs.property("minecraft_version", minecraft_version)
inputs.property("loader_version", loader_version)
filteringCharset = "UTF-8"


filesMatching("fabric.mod.json") {
expand(
"version" to project.version,
"mc_version" to project.property("minecraft_version"),
"mc_version" to minecraft_version,
"gh_hash" to (System.getenv("GITHUB_SHA") ?: ""),
"kotlin_loader_version" to project.property("kotlin_loader_version"),
"kotlin_loader_version" to kotlin_loader_version,
)
}
}
Expand All @@ -115,15 +126,7 @@ tasks.withType<KotlinCompile>().configureEach {
}

tasks.withType<JavaCompile>().configureEach {
// ensure that the encoding is set to UTF-8, no matter what the system default is
// this fixes some edge cases with special characters not displaying correctly
// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
// If Javadoc is generated, this must be specified in that task too.
options.encoding = "UTF-8"

// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
if(JavaVersion.current().isJava9Compatible){
options.release.set(targetJavaVersion)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ maven_group = anticope.rejects
archives_base_name = meteor-rejects-addon

meteor_version=0.5.8
baritone_version=1.20.6
baritone_version=1.21.1
15 changes: 15 additions & 0 deletions processor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
kotlin("jvm")
id("com.google.devtools.ksp")
}

group = "com.github.shu"
version = "0.0.1"

repositories {
mavenCentral()
}

dependencies {
implementation("com.google.devtools.ksp:symbol-processing-api:2.0.21-1.0.25")
}
46 changes: 46 additions & 0 deletions processor/src/main/kotlin/com/github/shu/AutoRegisterProcessor.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.github.shu

import com.google.devtools.ksp.getConstructors
import com.google.devtools.ksp.processing.*
import com.google.devtools.ksp.symbol.KSAnnotated
import com.google.devtools.ksp.symbol.KSClassDeclaration

/**
* A KSP (Kotlin Symbol Processing) processor that processes class annotated with `@AutoRegister`.
* This processor checks if the annotated classes have a no-argument constructor or if all their
* constructor parameters hava default values. If neither condition is met, an error is logged.
*
* @param logger The KSP logger used for logging errors during processing.
*/
class AutoRegisterProcessor(private val logger: KSPLogger) : SymbolProcessor {

override fun process(resolver: Resolver): List<KSAnnotated> {
val autoRegisterClasses = resolver.getSymbolsWithAnnotation("anticope.rejects.annotation.AutoRegister")
autoRegisterClasses.forEach { classSymbol ->
if (classSymbol is KSClassDeclaration) {
validateClass(classSymbol)
}
}
return emptyList()
}

private fun validateClass(classSymbol: KSClassDeclaration) {
val constructors = classSymbol.getConstructors()
val hasDefaultConstructor = constructors.any { constructor ->
constructor.parameters.isEmpty() || constructor.parameters.all { it.hasDefault }
}
if (!hasDefaultConstructor) {
val message =
"${classSymbol.simpleName.asString()} must have a no-arg constructor or " +
"all parameters must have default values"
logger.error(message)
}
}
}

class AutoRegisterProcessorProvider : SymbolProcessorProvider {

override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor {
return AutoRegisterProcessor(environment.logger)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
com.github.shu.AutoRegisterProcessorProvider
2 changes: 2 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ pluginManagement {
name = "Fabric"
}
gradlePluginPortal()
google()
}
}
include("processor")
79 changes: 3 additions & 76 deletions src/main/java/anticope/rejects/MeteorRejectsAddon.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package anticope.rejects;

import anticope.rejects.commands.*;
import anticope.rejects.gui.hud.RadarHud;
import anticope.rejects.gui.themes.rounded.MeteorRoundedGuiTheme;
import anticope.rejects.modules.*;
import anticope.rejects.utils.MeteorManagerKt;
import meteordevelopment.meteorclient.addons.GithubRepo;
import meteordevelopment.meteorclient.addons.MeteorAddon;
import meteordevelopment.meteorclient.commands.Commands;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.systems.Systems;
import meteordevelopment.meteorclient.systems.hud.Hud;
Expand All @@ -28,81 +26,10 @@ public void onInitialize() {
LOG.info("Initializing Meteor Rejects Addon");

// Modules
Modules modules = Modules.get();
modules.add(new AimAssist());
modules.add(new AntiBot());
modules.add(new AntiCrash());
modules.add(new AntiSpawnpoint());
modules.add(new AntiVanish());
modules.add(new ArrowDmg());
modules.add(new AutoBedTrap());
modules.add(new AutoCraft());
modules.add(new AutoExtinguish());
modules.add(new AutoFarm());
modules.add(new AutoGrind());
modules.add(new AutoLogin());
modules.add(new AutoPot());
modules.add(new AutoSoup());
modules.add(new AutoTNT());
modules.add(new AutoWither());
modules.add(new BoatGlitch());
modules.add(new BlockIn());
modules.add(new BoatPhase());
modules.add(new Boost());
modules.add(new BungeeCordSpoof());
modules.add(new ChatBot());
modules.add(new ChestAura());
modules.add(new ChorusExploit());
modules.add(new ColorSigns());
modules.add(new Confuse());
modules.add(new CoordLogger());
modules.add(new CustomPackets());
modules.add(new ExtraElytra());
modules.add(new FullFlight());
modules.add(new GamemodeNotifier());
modules.add(new GhostMode());
modules.add(new Glide());
modules.add(new ItemGenerator());
modules.add(new InteractionMenu());
modules.add(new Jetpack());
modules.add(new KnockbackPlus());
modules.add(new LawnBot());
modules.add(new Lavacast());
modules.add(new MossBot());
modules.add(new NewChunks());
modules.add(new NoJumpDelay());
modules.add(new ObsidianFarm());
modules.add(new OreSim());
modules.add(new PacketFly());
modules.add(new Painter());
modules.add(new Rendering());
modules.add(new RoboWalk());
modules.add(new ShieldBypass());
modules.add(new SilentDisconnect());
modules.add(new SkeletonESP());
modules.add(new SoundLocator());
modules.add(new TreeAura());
modules.add(new VehicleOneHit());
modules.add(new AutoEnchant());
modules.add(new AutoRename());
MeteorManagerKt.moduleRegister("anticope.rejects.modules");

// Commands
Commands.add(new CenterCommand());
Commands.add(new ClearChatCommand());
Commands.add(new GhostCommand());
Commands.add(new GiveCommand());
Commands.add(new HeadsCommand());
Commands.add(new KickCommand());
Commands.add(new LocateCommand());
Commands.add(new PanicCommand());
Commands.add(new ReconnectCommand());
Commands.add(new ServerCommand());
Commands.add(new SaveSkinCommand());
Commands.add(new SeedCommand());
Commands.add(new SetBlockCommand());
Commands.add(new SetVelocityCommand());
Commands.add(new TeleportCommand());
Commands.add(new TerrainExport());
MeteorManagerKt.commandRegister("anticope.rejects.commands");

// HUD
Hud hud = Systems.get(Hud.class);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/CenterCommand.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
import net.minecraft.command.CommandSource;
import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket;
import net.minecraft.util.math.MathHelper;

@AutoRegister
public class CenterCommand extends Command {
public CenterCommand() {
super("center", "Centers the player on a block.");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/ClearChatCommand.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
import net.minecraft.command.CommandSource;

@AutoRegister
public class ClearChatCommand extends Command {
public ClearChatCommand() {
super("clear-chat", "Clears your chat.", "clear", "cls");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/GhostCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
Expand All @@ -9,6 +10,7 @@
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;

@AutoRegister
public class GhostCommand extends Command {
public GhostCommand() {
super("ghost", "Remove ghost blocks & bypass AntiXray", "aax", "anti-anti-xray");
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/GiveCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import anticope.rejects.arguments.EnumStringArgumentType;
import anticope.rejects.utils.GiveUtils;
import com.mojang.authlib.GameProfile;
Expand All @@ -25,6 +26,7 @@

import static anticope.rejects.utils.accounts.GetPlayerUUID.getUUID;

@AutoRegister
public class GiveCommand extends Command {

private final Collection<String> PRESETS = GiveUtils.PRESETS.keySet();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/HeadsCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import anticope.rejects.gui.screens.HeadScreen;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.gui.GuiThemes;
import meteordevelopment.meteorclient.utils.Utils;
import net.minecraft.command.CommandSource;

@AutoRegister
public class HeadsCommand extends Command {

public HeadsCommand() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/KickCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.utils.player.ChatUtils;
Expand All @@ -11,6 +12,7 @@
import net.minecraft.text.Text;
import org.apache.commons.lang3.SystemUtils;

@AutoRegister
public class KickCommand extends Command {

public KickCommand() {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/LocateCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import anticope.rejects.arguments.EnumArgumentType;
import anticope.rejects.utils.WorldGenUtils;
import anticope.rejects.utils.seeds.Seeds;
Expand All @@ -19,6 +20,7 @@
import cubitect.Cubiomes;
import cubitect.Cubiomes.Pos;

@AutoRegister
public class LocateCommand extends Command {

private final static DynamicCommandExceptionType NOT_FOUND = new DynamicCommandExceptionType(o -> {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/anticope/rejects/commands/PanicCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package anticope.rejects.commands;

import anticope.rejects.annotation.AutoRegister;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import meteordevelopment.meteorclient.commands.Command;
import meteordevelopment.meteorclient.systems.modules.Module;
Expand All @@ -8,6 +9,7 @@

import java.util.ArrayList;

@AutoRegister
public class PanicCommand extends Command {
public PanicCommand() {
super("panic", "Disables all modules.", "disable-all");
Expand Down
Loading

0 comments on commit b5ad781

Please sign in to comment.