Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# TODO
* Find a way to bypass the xaeros packets to enable entity radar.
* Make a proper emc api library.
* Improve performance and try to decrease jar size.
* Improve performance and try to decrease jar size.
* Improve testing.
121 changes: 90 additions & 31 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "2.2.10"
id("fabric-loom") version "1.11-SNAPSHOT"
id("maven-publish")
kotlin("plugin.serialization") version "1.9.10"
id("com.github.johnrengelman.shadow") version "8.1.1"

}

version = project.property("mod_version") as String
Expand All @@ -18,9 +19,6 @@ base {
val targetJavaVersion = 21
java {
toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}

Expand All @@ -32,11 +30,6 @@ fabricApi {
}

repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
maven ("https://maven.terraformersmc.com/") {
name = "Terraformers"
}
Expand All @@ -45,6 +38,7 @@ repositories {
}
maven("https://maven.shedaniel.me/")
maven("https://maven.isxander.dev/releases")
maven("https://jitpack.io")
exclusiveContent {
forRepository {
maven("https://api.modrinth.com/maven")
Expand All @@ -56,31 +50,54 @@ repositories {

}

val shade: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
isVisible = false
}

val mcVer = project.property("minecraft_version")
val mappings = project.property("yarn_mappings")

val fabricVersion = project.property("fabric_version")
val fabricLoader = project.property("loader_version")
val kotlinLoader = project.property("kotlin_loader_version")
val ktSere = project.property("kt_sere")

val xaerosVersion = project.property("xaeros_version")
val clothVersion = project.property("cloth_config")
val modmenu = project.property("modmenu")
val placeholderVersion = project.property("placeholder_api")

dependencies {
minecraft("com.mojang:minecraft:${project.property("minecraft_version")}")
mappings("net.fabricmc:yarn:${project.property("yarn_mappings")}:v2")
minecraft("com.mojang:minecraft:$mcVer")
mappings("net.fabricmc:yarn:$mappings:v2")

compileOnly("org.jetbrains.kotlin:kotlin-stdlib")
compileOnly("org.jetbrains.kotlin:kotlin-reflect")

compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3")
compileOnly("org.jetbrains.kotlinx:kotlinx-serialization-json:$ktSere")

modImplementation("net.fabricmc:fabric-loader:${project.property("loader_version")}")
modImplementation("net.fabricmc:fabric-language-kotlin:${project.property("kotlin_loader_version")}")
modImplementation("net.fabricmc:fabric-loader:$fabricLoader")
modImplementation("net.fabricmc.fabric-api:fabric-api:$fabricVersion")

modImplementation("net.fabricmc.fabric-api:fabric-api:${project.property("fabric_version")}")
modImplementation("net.fabricmc:fabric-language-kotlin:$kotlinLoader")

modImplementation("eu.pb4:placeholder-api:${project.property("placeholder_api")}")
modImplementation("eu.pb4:placeholder-api:$placeholderVersion")

modApi("me.shedaniel.cloth:cloth-config-fabric:${project.property("cloth_config")}") {
modApi("me.shedaniel.cloth:cloth-config-fabric:$clothVersion") {
exclude("net.fabricmc.fabric-api")
}

modApi("com.terraformersmc:modmenu:${project.property("modmenu")}")
modApi("com.terraformersmc:modmenu:$modmenu")

implementation("com.github.breakthebot:breakthelibrary:1.0.4")
shade("com.github.breakthebot:breakthelibrary:1.0.4") {
isTransitive = false
}

modImplementation("maven.modrinth:xaeros-minimap:${project.property("xaeros_version")}")

testImplementation(kotlin("test"))
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
}

tasks.processResources {
Expand All @@ -92,22 +109,68 @@ tasks.processResources {
filesMatching("fabric.mod.json") {
expand(
"version" to project.version,
"minecraft_version" to project.property("minecraft_version"),
"loader_version" to project.property("loader_version"),
"kotlin_loader_version" to project.property("kotlin_loader_version")
"minecraft_version" to mcVer,
"loader_version" to fabricLoader,
"kotlin_loader_version" to kotlinLoader,
"cloth_config" to clothVersion,
"placeholder_api" to placeholderVersion,
"modmenu" to modmenu
)
}
}

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"
options.release.set(targetJavaVersion)
}

val headerText = file("header.txt").readText()

val addHeader by tasks.registering {
group = "build"

val targetFiles = fileTree("src") {
include("**/*.kt")
include("**/*.java")
}

doLast {
targetFiles.forEach { file: File ->
val content = file.readText()
if (!content.startsWith(headerText)) {
file.writeText("$headerText\n$content")
}
}
}
}

tasks.shadowJar {
dependsOn(tasks.jar)

archiveClassifier.set("shadow-dev")

configurations = listOf(shade)

from(zipTree(tasks.jar.get().archiveFile))

relocate(
"org.breakthebot.breakthelibrary",
"net.chariskar.breakthebot.breakthelibrary"
)
}

val remapShadowJar by tasks.registering(net.fabricmc.loom.task.RemapJarTask::class) {
dependsOn(tasks.shadowJar)
inputFile.set(tasks.shadowJar.get().archiveFile)
archiveClassifier.set("shadowed")

doLast {
delete(tasks.shadowJar.get().archiveFile.get().asFile)
}
}

tasks["build"].dependsOn(addHeader, remapShadowJar)

tasks.withType<KotlinCompile>().configureEach {
compilerOptions.jvmTarget.set(JvmTarget.fromTarget(targetJavaVersion.toString()))
}
Expand All @@ -118,10 +181,6 @@ tasks.jar {
}
}

tasks.test {
useJUnitPlatform()
}

kotlin {
compilerOptions {
allWarningsAsErrors.set(true)
Expand Down
3 changes: 2 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ fabric_version=0.136.0+1.21.8
xaeros_version=25.2.16_Fabric_1.21.8
placeholder_api=2.7.2+1.21.8
cloth_config=19.0.147
modmenu=15.0.0
modmenu=15.0.0
kt_sere = 1.6.3
10 changes: 0 additions & 10 deletions ...r/breakthemod/client/objects/Reference.kt → header.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,3 @@
* You should have received a copy of the GNU General Public License
* along with breakthemod. If not, see <https://www.gnu.org/licenses/>.
*/
package net.chariskar.breakthemod.client.objects

import kotlinx.serialization.Serializable
import net.chariskar.breakthemod.client.utils.serialization.SerializableUUID

@Serializable
data class Reference(
val uuid: SerializableUUID?,
val name: String?
)
19 changes: 12 additions & 7 deletions proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
-dontnote
-dontoptimize

-injars build/libs/breakthemod-1.4.3.jar
-injars build/libs/breakthemod-1.4.5-shadowed.jar
-outjars build/libs/btm-obf.jar

-libraryjars <java.home>/jmods/
Expand All @@ -14,16 +14,21 @@

-keep public class net.chariskar.breakthemod.Breakthemod { *; }

-keep class net.chariskar.breakthemod.client.commands.** implements net.chariskar.breakthemod.client.api.* { *; }
-keep class * implements net.fabricmc.api.ClientModInitializer { *; }
-keep public class net.chariskar.breakthemod.client.api.** { *; }
-keep public class net.chariskar.breakthemod.client.hooks.** { *; }
-keep class net.chariskar.breakthemod.client.commands.** implements net.chariskar.breakthemod.client.api.BaseCommand { *; }

# -keep public class net.chariskar.breakthemod.Breakthemod implements net.fabricmc.api.ClientModInitializer { *; }

-keep public class net.chariskar.breakthebot.breakthelibrary.models.** { *; }

-keep class net.chariskar.breakthemod.client.utils.** { *; }
-keep public class net.chariskar.breakthemod.mixins.** { *; }

-keepclassmembers class kotlin.Metadata { *; }
-keepattributes RuntimeVisibleAnnotations,RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleAnnotations,
RuntimeInvisibleAnnotations,
Signature,
InnerClasses,
EnclosingMethod,
Exceptions

-keepdirectories META-INF/**
-keepdirectories resources/**
17 changes: 17 additions & 0 deletions src/main/java/net/chariskar/breakthemod/mixins/EntityRadar.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* This file is part of breakthemod.
*
* breakthemod is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* breakthemod is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with breakthemod. If not, see <https://www.gnu.org/licenses/>.
*/

package net.chariskar.breakthemod.mixins;


Expand Down
17 changes: 17 additions & 0 deletions src/main/java/net/chariskar/breakthemod/mixins/FairPlay.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* This file is part of breakthemod.
*
* breakthemod is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* breakthemod is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with breakthemod. If not, see <https://www.gnu.org/licenses/>.
*/

package net.chariskar.breakthemod.mixins;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
/*
* This file is part of breakthemod.
*
* breakthemod is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* breakthemod is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with breakthemod. If not, see <https://www.gnu.org/licenses/>.
*/

package net.chariskar.breakthemod.mixins;

import org.spongepowered.asm.mixin.Mixin;
Expand Down
34 changes: 17 additions & 17 deletions src/main/kotlin/net/chariskar/breakthemod/Breakthemod.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@
*/
package net.chariskar.breakthemod

import net.chariskar.breakthemod.client.api.Command
import net.chariskar.breakthemod.client.api.BaseCommand
import net.chariskar.breakthemod.client.api.engine.NearbyEngine
import net.chariskar.breakthemod.client.commands.Debug
import net.chariskar.breakthemod.client.commands.discordId
import net.chariskar.breakthemod.client.commands.DiscordId
import net.chariskar.breakthemod.client.commands.FindPlayer
import net.chariskar.breakthemod.client.commands.goto
import net.chariskar.breakthemod.client.commands.help
import net.chariskar.breakthemod.client.commands.lastSeen
import net.chariskar.breakthemod.client.commands.locate
import net.chariskar.breakthemod.client.commands.nearby
import net.chariskar.breakthemod.client.commands.onlineStaff
import net.chariskar.breakthemod.client.commands.townless
import net.chariskar.breakthemod.client.commands.Help
import net.chariskar.breakthemod.client.commands.LastSeen
import net.chariskar.breakthemod.client.commands.Locate
import net.chariskar.breakthemod.client.commands.Nearby
import net.chariskar.breakthemod.client.commands.OnlineStaff
import net.chariskar.breakthemod.client.commands.Townless
import net.chariskar.breakthemod.client.hooks.nearby.Hud
import net.chariskar.breakthemod.client.utils.Config
import net.fabricmc.api.ClientModInitializer
Expand All @@ -43,7 +43,7 @@ import com.mojang.brigadier.CommandDispatcher
class Breakthemod : ClientModInitializer {
val nearbyLayer: Identifier = Identifier.of("breakthemod", "nearby_layer")

private fun loadCommands(commands: MutableList<Command>) {
private fun loadCommands(commands: MutableList<BaseCommand>) {
ClientCommandRegistrationCallback.EVENT.register(ClientCommandRegistrationCallback { dispatcher: CommandDispatcher<FabricClientCommandSource>, _: CommandRegistryAccess ->
for (command in commands) {
command.register(dispatcher)
Expand All @@ -53,16 +53,16 @@ class Breakthemod : ClientModInitializer {

override fun onInitializeClient() {
Config.loadConfig()
val helpCmd = help()
val commandList: MutableList<Command> = mutableListOf(
nearby(),
onlineStaff(),
townless(),
val helpCmd = Help()
val commandList: MutableList<BaseCommand> = mutableListOf(
Nearby(),
OnlineStaff(),
Townless(),
goto(),
FindPlayer(),
lastSeen(),
discordId(),
locate(),
LastSeen(),
DiscordId(),
Locate(),
Debug(),
helpCmd
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ private object CommandScope {
}
}

abstract class Command {
abstract class BaseCommand {
val logger: Logger = LoggerFactory.getLogger("breakthemod")
val fetch: Fetch = Fetch
val client: MinecraftClient = MinecraftClient.getInstance()
protected val scope = CommandScope.scope

Expand Down
Loading