From 717e928db851baf7e21136a643385796fb7f7e36 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sat, 11 May 2024 16:30:14 -0400 Subject: [PATCH 01/51] make mixins abstract less constructors = smaller lol --- .../java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java | 2 +- .../main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java | 2 +- .../java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java | 2 +- .../main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java | 2 +- .../java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java | 2 +- .../main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java | 2 +- .../java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java | 2 +- .../src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java | 2 +- .../java/dev/nolij/zume/mixin/modern/GameRendererMixin.java | 2 +- .../src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java | 2 +- .../java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java | 2 +- .../java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java | 2 +- .../java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java | 2 +- 13 files changed, 13 insertions(+), 13 deletions(-) diff --git a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java index e0d3c483..6d62a1e5 100644 --- a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(EntityRenderer.class) -public class EntityRendererMixin { +public abstract class EntityRendererMixin { @Inject(method = "updateCameraAndRender", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { diff --git a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java index dc7ed09e..c385ca14 100644 --- a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(value = Camera.class, priority = 1500) -public class CameraMixin { +public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { diff --git a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java index 2558944e..d1ffa47b 100644 --- a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(MouseHandler.class) -public class MouseHandlerMixin { +public abstract class MouseHandlerMixin { @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(Options instance) { diff --git a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java index d0c1d694..1a1c7906 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(value = Camera.class, priority = 1500) -public class CameraMixin { +public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { diff --git a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java index 0ffdab2a..95378d89 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(MouseHandler.class) -public class MouseHandlerMixin { +public abstract class MouseHandlerMixin { @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(Options instance) { diff --git a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java index 1b09ea0c..53d49a33 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(value = Camera.class, priority = 1500) -public class CameraMixin { +public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { diff --git a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java index 8125f4a6..27e623ef 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.Redirect; @Mixin(MouseHandler.class) -public class MouseHandlerMixin { +public abstract class MouseHandlerMixin { @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(Options instance) { diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java index 378b20f4..1277b0ae 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java @@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg; @Mixin(value = Camera.class, priority = 1500) -public class CameraMixin { +public abstract class CameraMixin { @ModifyArg(method = "update", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/Camera;clipToSpace(D)D")) public double zume$update$clipToSpace(double original) { diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java index eca44759..3d8440ed 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java @@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(GameRenderer.class) -public class GameRendererMixin { +public abstract class GameRendererMixin { @Inject(method = "render", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java index a203452f..46cac2ad 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java @@ -11,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.Group; @Mixin(value = Mouse.class, priority = 500) -public class MouseMixin { +public abstract class MouseMixin { @Dynamic @ModifyExpressionValue(method = { diff --git a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java index 7df7c8e8..8f2abe25 100644 --- a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java @@ -10,7 +10,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(class_555.class) -public class GameRendererMixin { +public abstract class GameRendererMixin { @Inject(method = "method_1844", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { diff --git a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java index ae827d93..c6410e89 100644 --- a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(value = Minecraft.class, priority = 500) -public class MinecraftMixin { +public abstract class MinecraftMixin { @WrapWithCondition(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;method_692(I)V")) public boolean onMouseScroll$scrollInHotbar(PlayerInventory instance, int scrollAmount) { diff --git a/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java index 0b062fc7..341a56de 100644 --- a/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java +++ b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java @@ -8,7 +8,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; @Mixin(EntityRenderer.class) -public class EntityRendererMixin { +public abstract class EntityRendererMixin { @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) From 3a3ca29ff16bbd7decaa29b67e6292cfd5de84fe Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sat, 11 May 2024 20:43:58 -0400 Subject: [PATCH 02/51] remove refmap --- archaic/build.gradle.kts | 1 + build.gradle.kts | 48 +++++++++++------- .../MixinConfigMergingTransformer.kt | 50 +++++++++++-------- legacy/build.gradle.kts | 14 +++--- modern/build.gradle.kts | 8 +++ primitive/build.gradle.kts | 1 + vintage/build.gradle.kts | 1 + 7 files changed, 77 insertions(+), 46 deletions(-) diff --git a/archaic/build.gradle.kts b/archaic/build.gradle.kts index 25163ed0..39de4748 100644 --- a/archaic/build.gradle.kts +++ b/archaic/build.gradle.kts @@ -19,6 +19,7 @@ unimined.minecraft { tasks.withType { mixinRemap { enableMixinExtra() + disableRefmap() } } diff --git a/build.gradle.kts b/build.gradle.kts index 549a8ef1..e0fc9491 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -15,11 +15,13 @@ import okhttp3.MultipartBody import okhttp3.Request import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.internal.immutableListOf +import org.ajoberstar.grgit.Tag import org.objectweb.asm.ClassReader import org.objectweb.asm.ClassWriter import org.objectweb.asm.tree.ClassNode import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask import xyz.wagyourtail.unimined.api.unimined +import xyz.wagyourtail.unimined.internal.mapping.extension.MixinRemapExtension import java.nio.file.Files import java.time.ZonedDateTime @@ -245,6 +247,14 @@ subprojects { defaultRemapJar = true } } + + if(implName in lexForgeImpls) { + tasks.withType { + mixinRemap { + disableRefmap() + } + } + } } unimined.minecraft { @@ -343,25 +353,21 @@ tasks.shadowJar { from(zipTree(remapJar.archiveFile.get())) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE exclude("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "pack.mcmeta") + + filesMatching("**/*.class") { + val reader = ClassReader(this.open()) + val node = ClassNode() + reader.accept(node, 0) + + node.visibleAnnotations?.removeIf { it.desc == "Lnet/minecraftforge/fml/common/Mod;" } + + val writer = ClassWriter(0) + node.accept(writer) + this.file.writeBytes(writer.toByteArray()) + } } } - filesMatching(immutableListOf( - "dev/nolij/zume/lexforge/LexZume.class", - "dev/nolij/zume/lexforge18/LexZume18.class", - "dev/nolij/zume/lexforge16/LexZume16.class", - "dev/nolij/zume/vintage/VintageZume.class")) { - val reader = ClassReader(this.open()) - val node = ClassNode() - reader.accept(node, 0) - - node.visibleAnnotations.removeIf { it.desc == "Lnet/minecraftforge/fml/common/Mod;" } - - val writer = ClassWriter(0) - node.accept(writer) - this.file.writeBytes(writer.toByteArray()) - } - relocate("blue.endless.jankson", "dev.nolij.zume.shadow.blue.endless.jankson") manifest { @@ -393,6 +399,14 @@ tasks.assemble { dependsOn(compressJar, sourcesJar) } +//tasks.register("cleassemble") { +// group = "build" +// doLast { +// //run clean THEN assemble +// tasks.clean.get(). +// } +//} + afterEvaluate { publishing { repositories { @@ -524,7 +538,7 @@ afterEvaluate { doLast { val http = HttpUtils() - val currentTag = releaseTags.getOrNull(0) + val currentTag: Tag? = releaseTags.getOrNull(0) val buildChangeLog = grgit.log { if (currentTag != null) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt index e3484191..f96b4c0e 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt @@ -56,32 +56,38 @@ class MixinConfigMergingTransformer : Transformer { override fun modifyOutputStream(os: ZipOutputStream?, preserveFileTimestamps: Boolean) { val mixinConfigEntry = ZipEntry("${modId}.mixins.json") os!!.putNextEntry(mixinConfigEntry) - os.write( - JsonOutput.prettyPrint( - JsonOutput.toJson(mapOf( - "required" to true, - "minVersion" to "0.8", - "package" to packageName, - "plugin" to mixinPlugin, - "compatibilityLevel" to "JAVA_8", - "client" to mixins, - "injectors" to mapOf( - "defaultRequire" to 1, - ), - "refmap" to "${modId}-refmap.json", - ))).toByteArray()) + + val mixinConfigJson = mutableMapOf( + "required" to true, + "minVersion" to "0.8", + "package" to packageName, + "plugin" to mixinPlugin, + "compatibilityLevel" to "JAVA_8", + "client" to mixins, + "injectors" to mapOf( + "defaultRequire" to 1, + ) + ) + + if(refMaps.isNotEmpty()) { + val refmapName = "${modId}-refmap.json" + mixinConfigJson["refmap"] = refmapName + os.putNextEntry(ZipEntry(refmapName)) + os.write( + JsonOutput.prettyPrint( + JsonOutput.toJson( + mapOf( + "mappings" to refMaps, + ) + ) + ).toByteArray() + ) + } - val refMapEntry = ZipEntry("${modId}-refmap.json") - os.putNextEntry(refMapEntry) - os.write( - JsonOutput.prettyPrint( - JsonOutput.toJson(mapOf( - "mappings" to refMaps, - ))).toByteArray()) + os.write(JsonOutput.prettyPrint(JsonOutput.toJson(mixinConfigJson)).toByteArray()) transformed = false mixins.clear() refMaps.clear() } - } \ No newline at end of file diff --git a/legacy/build.gradle.kts b/legacy/build.gradle.kts index 86b2febb..7eb9c19c 100644 --- a/legacy/build.gradle.kts +++ b/legacy/build.gradle.kts @@ -1,13 +1,9 @@ +import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask + operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") unimined.minecraft { version("legacy_minecraft_version"()) - - runs { - config("server") { - disabled = true - } - } fabric { loader("fabric_version"()) @@ -17,8 +13,12 @@ unimined.minecraft { legacyIntermediary() legacyYarn("legacy_mappings_version"()) } +} - defaultRemapJar = true +tasks.withType { + mixinRemap { + disableRefmap() + } } dependencies { diff --git a/modern/build.gradle.kts b/modern/build.gradle.kts index 8093f7f6..0be31014 100644 --- a/modern/build.gradle.kts +++ b/modern/build.gradle.kts @@ -1,3 +1,5 @@ +import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask + operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") unimined.minecraft { @@ -14,6 +16,12 @@ unimined.minecraft { } } +tasks.withType { + mixinRemap { + disableRefmap() + } +} + repositories { maven("https://maven.terraformersmc.com/releases/") } diff --git a/primitive/build.gradle.kts b/primitive/build.gradle.kts index 85574fa4..82808627 100644 --- a/primitive/build.gradle.kts +++ b/primitive/build.gradle.kts @@ -25,6 +25,7 @@ unimined.minecraft { tasks.withType { mixinRemap { enableMixinExtra() + disableRefmap() } } diff --git a/vintage/build.gradle.kts b/vintage/build.gradle.kts index 1d92e7de..1e790abb 100644 --- a/vintage/build.gradle.kts +++ b/vintage/build.gradle.kts @@ -23,6 +23,7 @@ unimined.minecraft { tasks.withType { mixinRemap { enableMixinExtra() + disableRefmap() } } From 330ef30723622f56006aebe964803edacdad032c Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sat, 11 May 2024 22:23:23 -0400 Subject: [PATCH 03/51] yes --- settings.gradle.kts | 1 + zson/build.gradle.kts | 5 ++ .../main/java/dev/nolij/zson/JsonElement.java | 68 +++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 zson/build.gradle.kts create mode 100644 zson/src/main/java/dev/nolij/zson/JsonElement.java diff --git a/settings.gradle.kts b/settings.gradle.kts index f70d74e8..7a2182c2 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,6 +12,7 @@ rootProject.name = "zume" include("stubs") include("api") +include("zson") include("modern") include("legacy") include("primitive") diff --git a/zson/build.gradle.kts b/zson/build.gradle.kts new file mode 100644 index 00000000..91cd6545 --- /dev/null +++ b/zson/build.gradle.kts @@ -0,0 +1,5 @@ +operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") + +dependencies { + implementation(project(":api")) +} \ No newline at end of file diff --git a/zson/src/main/java/dev/nolij/zson/JsonElement.java b/zson/src/main/java/dev/nolij/zson/JsonElement.java new file mode 100644 index 00000000..67698db5 --- /dev/null +++ b/zson/src/main/java/dev/nolij/zson/JsonElement.java @@ -0,0 +1,68 @@ +package dev.nolij.zson; + +public class JsonElement { + public final String key; + + // 0/1 if boolean, value if number + private double value; + + // true = floating point, false = non-floating point, null = boolean + private final Boolean type; + + private JsonElement(String key, double value, Boolean type) { + this.key = key; + this.value = value; + this.type = type; + } + + public static JsonElement doubleElement(String key, double value) { + return new JsonElement(key, value, true); + } + + public static JsonElement intElement(String key, int value) { + return new JsonElement(key, value, false); + } + + public static JsonElement booleanElement(String key, boolean value) { + return new JsonElement(key, value ? 1 : 0, null); + } + + public String toString() { + return key + ": " + (type == null ? + value == 1 ? "true" : "false" + : type ? value : (int) value); + } + + public int getAsInt() { + if(!isInt()) { + throw new IllegalStateException("Element is not an integer"); + } + return (int) value; + } + + public double getAsDouble() { + if(!isDouble()) { + throw new IllegalStateException("Element is not a double"); + } + return value; + } + + public boolean getAsBoolean() { + if(!isBoolean()) { + throw new IllegalStateException("Element is not a boolean"); + } + return value == 1; + } + + public boolean isInt() { + return Boolean.FALSE.equals(type); + } + + public boolean isDouble() { + return Boolean.TRUE.equals(type); + } + + public boolean isBoolean() { + return type == null; + } +} From edec9e8019c041e5a22125533e3828411ac0c7b7 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sat, 11 May 2024 23:05:42 -0400 Subject: [PATCH 04/51] no way zson writing --- zson/build.gradle.kts | 11 +++ .../main/java/dev/nolij/zson/JsonElement.java | 68 ------------------- zson/src/main/java/dev/nolij/zson/Zson.java | 63 +++++++++++++++++ zson/src/test/java/Main.java | 29 ++++++++ 4 files changed, 103 insertions(+), 68 deletions(-) delete mode 100644 zson/src/main/java/dev/nolij/zson/JsonElement.java create mode 100644 zson/src/main/java/dev/nolij/zson/Zson.java create mode 100644 zson/src/test/java/Main.java diff --git a/zson/build.gradle.kts b/zson/build.gradle.kts index 91cd6545..1f75c846 100644 --- a/zson/build.gradle.kts +++ b/zson/build.gradle.kts @@ -2,4 +2,15 @@ operator fun String.invoke(): String = rootProject.properties[this] as? String ? dependencies { implementation(project(":api")) +} + +java { + toolchain { + languageVersion.set(JavaLanguageVersion.of(17)) + } +} + +tasks.register("testRun") { + mainClass = "Main" + classpath(sourceSets["test"].runtimeClasspath) } \ No newline at end of file diff --git a/zson/src/main/java/dev/nolij/zson/JsonElement.java b/zson/src/main/java/dev/nolij/zson/JsonElement.java deleted file mode 100644 index 67698db5..00000000 --- a/zson/src/main/java/dev/nolij/zson/JsonElement.java +++ /dev/null @@ -1,68 +0,0 @@ -package dev.nolij.zson; - -public class JsonElement { - public final String key; - - // 0/1 if boolean, value if number - private double value; - - // true = floating point, false = non-floating point, null = boolean - private final Boolean type; - - private JsonElement(String key, double value, Boolean type) { - this.key = key; - this.value = value; - this.type = type; - } - - public static JsonElement doubleElement(String key, double value) { - return new JsonElement(key, value, true); - } - - public static JsonElement intElement(String key, int value) { - return new JsonElement(key, value, false); - } - - public static JsonElement booleanElement(String key, boolean value) { - return new JsonElement(key, value ? 1 : 0, null); - } - - public String toString() { - return key + ": " + (type == null ? - value == 1 ? "true" : "false" - : type ? value : (int) value); - } - - public int getAsInt() { - if(!isInt()) { - throw new IllegalStateException("Element is not an integer"); - } - return (int) value; - } - - public double getAsDouble() { - if(!isDouble()) { - throw new IllegalStateException("Element is not a double"); - } - return value; - } - - public boolean getAsBoolean() { - if(!isBoolean()) { - throw new IllegalStateException("Element is not a boolean"); - } - return value == 1; - } - - public boolean isInt() { - return Boolean.FALSE.equals(type); - } - - public boolean isDouble() { - return Boolean.TRUE.equals(type); - } - - public boolean isBoolean() { - return type == null; - } -} diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java new file mode 100644 index 00000000..016b2602 --- /dev/null +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -0,0 +1,63 @@ +package dev.nolij.zson; + +import java.util.AbstractMap; +import java.util.Map; + +public final class Zson { + public String indent; + + public Zson(String indent) { + this.indent = indent; + } + + public Map, Object> parse(String json) { + throw new UnsupportedOperationException("Not implemented yet"); + } + + public String stringify(Map, Object> zson) { + StringBuilder sb = new StringBuilder("{\n"); + + for (Map.Entry, Object> entry : zson.entrySet()) { + Map.Entry keyPair = entry.getKey(); + String key = keyPair.getKey(); + String comment = keyPair.getValue(); + Object value = entry.getValue(); + + if (!comment.isEmpty()) { + writeComment(sb, comment); + } + + sb.append(indent).append(key).append(": "); + if (value instanceof Map) { + //noinspection unchecked + String inner = stringify((Map, Object>) value); + sb.append(inner.replace("\n", "\n" + indent)); + } else { + sb.append(value(value)); + } + + sb.append(",\n"); + } + + return sb.append("}").toString(); + } + + private void writeComment(StringBuilder sb, String comment) { + String[] lines = comment.split("\n"); + for (String line : lines) { + sb.append(indent).append("// ").append(line).append("\n"); + } + } + + private String value(Object value) { + if (value instanceof String) { + return "\"" + ((String) value).replace("\"", "\\\"") + "\""; + } else { + return String.valueOf(value); + } + } + + public static Map.Entry key(String key, String comment) { + return new AbstractMap.SimpleEntry<>(key, comment); + } +} diff --git a/zson/src/test/java/Main.java b/zson/src/test/java/Main.java new file mode 100644 index 00000000..31edb325 --- /dev/null +++ b/zson/src/test/java/Main.java @@ -0,0 +1,29 @@ +import dev.nolij.zson.Zson; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class Main { + public static void main(String[] args) { + Zson zson = new Zson(" "); + Map, Object> zsonMap = new LinkedHashMap<>(); + zsonMap.put(Zson.key("name", "The name of the person\nlook, a second line!"), "John Doe"); + zsonMap.put(Zson.key("age", "The age of the person"), 30); + zsonMap.put(Zson.key("address", "The address of the person"), map( + new Map.Entry[] {Zson.key("street", "The street of the address"), Zson.key("city", "The city of the address")}, + new Object[] {"1234 Elm St", "Springfield"} + )); + System.out.println(zson.stringify(zsonMap)); + } + + private static Map map(K[] keys, V[] values) { + if(keys.length != values.length) { + throw new IllegalArgumentException("Keys and values must have the same length"); + } + Map map = new LinkedHashMap<>(); + for (int i = 0; i < keys.length; i++) { + map.put(keys[i], values[i]); + } + return map; + } +} From 80e417cba73bf1d1ed38c17cffd970ffbd42cc2d Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sat, 11 May 2024 23:09:06 -0400 Subject: [PATCH 05/51] inline stuff [skip ci] --- zson/src/main/java/dev/nolij/zson/Zson.java | 28 ++++++++------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java index 016b2602..0bd88fa8 100644 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -24,32 +24,24 @@ public String stringify(Map, Object> zson) { Object value = entry.getValue(); if (!comment.isEmpty()) { - writeComment(sb, comment); + String[] lines = comment.split("\n"); + for (String line : lines) { + sb.append(indent).append("// ").append(line).append("\n"); + } } - sb.append(indent).append(key).append(": "); - if (value instanceof Map) { - //noinspection unchecked - String inner = stringify((Map, Object>) value); - sb.append(inner.replace("\n", "\n" + indent)); - } else { - sb.append(value(value)); - } - - sb.append(",\n"); + sb.append(indent).append(key).append(": ").append(value(value)).append(",\n"); } return sb.append("}").toString(); } - private void writeComment(StringBuilder sb, String comment) { - String[] lines = comment.split("\n"); - for (String line : lines) { - sb.append(indent).append("// ").append(line).append("\n"); - } - } - private String value(Object value) { + if(value instanceof Map) { + //noinspection unchecked + return stringify((Map, Object>) value) + .replace("\n", "\n" + indent); + } if (value instanceof String) { return "\"" + ((String) value).replace("\"", "\\\"") + "\""; } else { From 94db923df78adede42edb1d0fcbbcaabc217acce Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 12 May 2024 11:56:03 -0400 Subject: [PATCH 06/51] nicer error handling [skip ci] --- zson/src/main/java/dev/nolij/zson/Zson.java | 15 ++++++++++----- zson/src/test/java/Main.java | 7 +++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java index 0bd88fa8..361ba1fe 100644 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -19,8 +19,7 @@ public String stringify(Map, Object> zson) { for (Map.Entry, Object> entry : zson.entrySet()) { Map.Entry keyPair = entry.getKey(); - String key = keyPair.getKey(); - String comment = keyPair.getValue(); + String key = keyPair.getKey(), comment = keyPair.getValue(); Object value = entry.getValue(); if (!comment.isEmpty()) { @@ -38,9 +37,15 @@ public String stringify(Map, Object> zson) { private String value(Object value) { if(value instanceof Map) { - //noinspection unchecked - return stringify((Map, Object>) value) - .replace("\n", "\n" + indent); + try { + //noinspection unchecked + return stringify((Map, Object>) value) + .replace("\n", "\n" + indent); + } catch (ClassCastException e) { + throw new IllegalArgumentException("Map must have keys of type Map.Entry", e); + } catch (StackOverflowError e) { + throw new StackOverflowError("Map is circular"); + } } if (value instanceof String) { return "\"" + ((String) value).replace("\"", "\\\"") + "\""; diff --git a/zson/src/test/java/Main.java b/zson/src/test/java/Main.java index 31edb325..4cf778c2 100644 --- a/zson/src/test/java/Main.java +++ b/zson/src/test/java/Main.java @@ -14,6 +14,13 @@ public static void main(String[] args) { new Object[] {"1234 Elm St", "Springfield"} )); System.out.println(zson.stringify(zsonMap)); + + Map, Object> map2 = new LinkedHashMap<>(); + Map, Object> map3 = new LinkedHashMap<>(); + map3.put(Zson.key("test", "a"), map2); + map2.put(Zson.key("test", "b"), map3); + + System.out.println(zson.stringify(map2)); } private static Map map(K[] keys, V[] values) { From 1e4a6c2d57820f61c002758eee4eb528989488ac Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 12 May 2024 13:17:19 -0400 Subject: [PATCH 07/51] add a ZsonMap class to avoid all the ugly generics stuff --- zson/build.gradle.kts | 10 ---- zson/src/main/java/dev/nolij/zson/Zson.java | 22 ++++----- .../src/main/java/dev/nolij/zson/ZsonMap.java | 27 +++++++++++ zson/src/test/java/Main.java | 48 +++++++++---------- 4 files changed, 61 insertions(+), 46 deletions(-) create mode 100644 zson/src/main/java/dev/nolij/zson/ZsonMap.java diff --git a/zson/build.gradle.kts b/zson/build.gradle.kts index 1f75c846..c7b9b686 100644 --- a/zson/build.gradle.kts +++ b/zson/build.gradle.kts @@ -1,15 +1,5 @@ operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") -dependencies { - implementation(project(":api")) -} - -java { - toolchain { - languageVersion.set(JavaLanguageVersion.of(17)) - } -} - tasks.register("testRun") { mainClass = "Main" classpath(sourceSets["test"].runtimeClasspath) diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java index 361ba1fe..de16649e 100644 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -10,14 +10,14 @@ public Zson(String indent) { this.indent = indent; } - public Map, Object> parse(String json) { + public ZsonMap parse(String json) { throw new UnsupportedOperationException("Not implemented yet"); } - public String stringify(Map, Object> zson) { + public String stringify(ZsonMap zson) { StringBuilder sb = new StringBuilder("{\n"); - for (Map.Entry, Object> entry : zson.entrySet()) { + for (var entry : zson.entrySet()) { Map.Entry keyPair = entry.getKey(); String key = keyPair.getKey(), comment = keyPair.getValue(); Object value = entry.getValue(); @@ -36,13 +36,9 @@ public String stringify(Map, Object> zson) { } private String value(Object value) { - if(value instanceof Map) { + if(value instanceof ZsonMap zson) { try { - //noinspection unchecked - return stringify((Map, Object>) value) - .replace("\n", "\n" + indent); - } catch (ClassCastException e) { - throw new IllegalArgumentException("Map must have keys of type Map.Entry", e); + return stringify(zson).replace("\n", "\n" + indent); } catch (StackOverflowError e) { throw new StackOverflowError("Map is circular"); } @@ -54,7 +50,11 @@ private String value(Object value) { } } - public static Map.Entry key(String key, String comment) { - return new AbstractMap.SimpleEntry<>(key, comment); + public static Map.Entry, Object> entry(String key, String comment, Object value) { + return new AbstractMap.SimpleEntry<>(new AbstractMap.SimpleEntry<>(key, comment), value); + } + + public static Map.Entry, Object> entry(String key, Object value) { + return entry(key, "", value); } } diff --git a/zson/src/main/java/dev/nolij/zson/ZsonMap.java b/zson/src/main/java/dev/nolij/zson/ZsonMap.java new file mode 100644 index 00000000..1ae3effc --- /dev/null +++ b/zson/src/main/java/dev/nolij/zson/ZsonMap.java @@ -0,0 +1,27 @@ +package dev.nolij.zson; + +import java.util.AbstractMap; +import java.util.LinkedHashMap; +import java.util.Map; + +public class ZsonMap extends LinkedHashMap, Object> { + public ZsonMap() { + super(); + } + + @SafeVarargs + public ZsonMap(Map.Entry, Object>... entries) { + super(entries.length); + for (var entry : entries) { + this.put(entry.getKey(), entry.getValue()); + } + } + + public Object put(String key, String comment, Object value) { + return this.put(new AbstractMap.SimpleEntry<>(key, comment), value); + } + + public Object put(String key, Object value) { + return this.put(new AbstractMap.SimpleEntry<>(key, ""), value); + } +} diff --git a/zson/src/test/java/Main.java b/zson/src/test/java/Main.java index 4cf778c2..8b7a0d50 100644 --- a/zson/src/test/java/Main.java +++ b/zson/src/test/java/Main.java @@ -1,36 +1,34 @@ import dev.nolij.zson.Zson; +import dev.nolij.zson.ZsonMap; -import java.util.LinkedHashMap; -import java.util.Map; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; public class Main { - public static void main(String[] args) { + public static void main(String[] args) throws Throwable { Zson zson = new Zson(" "); - Map, Object> zsonMap = new LinkedHashMap<>(); - zsonMap.put(Zson.key("name", "The name of the person\nlook, a second line!"), "John Doe"); - zsonMap.put(Zson.key("age", "The age of the person"), 30); - zsonMap.put(Zson.key("address", "The address of the person"), map( - new Map.Entry[] {Zson.key("street", "The street of the address"), Zson.key("city", "The city of the address")}, - new Object[] {"1234 Elm St", "Springfield"} + ZsonMap zsonMap = new ZsonMap(); + zsonMap.put("name", "The name of the person\nlook, a second line!", "John Doe"); + zsonMap.put("age", "The age of the person", 30); + zsonMap.put("address", "The address of the person", new ZsonMap( + Zson.entry("street", "The street of the address", "123 Main St"), + Zson.entry("city", "The city of the address", "Springfield"), + Zson.entry("state", "The state of the address", "IL"), + Zson.entry("zip", "The zip code of the address", 62701) )); - System.out.println(zson.stringify(zsonMap)); + zsonMap.put("phoneNumbers", "The phone numbers of the person", new ZsonMap( + Zson.entry("home", "217-555-1234"), + Zson.entry("cell", "217-555-5678") + )); + Files.write(Paths.get("person.json5"), zson.stringify(zsonMap).getBytes(StandardCharsets.UTF_8)); - Map, Object> map2 = new LinkedHashMap<>(); - Map, Object> map3 = new LinkedHashMap<>(); - map3.put(Zson.key("test", "a"), map2); - map2.put(Zson.key("test", "b"), map3); + ZsonMap map2 = new ZsonMap(); + ZsonMap map3 = new ZsonMap(); + map3.put("test", "a", map2); + map2.put("test", "b", map3); System.out.println(zson.stringify(map2)); } - - private static Map map(K[] keys, V[] values) { - if(keys.length != values.length) { - throw new IllegalArgumentException("Keys and values must have the same length"); - } - Map map = new LinkedHashMap<>(); - for (int i = 0; i < keys.length; i++) { - map.put(keys[i], values[i]); - } - return map; - } } From 64c72015646f385adb7cf99eb5724ded22325b46 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 12 May 2024 13:54:55 -0400 Subject: [PATCH 08/51] quote keys among other things [skip ci] --- build.gradle.kts | 5 ++- zson/src/main/java/dev/nolij/zson/Zson.java | 31 ++++++++++--------- .../src/main/java/dev/nolij/zson/ZsonMap.java | 9 +++--- zson/src/test/java/Main.java | 1 - 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index e0fc9491..6676fdce 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,6 @@ import org.objectweb.asm.ClassWriter import org.objectweb.asm.tree.ClassNode import xyz.wagyourtail.unimined.api.minecraft.task.RemapJarTask import xyz.wagyourtail.unimined.api.unimined -import xyz.wagyourtail.unimined.internal.mapping.extension.MixinRemapExtension import java.nio.file.Files import java.time.ZonedDateTime @@ -52,6 +51,8 @@ enum class ReleaseChannel( RELEASE(releaseType = ReleaseType.STABLE), } +//region Git Versioning + val headDateTime: ZonedDateTime = grgit.head().dateTime val branchName = grgit.branch.current().name!! @@ -123,6 +124,8 @@ if (releaseChannel.suffix != null) { } } +//endregion + Zume.version = "${minorVersion}.${patchAndSuffix}" println("Zume Version: ${Zume.version}") diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java index de16649e..4df50b8e 100644 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -22,32 +22,33 @@ public String stringify(ZsonMap zson) { String key = keyPair.getKey(), comment = keyPair.getValue(); Object value = entry.getValue(); - if (!comment.isEmpty()) { - String[] lines = comment.split("\n"); - for (String line : lines) { + if (comment != null && !comment.isEmpty()) { + for (String line : comment.split("\n")) { sb.append(indent).append("// ").append(line).append("\n"); } } - sb.append(indent).append(key).append(": ").append(value(value)).append(",\n"); + sb.append(indent).append('"').append(key).append("\": ").append(value(value)).append(",\n"); } return sb.append("}").toString(); } private String value(Object value) { - if(value instanceof ZsonMap zson) { - try { - return stringify(zson).replace("\n", "\n" + indent); - } catch (StackOverflowError e) { - throw new StackOverflowError("Map is circular"); + return switch (value) { + case ZsonMap zson -> { + try { + yield stringify(zson).replace("\n", "\n" + indent); + } catch (StackOverflowError e) { + throw new StackOverflowError("Map is circular"); + } } - } - if (value instanceof String) { - return "\"" + ((String) value).replace("\"", "\\\"") + "\""; - } else { - return String.valueOf(value); - } + case String s -> "\"" + s.replace("\"", "\\\"") + "\""; + case Number n -> n.toString(); + case Boolean b -> b.toString(); + case null -> "null"; + default -> throw new IllegalArgumentException("Unsupported value type: " + value.getClass().getName()); + }; } public static Map.Entry, Object> entry(String key, String comment, Object value) { diff --git a/zson/src/main/java/dev/nolij/zson/ZsonMap.java b/zson/src/main/java/dev/nolij/zson/ZsonMap.java index 1ae3effc..9ed6647e 100644 --- a/zson/src/main/java/dev/nolij/zson/ZsonMap.java +++ b/zson/src/main/java/dev/nolij/zson/ZsonMap.java @@ -17,11 +17,12 @@ public ZsonMap(Map.Entry, Object>... entries) { } } - public Object put(String key, String comment, Object value) { - return this.put(new AbstractMap.SimpleEntry<>(key, comment), value); + public ZsonMap put(String key, String comment, Object value) { + this.put(new AbstractMap.SimpleEntry<>(key, comment), value); + return this; } - public Object put(String key, Object value) { - return this.put(new AbstractMap.SimpleEntry<>(key, ""), value); + public ZsonMap put(String key, Object value) { + return this.put(key, "", value); } } diff --git a/zson/src/test/java/Main.java b/zson/src/test/java/Main.java index 8b7a0d50..e0708da0 100644 --- a/zson/src/test/java/Main.java +++ b/zson/src/test/java/Main.java @@ -3,7 +3,6 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; -import java.nio.file.Path; import java.nio.file.Paths; public class Main { From 832227cc1a9a34cf769de068836c17c4389dd3ad Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 12 May 2024 14:01:28 -0400 Subject: [PATCH 09/51] remove switch java 21 moment --- zson/src/main/java/dev/nolij/zson/Zson.java | 30 ++++++++++++--------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java index 4df50b8e..3a1047ce 100644 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -35,20 +35,24 @@ public String stringify(ZsonMap zson) { } private String value(Object value) { - return switch (value) { - case ZsonMap zson -> { - try { - yield stringify(zson).replace("\n", "\n" + indent); - } catch (StackOverflowError e) { - throw new StackOverflowError("Map is circular"); - } + if(value instanceof ZsonMap zson) { + try { + return stringify(zson).replace("\n", "\n" + indent); + } catch (StackOverflowError e) { + throw new StackOverflowError("Map is circular"); } - case String s -> "\"" + s.replace("\"", "\\\"") + "\""; - case Number n -> n.toString(); - case Boolean b -> b.toString(); - case null -> "null"; - default -> throw new IllegalArgumentException("Unsupported value type: " + value.getClass().getName()); - }; + } else if(value instanceof String s) { + return '"' + s + .replace("\"", "\\\"") + .replace("\n", "\\n") + .replace("\r", "\\r") + .replace("\t", "\\t") + + '"'; + } else if(value instanceof Number || value instanceof Boolean || value == null) { + return String.valueOf(value); + } else { + throw new IllegalArgumentException("Unsupported value type: " + value.getClass().getName()); + } } public static Map.Entry, Object> entry(String key, String comment, Object value) { From 743d8666d4758182124a221cb6806c4a9b1ddd72 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 12 May 2024 21:53:26 -0400 Subject: [PATCH 10/51] add ZsonKey definitely larger but at least get() works now --- zson/src/main/java/dev/nolij/zson/Zson.java | 44 ++++++++++++++----- .../src/main/java/dev/nolij/zson/ZsonKey.java | 20 +++++++++ .../src/main/java/dev/nolij/zson/ZsonMap.java | 14 +++--- zson/src/test/java/Main.java | 5 ++- 4 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 zson/src/main/java/dev/nolij/zson/ZsonKey.java diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java index 3a1047ce..702450ab 100644 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ b/zson/src/main/java/dev/nolij/zson/Zson.java @@ -1,5 +1,8 @@ package dev.nolij.zson; +import java.io.IOException; +import java.io.StringWriter; +import java.io.Writer; import java.util.AbstractMap; import java.util.Map; @@ -15,23 +18,42 @@ public ZsonMap parse(String json) { } public String stringify(ZsonMap zson) { - StringBuilder sb = new StringBuilder("{\n"); + StringWriter writer = new StringWriter(); + try { + write(zson, writer); + } catch (IOException e) { + throw new RuntimeException(e); + } + return writer.toString(); + } + + public void write(ZsonMap zson, Writer writer) throws IOException { + writer.write("{\n"); for (var entry : zson.entrySet()) { - Map.Entry keyPair = entry.getKey(); - String key = keyPair.getKey(), comment = keyPair.getValue(); + ZsonKey keyPair = entry.getKey(); + String key = keyPair.key, comment = keyPair.comment; Object value = entry.getValue(); - if (comment != null && !comment.isEmpty()) { + if (comment != null) { for (String line : comment.split("\n")) { - sb.append(indent).append("// ").append(line).append("\n"); + writer.write(indent); + writer.write("// "); + writer.write(line); + writer.write("\n"); } } - sb.append(indent).append('"').append(key).append("\": ").append(value(value)).append(",\n"); + writer.write(indent); + writer.write('"'); + writer.write(key); + writer.write("\": "); + writer.write(value(value)); + writer.write(",\n"); } - return sb.append("}").toString(); + writer.write("}"); + writer.flush(); } private String value(Object value) { @@ -55,11 +77,11 @@ private String value(Object value) { } } - public static Map.Entry, Object> entry(String key, String comment, Object value) { - return new AbstractMap.SimpleEntry<>(new AbstractMap.SimpleEntry<>(key, comment), value); + public static Map.Entry entry(String key, String comment, Object value) { + return new AbstractMap.SimpleEntry<>(new ZsonKey(key, comment), value); } - public static Map.Entry, Object> entry(String key, Object value) { - return entry(key, "", value); + public static Map.Entry entry(String key, Object value) { + return new AbstractMap.SimpleEntry<>(new ZsonKey(key), value); } } diff --git a/zson/src/main/java/dev/nolij/zson/ZsonKey.java b/zson/src/main/java/dev/nolij/zson/ZsonKey.java new file mode 100644 index 00000000..9ee1a738 --- /dev/null +++ b/zson/src/main/java/dev/nolij/zson/ZsonKey.java @@ -0,0 +1,20 @@ +package dev.nolij.zson; + +public class ZsonKey { + public final String key; + public String comment; + + public ZsonKey(String key, String comment) { + this.key = key; + this.comment = comment; + } + + public ZsonKey(String key) { + this(key, null); + } + + @Override + public int hashCode() { + return key.hashCode(); + } +} diff --git a/zson/src/main/java/dev/nolij/zson/ZsonMap.java b/zson/src/main/java/dev/nolij/zson/ZsonMap.java index 9ed6647e..c487ea8b 100644 --- a/zson/src/main/java/dev/nolij/zson/ZsonMap.java +++ b/zson/src/main/java/dev/nolij/zson/ZsonMap.java @@ -1,16 +1,15 @@ package dev.nolij.zson; -import java.util.AbstractMap; import java.util.LinkedHashMap; import java.util.Map; -public class ZsonMap extends LinkedHashMap, Object> { +public class ZsonMap extends LinkedHashMap { public ZsonMap() { super(); } @SafeVarargs - public ZsonMap(Map.Entry, Object>... entries) { + public ZsonMap(Map.Entry... entries) { super(entries.length); for (var entry : entries) { this.put(entry.getKey(), entry.getValue()); @@ -18,11 +17,16 @@ public ZsonMap(Map.Entry, Object>... entries) { } public ZsonMap put(String key, String comment, Object value) { - this.put(new AbstractMap.SimpleEntry<>(key, comment), value); + this.put(new ZsonKey(key, comment), value); return this; } public ZsonMap put(String key, Object value) { - return this.put(key, "", value); + this.put(new ZsonKey(key), value); + return this; + } + + public Object get(String key) { + return this.get(new ZsonKey(key)); } } diff --git a/zson/src/test/java/Main.java b/zson/src/test/java/Main.java index e0708da0..7a2e9e10 100644 --- a/zson/src/test/java/Main.java +++ b/zson/src/test/java/Main.java @@ -21,13 +21,14 @@ public static void main(String[] args) throws Throwable { Zson.entry("home", "217-555-1234"), Zson.entry("cell", "217-555-5678") )); - Files.write(Paths.get("person.json5"), zson.stringify(zsonMap).getBytes(StandardCharsets.UTF_8)); + String json = zson.stringify(zsonMap); + zson.write(zsonMap, Files.newBufferedWriter(Paths.get("person.json5"), StandardCharsets.UTF_8)); + System.out.println(json); ZsonMap map2 = new ZsonMap(); ZsonMap map3 = new ZsonMap(); map3.put("test", "a", map2); map2.put("test", "b", map3); - System.out.println(zson.stringify(map2)); } } From 94d224c255b0e961f5fc7f69e0b4590478e3448e Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 13 May 2024 09:08:32 -0400 Subject: [PATCH 11/51] remove zson yes --- settings.gradle.kts | 1 - zson/build.gradle.kts | 6 -- zson/src/main/java/dev/nolij/zson/Zson.java | 87 ------------------- .../src/main/java/dev/nolij/zson/ZsonKey.java | 20 ----- .../src/main/java/dev/nolij/zson/ZsonMap.java | 32 ------- zson/src/test/java/Main.java | 34 -------- 6 files changed, 180 deletions(-) delete mode 100644 zson/build.gradle.kts delete mode 100644 zson/src/main/java/dev/nolij/zson/Zson.java delete mode 100644 zson/src/main/java/dev/nolij/zson/ZsonKey.java delete mode 100644 zson/src/main/java/dev/nolij/zson/ZsonMap.java delete mode 100644 zson/src/test/java/Main.java diff --git a/settings.gradle.kts b/settings.gradle.kts index 7a2182c2..f70d74e8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -12,7 +12,6 @@ rootProject.name = "zume" include("stubs") include("api") -include("zson") include("modern") include("legacy") include("primitive") diff --git a/zson/build.gradle.kts b/zson/build.gradle.kts deleted file mode 100644 index c7b9b686..00000000 --- a/zson/build.gradle.kts +++ /dev/null @@ -1,6 +0,0 @@ -operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") - -tasks.register("testRun") { - mainClass = "Main" - classpath(sourceSets["test"].runtimeClasspath) -} \ No newline at end of file diff --git a/zson/src/main/java/dev/nolij/zson/Zson.java b/zson/src/main/java/dev/nolij/zson/Zson.java deleted file mode 100644 index 702450ab..00000000 --- a/zson/src/main/java/dev/nolij/zson/Zson.java +++ /dev/null @@ -1,87 +0,0 @@ -package dev.nolij.zson; - -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; -import java.util.AbstractMap; -import java.util.Map; - -public final class Zson { - public String indent; - - public Zson(String indent) { - this.indent = indent; - } - - public ZsonMap parse(String json) { - throw new UnsupportedOperationException("Not implemented yet"); - } - - public String stringify(ZsonMap zson) { - StringWriter writer = new StringWriter(); - try { - write(zson, writer); - } catch (IOException e) { - throw new RuntimeException(e); - } - return writer.toString(); - } - - public void write(ZsonMap zson, Writer writer) throws IOException { - writer.write("{\n"); - - for (var entry : zson.entrySet()) { - ZsonKey keyPair = entry.getKey(); - String key = keyPair.key, comment = keyPair.comment; - Object value = entry.getValue(); - - if (comment != null) { - for (String line : comment.split("\n")) { - writer.write(indent); - writer.write("// "); - writer.write(line); - writer.write("\n"); - } - } - - writer.write(indent); - writer.write('"'); - writer.write(key); - writer.write("\": "); - writer.write(value(value)); - writer.write(",\n"); - } - - writer.write("}"); - writer.flush(); - } - - private String value(Object value) { - if(value instanceof ZsonMap zson) { - try { - return stringify(zson).replace("\n", "\n" + indent); - } catch (StackOverflowError e) { - throw new StackOverflowError("Map is circular"); - } - } else if(value instanceof String s) { - return '"' + s - .replace("\"", "\\\"") - .replace("\n", "\\n") - .replace("\r", "\\r") - .replace("\t", "\\t") - + '"'; - } else if(value instanceof Number || value instanceof Boolean || value == null) { - return String.valueOf(value); - } else { - throw new IllegalArgumentException("Unsupported value type: " + value.getClass().getName()); - } - } - - public static Map.Entry entry(String key, String comment, Object value) { - return new AbstractMap.SimpleEntry<>(new ZsonKey(key, comment), value); - } - - public static Map.Entry entry(String key, Object value) { - return new AbstractMap.SimpleEntry<>(new ZsonKey(key), value); - } -} diff --git a/zson/src/main/java/dev/nolij/zson/ZsonKey.java b/zson/src/main/java/dev/nolij/zson/ZsonKey.java deleted file mode 100644 index 9ee1a738..00000000 --- a/zson/src/main/java/dev/nolij/zson/ZsonKey.java +++ /dev/null @@ -1,20 +0,0 @@ -package dev.nolij.zson; - -public class ZsonKey { - public final String key; - public String comment; - - public ZsonKey(String key, String comment) { - this.key = key; - this.comment = comment; - } - - public ZsonKey(String key) { - this(key, null); - } - - @Override - public int hashCode() { - return key.hashCode(); - } -} diff --git a/zson/src/main/java/dev/nolij/zson/ZsonMap.java b/zson/src/main/java/dev/nolij/zson/ZsonMap.java deleted file mode 100644 index c487ea8b..00000000 --- a/zson/src/main/java/dev/nolij/zson/ZsonMap.java +++ /dev/null @@ -1,32 +0,0 @@ -package dev.nolij.zson; - -import java.util.LinkedHashMap; -import java.util.Map; - -public class ZsonMap extends LinkedHashMap { - public ZsonMap() { - super(); - } - - @SafeVarargs - public ZsonMap(Map.Entry... entries) { - super(entries.length); - for (var entry : entries) { - this.put(entry.getKey(), entry.getValue()); - } - } - - public ZsonMap put(String key, String comment, Object value) { - this.put(new ZsonKey(key, comment), value); - return this; - } - - public ZsonMap put(String key, Object value) { - this.put(new ZsonKey(key), value); - return this; - } - - public Object get(String key) { - return this.get(new ZsonKey(key)); - } -} diff --git a/zson/src/test/java/Main.java b/zson/src/test/java/Main.java deleted file mode 100644 index 7a2e9e10..00000000 --- a/zson/src/test/java/Main.java +++ /dev/null @@ -1,34 +0,0 @@ -import dev.nolij.zson.Zson; -import dev.nolij.zson.ZsonMap; - -import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class Main { - public static void main(String[] args) throws Throwable { - Zson zson = new Zson(" "); - ZsonMap zsonMap = new ZsonMap(); - zsonMap.put("name", "The name of the person\nlook, a second line!", "John Doe"); - zsonMap.put("age", "The age of the person", 30); - zsonMap.put("address", "The address of the person", new ZsonMap( - Zson.entry("street", "The street of the address", "123 Main St"), - Zson.entry("city", "The city of the address", "Springfield"), - Zson.entry("state", "The state of the address", "IL"), - Zson.entry("zip", "The zip code of the address", 62701) - )); - zsonMap.put("phoneNumbers", "The phone numbers of the person", new ZsonMap( - Zson.entry("home", "217-555-1234"), - Zson.entry("cell", "217-555-5678") - )); - String json = zson.stringify(zsonMap); - zson.write(zsonMap, Files.newBufferedWriter(Paths.get("person.json5"), StandardCharsets.UTF_8)); - System.out.println(json); - - ZsonMap map2 = new ZsonMap(); - ZsonMap map3 = new ZsonMap(); - map3.put("test", "a", map2); - map2.put("test", "b", map3); - System.out.println(zson.stringify(map2)); - } -} From 74af0feaa728d4046efb10da61b2d79f8afaa3d1 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 14 May 2024 10:05:39 -0400 Subject: [PATCH 12/51] depend on external zson [skip ci]; doesn't work because zson isn't in mavenlocal on github runners --- .gitignore | 1 + .../zume/impl/config/ZumeConfigImpl.java | 182 ++++++++++-------- build.gradle.kts | 11 +- gradle.properties | 4 +- lexforge/build.gradle.kts | 2 +- lexforge16/build.gradle.kts | 2 +- lexforge18/build.gradle.kts | 2 +- neoforge/build.gradle.kts | 2 +- 8 files changed, 118 insertions(+), 88 deletions(-) diff --git a/.gitignore b/.gitignore index 3c37caf3..1496c587 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # User-specific stuff .idea/ +zume.json5 *.iml *.ipr diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 6de09be8..9638c356 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -1,103 +1,104 @@ package dev.nolij.zume.impl.config; -import blue.endless.jankson.Comment; -import blue.endless.jankson.Jankson; -import blue.endless.jankson.JsonGrammar; -import blue.endless.jankson.api.SyntaxError; +import dev.nolij.zson.Zson; +import dev.nolij.zson.ZsonParser; +import dev.nolij.zson.ZsonValue; +import dev.nolij.zson.ZsonWriter; import dev.nolij.zume.impl.Zume; import java.io.*; +import java.lang.reflect.Modifier; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Map; public class ZumeConfigImpl { - @Comment(""" - \nEnable Cinematic Camera while zooming. - If you disable this, you should also try setting `zoomSmoothnessMs` to `0`. - DEFAULT: `true`""") public boolean enableCinematicZoom = true; - - @Comment(""" - \nMouse Sensitivity will not be reduced below this amount while zoomed in. - Set to `1.0` to prevent it from being changed at all (not recommended without `enableCinematicZoom`). - DEFAULT: `0.4`""") public double mouseSensitivityFloor = 0.4D; - - @Comment(""" - \nSpeed for Zoom In/Out key binds & zoom scrolling (if enabled). - DEFAULT: `20`""") public short zoomSpeed = 20; - - @Comment(""" - \nAllows you to zoom in and out by scrolling up and down on your mouse while zoom is active. - This will prevent you from scrolling through your hotbar while zooming if enabled. - DEFAULT: `true`""") public boolean enableZoomScrolling = true; - - @Comment(""" - \nFOV changes will be spread out over this many milliseconds. - Set to `0` to disable animations. - DEFAULT: `150`""") public short zoomSmoothnessMs = 150; - - @Comment(""" - \nThe exponent used for easing animations. - You should probably leave this at the default if you don't understand what it does. - DEFAULT: `4.0`""") public double animationEasingExponent = 4D; - - @Comment(""" - \nThe exponent used for making differences in FOV more uniform. - You should probably leave this at the default if you don't understand what it does. - DEFAULT: `2.0`""") public double zoomEasingExponent = 2D; - - @Comment(""" - \nDefault starting zoom percentage. - DEFAULT: `0.5`""") public double defaultZoom = 0.5D; - - @Comment(""" - \nIf `true`, the Zoom keybind will act as a toggle in first-person. - If `false`, Zoom will only be active in first-person while the keybind is held. - DEFAULT: `false`""") public boolean toggleMode = false; - - @Comment(""" - \nIf `true`, the Zoom keybind will act as a toggle in third-person. - If `false`, Zoom will only be active in third-person while the keybind is held. - DEFAULT: `true`""") public boolean thirdPersonToggleMode = true; - - @Comment(""" - \nMinimum zoom FOV. - DEFAULT: `1.0`""") public double minFOV = 1D; - - @Comment(""" - \nMaximum third-person zoom distance (in blocks). - Set to `0.0` to disable third-person zoom. - DEFAULT: `15.0`""") public double maxThirdPersonZoomDistance = 15D; - - @Comment(""" - \nMinimum third-person zoom distance (in blocks). - Set to `4.0` to mimic vanilla. - DEFAULT: `0.5`""") public double minThirdPersonZoomDistance = 0.5D; - - @Comment(""" - \nIf `true`, the mod will be disabled (on some platforms, key binds will still show in game options; they won't do anything if this is set to `true`). - Requires re-launch to take effect. - DEFAULT: `false`""") public boolean disable = false; private static final int EXPECTED_VERSION = 1; - @Comment("Used internally. Don't modify this.") public int configVersion = EXPECTED_VERSION; + @SuppressWarnings("unused") + private static final class Comments { + static final String enableCinematicZoom = """ + Enable Cinematic Camera while zooming. + If you disable this, you should also try setting `zoomSmoothnessMs` to `0`. + DEFAULT: `true`"""; + static final String mouseSensitivityFloor = """ + Mouse Sensitivity will not be reduced below this amount while zoomed in. + Set to `1.0` to prevent it from being changed at all (not recommended without `enableCinematicZoom`). + DEFAULT: `0.4`"""; + static final String zoomSpeed = """ + Speed for Zoom In/Out key binds & zoom scrolling (if enabled). + DEFAULT: `20`"""; + static final String enableZoomScrolling = """ + Allows you to zoom in and out by scrolling up and down on your mouse while zoom is active. + This will prevent you from scrolling through your hotbar while zooming if enabled. + DEFAULT: `true`"""; + static final String zoomSmoothnessMs = """ + FOV changes will be spread out over this many milliseconds. + Set to `0` to disable animations. + DEFAULT: `150`"""; + static final String animationEasingExponent = """ + The exponent used for easing animations. + You should probably leave this at the default if you don't understand what it does. + DEFAULT: `4.0`"""; + static final String zoomEasingExponent = """ + The exponent used for making differences in FOV more uniform. + You should probably leave this at the default if you don't understand what it does. + DEFAULT: `2.0`"""; + static final String defaultZoom = """ + Default starting zoom percentage. + DEFAULT: `0.5`"""; + static final String toggleMode = """ + If `true`, the Zoom keybind will act as a toggle in first-person. + If `false`, Zoom will only be active in first-person while the keybind is held. + DEFAULT: `false`"""; + static final String thirdPersonToggleMode = """ + If `true`, the Zoom keybind will act as a toggle in third-person. + If `false`, Zoom will only be active in third-person while the keybind is held. + DEFAULT: `true`"""; + static final String minFOV = """ + Minimum zoom FOV. + DEFAULT: `1.0`"""; + static final String maxThirdPersonZoomDistance = """ + Maximum third-person zoom distance (in blocks). + Set to `0.0` to disable third-person zoom. + DEFAULT: `15.0`"""; + static final String minThirdPersonZoomDistance = """ + Minimum third-person zoom distance (in blocks). + Set to `4.0` to mimic vanilla. + DEFAULT: `0.5`"""; + static final String disable = """ + If `true`, the mod will be disabled (on some platforms, key binds will still show in game options; they won't do anything if this is set to `true`). + Requires re-launch to take effect. + DEFAULT: `false`"""; + static final String configVersion = "Used internally. Don't modify this."; + + static String getComment(final String fieldName) { + try { + return (String) Comments.class.getDeclaredField(fieldName).get(null); + } catch (IllegalAccessException | NoSuchFieldException e) { + throw new RuntimeException(e); + } + } + } + @FunctionalInterface public interface ConfigConsumer { @@ -105,10 +106,7 @@ public interface ConfigConsumer { } private static final int MAX_RETRIES = 5; - private static final JsonGrammar JSON_GRAMMAR = JsonGrammar.JANKSON; - private static final Jankson JANKSON = Jankson.builder() - .allowBareRootObject() - .build(); + private static final ZsonWriter ZSON = new ZsonWriter(); private static ZumeConfigImpl readFromFile(final File configFile) { if (configFile == null || !configFile.exists()) @@ -117,8 +115,8 @@ private static ZumeConfigImpl readFromFile(final File configFile) { int i = 0; while (true) { try { - return JANKSON.fromJson(JANKSON.load(configFile), ZumeConfigImpl.class); - } catch (SyntaxError e) { + return fromMap(ZsonParser.parse(new FileReader(configFile))); + } catch (IllegalArgumentException e) { if (++i < MAX_RETRIES) { try { //noinspection BusyWait @@ -149,13 +147,39 @@ private static ZumeConfigImpl readConfigFile() { private void writeToFile(final File configFile) { this.configVersion = EXPECTED_VERSION; try (final FileWriter configWriter = new FileWriter(configFile)) { - JANKSON.toJson(this).toJson(configWriter, JSON_GRAMMAR, 0); + ZSON.write(this.toMap(), configWriter); configWriter.flush(); } catch (IOException e) { throw new RuntimeException(e); } } + private Map toMap() { + Map map = Zson.object(); + for (var field : ZumeConfigImpl.class.getDeclaredFields()) { + if(Modifier.isStatic(field.getModifiers())) continue; + try { + map.put(field.getName(), new ZsonValue(Comments.getComment(field.getName()), field.get(this))); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + return map; + } + + private static ZumeConfigImpl fromMap(final Map map) { + ZumeConfigImpl result = new ZumeConfigImpl(); + for (var field : ZumeConfigImpl.class.getDeclaredFields()) { + if(Modifier.isStatic(field.getModifiers())) continue; + try { + field.set(result, map.get(field.getName()).value); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + return result; + } + private static ConfigConsumer consumer; private static IFileWatcher instanceWatcher; private static IFileWatcher globalWatcher; @@ -239,7 +263,7 @@ public static void init(final Path instanceConfigPath, final String fileName, fi try { final IFileWatcher nullWatcher = new IFileWatcher() { @Override - public void lock() throws InterruptedException {} + public void lock() {} @Override public boolean tryLock() { diff --git a/build.gradle.kts b/build.gradle.kts index ac45104b..b8f33583 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -170,6 +170,7 @@ allprojects { excludeGroup("ca.weblite") } } + mavenLocal() maven("https://repo.spongepowered.org/maven") maven("https://jitpack.io/") maven("https://api.modrinth.com/maven") { @@ -232,7 +233,7 @@ subprojects { } dependencies { - implementation("blue.endless:jankson:${"jankson_version"()}") + implementation("dev.nolij:zson:${"zson_version"()}") } if (implName in uniminedImpls) { @@ -245,6 +246,10 @@ subprojects { runs.config("server") { disabled = true } + + runs.config("client") { + jvmArgs += "-Dzume.configPathOverride=${rootProject.file("zume.json5").absolutePath}" + } } defaultRemapJar = true @@ -284,7 +289,7 @@ val shade: Configuration by configurations.creating { } dependencies { - shade("blue.endless:jankson:${"jankson_version"()}") + shade("dev.nolij:zson:${"zson_version"()}") compileOnly("org.apache.logging.log4j:log4j-core:${"log4j_version"()}") @@ -371,7 +376,7 @@ tasks.shadowJar { } } - relocate("blue.endless.jankson", "dev.nolij.zume.shadow.blue.endless.jankson") + relocate("dev.nolij.zson", "dev.nolij.zume.shadow.dev.nolij.zson") manifest { attributes( diff --git a/gradle.properties b/gradle.properties index 3c548c8f..e4d426d0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -91,8 +91,8 @@ mixinbooter_version = 9.1 # Misc Dependencies # https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 -# https://central.sonatype.com/artifact/blue.endless/jankson/overview -jankson_version = 1.2.3 +# idk +zson_version = 0.1 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core log4j_version = 3.0.0-beta2 # https://central.sonatype.com/artifact/org.slf4j/slf4j-api diff --git a/lexforge/build.gradle.kts b/lexforge/build.gradle.kts index 6dc9744c..d80d85bf 100644 --- a/lexforge/build.gradle.kts +++ b/lexforge/build.gradle.kts @@ -17,5 +17,5 @@ unimined.minecraft { dependencies { compileOnly(project(":stubs")) - "minecraftLibraries"("blue.endless:jankson:${"jankson_version"()}") + "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file diff --git a/lexforge16/build.gradle.kts b/lexforge16/build.gradle.kts index 8e817db0..2d33ac1b 100644 --- a/lexforge16/build.gradle.kts +++ b/lexforge16/build.gradle.kts @@ -16,5 +16,5 @@ unimined.minecraft { } dependencies { - "minecraftLibraries"("blue.endless:jankson:${"jankson_version"()}") + "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file diff --git a/lexforge18/build.gradle.kts b/lexforge18/build.gradle.kts index 26160165..83a48a1a 100644 --- a/lexforge18/build.gradle.kts +++ b/lexforge18/build.gradle.kts @@ -17,5 +17,5 @@ unimined.minecraft { dependencies { compileOnly(project(":stubs")) - "minecraftLibraries"("blue.endless:jankson:${"jankson_version"()}") + "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index b16ede60..4898867d 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -20,5 +20,5 @@ unimined.minecraft { dependencies { compileOnly(project(":stubs")) - "minecraftLibraries"("blue.endless:jankson:${"jankson_version"()}") + "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file From a8a20dc5b667c3e7457027c8a1e0b5cb53dc36a3 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Wed, 15 May 2024 21:25:25 -0400 Subject: [PATCH 13/51] fix config loading least cursed zume code ive written --- .../zume/impl/config/ZumeConfigImpl.java | 30 +++++++++++++++---- build.gradle.kts | 9 +----- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 9638c356..7f97b557 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -7,6 +7,7 @@ import dev.nolij.zume.impl.Zume; import java.io.*; +import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.file.FileSystems; import java.nio.file.Files; @@ -171,15 +172,34 @@ private static ZumeConfigImpl fromMap(final Map map) { ZumeConfigImpl result = new ZumeConfigImpl(); for (var field : ZumeConfigImpl.class.getDeclaredFields()) { if(Modifier.isStatic(field.getModifiers())) continue; - try { - field.set(result, map.get(field.getName()).value); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } + setField(field, result, map.get(field.getName()).value); } return result; } + private static void setField(Field field, ZumeConfigImpl config, Object value) { + @SuppressWarnings("unchecked") + Class type = (Class) field.getType(); + try { + if (type == boolean.class) { + field.setBoolean(config, (boolean) value); + } else if(type == int.class) { + field.setInt(config, (int) value); + } else if (type == double.class) { + field.setDouble(config, (double) value); + } else if (type == short.class) { + field.setShort(config, (short) (int) value); + } else { + field.set(config, value); + } + } catch (Exception e) { + throw new RuntimeException( + "Failed to set field " + field.getName() + " (type " + type.getSimpleName() + ") to " + value + " " + + "(type " + value.getClass().getSimpleName() + ")", e + ); + } + } + private static ConfigConsumer consumer; private static IFileWatcher instanceWatcher; private static IFileWatcher globalWatcher; diff --git a/build.gradle.kts b/build.gradle.kts index b8f33583..90a3651c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -346,6 +346,7 @@ tasks.shadowJar { } exclude("*.xcf") + exclude("LICENSE_ZSON") configurations = immutableListOf(shade) archiveClassifier = null @@ -407,14 +408,6 @@ tasks.assemble { dependsOn(compressJar, sourcesJar) } -//tasks.register("cleassemble") { -// group = "build" -// doLast { -// //run clean THEN assemble -// tasks.clean.get(). -// } -//} - afterEvaluate { publishing { repositories { From 6d83e4ef9ee4515b39a1214af71c085ef453f2f7 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Thu, 16 May 2024 10:35:36 +0800 Subject: [PATCH 14/51] use an @Comment annotation on fields for readability but is larger :( and other stuff idk --- .../main/java/dev/nolij/zume/impl/Zume.java | 4 +- .../zume/impl/config/NullFileWatcher.java | 16 ++ .../zume/impl/config/ZumeConfigImpl.java | 203 +++++++++--------- 3 files changed, 117 insertions(+), 106 deletions(-) create mode 100644 api/src/main/java/dev/nolij/zume/impl/config/NullFileWatcher.java diff --git a/api/src/main/java/dev/nolij/zume/impl/Zume.java b/api/src/main/java/dev/nolij/zume/impl/Zume.java index 59743c4a..25c8128b 100644 --- a/api/src/main/java/dev/nolij/zume/impl/Zume.java +++ b/api/src/main/java/dev/nolij/zume/impl/Zume.java @@ -28,10 +28,10 @@ public class Zume { if (OS_NAME.contains("linux")) HOST_PLATFORM = HostPlatform.LINUX; - else if (OS_NAME.contains("win")) - HOST_PLATFORM = HostPlatform.WINDOWS; else if (OS_NAME.contains("mac")) HOST_PLATFORM = HostPlatform.MAC_OS; + else if (OS_NAME.contains("win")) + HOST_PLATFORM = HostPlatform.WINDOWS; else HOST_PLATFORM = HostPlatform.UNKNOWN; } diff --git a/api/src/main/java/dev/nolij/zume/impl/config/NullFileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/NullFileWatcher.java new file mode 100644 index 00000000..0f715737 --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/impl/config/NullFileWatcher.java @@ -0,0 +1,16 @@ +package dev.nolij.zume.impl.config; + +public final class NullFileWatcher implements IFileWatcher { + @Override + public void lock() { + } + + @Override + public boolean tryLock() { + return true; + } + + @Override + public void unlock() { + } +} diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 7f97b557..a66f6cbc 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -7,104 +7,103 @@ import dev.nolij.zume.impl.Zume; import java.io.*; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.util.Map; +import java.util.function.Consumer; public class ZumeConfigImpl { + @Comment(""" + Enable Cinematic Camera while zooming. + If you disable this, you should also try setting `zoomSmoothnessMs` to `0`. + DEFAULT: `true`""") public boolean enableCinematicZoom = true; + + @Comment(""" + Mouse Sensitivity will not be reduced below this amount while zoomed in. + Set to `1.0` to prevent it from being changed at all (not recommended without `enableCinematicZoom`). + DEFAULT: `0.4`""") public double mouseSensitivityFloor = 0.4D; + + @Comment(""" + Speed for Zoom In/Out key binds & zoom scrolling (if enabled). + DEFAULT: `20`""") public short zoomSpeed = 20; + + @Comment(""" + Allows you to zoom in and out by scrolling up and down on your mouse while zoom is active. + This will prevent you from scrolling through your hotbar while zooming if enabled. + DEFAULT: `true`""") public boolean enableZoomScrolling = true; + + @Comment(""" + FOV changes will be spread out over this many milliseconds. + Set to `0` to disable animations. + DEFAULT: `150`""") public short zoomSmoothnessMs = 150; + + @Comment(""" + The exponent used for easing animations. + You should probably leave this at the default if you don't understand what it does. + DEFAULT: `4.0`""") public double animationEasingExponent = 4D; + + @Comment(""" + The exponent used for making differences in FOV more uniform. + You should probably leave this at the default if you don't understand what it does. + DEFAULT: `2.0`""") public double zoomEasingExponent = 2D; + + @Comment(""" + Default starting zoom percentage. + DEFAULT: `0.5`""") public double defaultZoom = 0.5D; + + @Comment(""" + If `true`, the Zoom keybind will act as a toggle in first-person. + If `false`, Zoom will only be active in first-person while the keybind is held. + DEFAULT: `false`""") public boolean toggleMode = false; + + @Comment(""" + If `true`, the Zoom keybind will act as a toggle in third-person. + If `false`, Zoom will only be active in third-person while the keybind is held. + DEFAULT: `true`""") public boolean thirdPersonToggleMode = true; + + @Comment("Minimum zoom FOV.\nDEFAULT: `1.0`") public double minFOV = 1D; + + @Comment(""" + Maximum third-person zoom distance (in blocks). + Set to `0.0` to disable third-person zoom. + DEFAULT: `15.0`""") public double maxThirdPersonZoomDistance = 15D; + + @Comment(""" + Minimum third-person zoom distance (in blocks). + Set to `4.0` to mimic vanilla. + DEFAULT: `0.5`""") public double minThirdPersonZoomDistance = 0.5D; + + @Comment(""" + If `true`, the mod will be disabled (on some platforms, key binds will still show in game options; they won't do anything if this is set to `true`). + Requires re-launch to take effect. + DEFAULT: `false`""") public boolean disable = false; private static final int EXPECTED_VERSION = 1; - public int configVersion = EXPECTED_VERSION; - @SuppressWarnings("unused") - private static final class Comments { - static final String enableCinematicZoom = """ - Enable Cinematic Camera while zooming. - If you disable this, you should also try setting `zoomSmoothnessMs` to `0`. - DEFAULT: `true`"""; - static final String mouseSensitivityFloor = """ - Mouse Sensitivity will not be reduced below this amount while zoomed in. - Set to `1.0` to prevent it from being changed at all (not recommended without `enableCinematicZoom`). - DEFAULT: `0.4`"""; - static final String zoomSpeed = """ - Speed for Zoom In/Out key binds & zoom scrolling (if enabled). - DEFAULT: `20`"""; - static final String enableZoomScrolling = """ - Allows you to zoom in and out by scrolling up and down on your mouse while zoom is active. - This will prevent you from scrolling through your hotbar while zooming if enabled. - DEFAULT: `true`"""; - static final String zoomSmoothnessMs = """ - FOV changes will be spread out over this many milliseconds. - Set to `0` to disable animations. - DEFAULT: `150`"""; - static final String animationEasingExponent = """ - The exponent used for easing animations. - You should probably leave this at the default if you don't understand what it does. - DEFAULT: `4.0`"""; - static final String zoomEasingExponent = """ - The exponent used for making differences in FOV more uniform. - You should probably leave this at the default if you don't understand what it does. - DEFAULT: `2.0`"""; - static final String defaultZoom = """ - Default starting zoom percentage. - DEFAULT: `0.5`"""; - static final String toggleMode = """ - If `true`, the Zoom keybind will act as a toggle in first-person. - If `false`, Zoom will only be active in first-person while the keybind is held. - DEFAULT: `false`"""; - static final String thirdPersonToggleMode = """ - If `true`, the Zoom keybind will act as a toggle in third-person. - If `false`, Zoom will only be active in third-person while the keybind is held. - DEFAULT: `true`"""; - static final String minFOV = """ - Minimum zoom FOV. - DEFAULT: `1.0`"""; - static final String maxThirdPersonZoomDistance = """ - Maximum third-person zoom distance (in blocks). - Set to `0.0` to disable third-person zoom. - DEFAULT: `15.0`"""; - static final String minThirdPersonZoomDistance = """ - Minimum third-person zoom distance (in blocks). - Set to `4.0` to mimic vanilla. - DEFAULT: `0.5`"""; - static final String disable = """ - If `true`, the mod will be disabled (on some platforms, key binds will still show in game options; they won't do anything if this is set to `true`). - Requires re-launch to take effect. - DEFAULT: `false`"""; - static final String configVersion = "Used internally. Don't modify this."; - - static String getComment(final String fieldName) { - try { - return (String) Comments.class.getDeclaredField(fieldName).get(null); - } catch (IllegalAccessException | NoSuchFieldException e) { - throw new RuntimeException(e); - } - } - } - - - @FunctionalInterface - public interface ConfigConsumer { - void invoke(ZumeConfigImpl config); - } + @Comment("Used internally. Don't modify this.") + public int configVersion = EXPECTED_VERSION; private static final int MAX_RETRIES = 5; private static final ZsonWriter ZSON = new ZsonWriter(); @@ -151,18 +150,20 @@ private void writeToFile(final File configFile) { ZSON.write(this.toMap(), configWriter); configWriter.flush(); } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed to write config file", e); } } private Map toMap() { Map map = Zson.object(); - for (var field : ZumeConfigImpl.class.getDeclaredFields()) { + for (Field field : ZumeConfigImpl.class.getDeclaredFields()) { if(Modifier.isStatic(field.getModifiers())) continue; + Comment comment = field.getAnnotation(Comment.class); + if (comment == null) continue; try { - map.put(field.getName(), new ZsonValue(Comments.getComment(field.getName()), field.get(this))); + map.put(field.getName(), new ZsonValue(comment.value(), field.get(this))); } catch (IllegalAccessException e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed to get field " + field.getName(), e); } } return map; @@ -170,7 +171,7 @@ private Map toMap() { private static ZumeConfigImpl fromMap(final Map map) { ZumeConfigImpl result = new ZumeConfigImpl(); - for (var field : ZumeConfigImpl.class.getDeclaredFields()) { + for (Field field : ZumeConfigImpl.class.getDeclaredFields()) { if(Modifier.isStatic(field.getModifiers())) continue; setField(field, result, map.get(field.getName()).value); } @@ -181,16 +182,16 @@ private static void setField(Field field, ZumeConfigImpl config, Object valu @SuppressWarnings("unchecked") Class type = (Class) field.getType(); try { - if (type == boolean.class) { - field.setBoolean(config, (boolean) value); - } else if(type == int.class) { - field.setInt(config, (int) value); - } else if (type == double.class) { - field.setDouble(config, (double) value); - } else if (type == short.class) { - field.setShort(config, (short) (int) value); + if(type.isPrimitive()) { + switch (type.getName()) { + case "boolean" -> field.setBoolean(config, (boolean) value); + case "short" -> field.setShort(config, (short) (int) value); + case "int" -> field.setInt(config, (int) value); + case "float" -> field.setFloat(config, (float) (double) value); + case "double" -> field.setDouble(config, (double) value); + } } else { - field.set(config, value); + field.set(config, type.cast(value)); } } catch (Exception e) { throw new RuntimeException( @@ -200,7 +201,7 @@ private static void setField(Field field, ZumeConfigImpl config, Object valu } } - private static ConfigConsumer consumer; + private static Consumer consumer; private static IFileWatcher instanceWatcher; private static IFileWatcher globalWatcher; private static File instanceFile = null; @@ -213,7 +214,7 @@ public static void replace(final ZumeConfigImpl newConfig) throws InterruptedExc globalWatcher.lock(); newConfig.writeToFile(getConfigFile()); - consumer.invoke(newConfig); + consumer.accept(newConfig); } finally { globalWatcher.unlock(); } @@ -260,10 +261,10 @@ public static void reloadConfig() { final ZumeConfigImpl newConfig = readConfigFile(); - consumer.invoke(newConfig); + consumer.accept(newConfig); } - public static void init(final Path instanceConfigPath, final String fileName, final ConfigConsumer configConsumer) { + public static void init(final Path instanceConfigPath, final String fileName, final Consumer configConsumer) { if (consumer != null) throw new AssertionError("Config already initialized!"); @@ -278,21 +279,10 @@ public static void init(final Path instanceConfigPath, final String fileName, fi // write new options and comment updates to disk config.writeToFile(getConfigFile()); - consumer.invoke(config); + consumer.accept(config); try { - final IFileWatcher nullWatcher = new IFileWatcher() { - @Override - public void lock() {} - - @Override - public boolean tryLock() { - return true; - } - - @Override - public void unlock() {} - }; + final IFileWatcher nullWatcher = new NullFileWatcher(); if (config.disable) { instanceWatcher = nullWatcher; @@ -305,8 +295,13 @@ public void unlock() {} globalWatcher = FileWatcher.onFileChange(getConfigFile().toPath(), ZumeConfigImpl::reloadConfig); } } catch (IOException e) { - throw new RuntimeException(e); + throw new RuntimeException("Failed to create file watcher", e); } } + @Target(ElementType.FIELD) + @Retention(RetentionPolicy.RUNTIME) + public @interface Comment { + String value(); + } } From 7b8fe2c761d22dffa68c8f70aaafd1088ea38ce9 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Thu, 16 May 2024 09:21:45 -0400 Subject: [PATCH 15/51] remap fabric entrypoints --- buildSrc/build.gradle.kts | 1 + .../dev/nolij/zumegradle/JarCompressing.kt | 55 ++++++++++++++++++- proguard.pro | 6 +- 3 files changed, 56 insertions(+), 6 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 7a8b0bf3..31dbf37b 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -22,6 +22,7 @@ fun DependencyHandler.plugin(id: String, version: String) { dependencies { implementation("org.ow2.asm:asm-tree:9.7") + implementation("net.fabricmc:mapping-io:0.3.0") implementation("org.apache.ant:ant:1.10.13") implementation("com.guardsquare:proguard-base:7.4.2") diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 3f50992b..56a9fe73 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -2,6 +2,10 @@ package dev.nolij.zumegradle import groovy.json.JsonOutput import groovy.json.JsonSlurper +import net.fabricmc.mappingio.MappingReader +import net.fabricmc.mappingio.format.MappingFormat +import net.fabricmc.mappingio.tree.MappingTree.ClassMapping +import net.fabricmc.mappingio.tree.MemoryMappingTree import org.gradle.api.DefaultTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFile @@ -48,7 +52,7 @@ enum class JsonShrinkingType { NONE, MINIFY, PRETTY_PRINT } -fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: JsonShrinkingType) { +fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: JsonShrinkingType, mappingsFile: File) { val contents = linkedMapOf() JarFile(jar).use { it.entries().asIterator().forEach { entry -> @@ -57,7 +61,7 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js } } } - + jar.delete() val json = JsonSlurper() @@ -65,6 +69,11 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js JarOutputStream(jar.outputStream()).use { out -> out.setLevel(Deflater.BEST_COMPRESSION) contents.forEach { var (name, bytes) = it + if(name == "fabric.mod.json" && mappingsFile.exists()) { + println("remapping $name") + bytes = remapFMJ(bytes, mappingsFile) + } + if (jsonProcessing != JsonShrinkingType.NONE && name.endsWith(".json") || name.endsWith(".mcmeta") || name == "mcmod.info") { bytes = when (jsonProcessing) { @@ -86,6 +95,46 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js } } +private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { + val mappingTree = MemoryMappingTree() + MappingReader.read(mappingsFile.toPath(), MappingFormat.PROGUARD, mappingTree) + + val dstNamespaceIndex = mappingTree.getNamespaceId(mappingTree.dstNamespaces[0]) + + val json = (JsonSlurper().parse(bytes) as Map).toMutableMap() + //look for entrypoints, should be an object with string keys and array of strings values + var entrypoints = (json["entrypoints"] as Map>?)?.toMutableMap() + if (entrypoints == null) { + throw IllegalStateException("fabric.mod.json does not contain entrypoints") + } + + val mappings = mutableMapOf() + + @Suppress("INACCESSIBLE_TYPE") + for (clazz: ClassMapping in mappingTree.classes) { + val dst = clazz.getDstName(dstNamespaceIndex).replace('/', '.') + val src = clazz.srcName.replace('/', '.') + mappings[src] = dst + } + + val newEntrypoints = mutableMapOf>() + for ((type, classes) in entrypoints) { + for (old in classes) { + println("checking $old") + for ((src, dst) in mappings) { + if(src == old) { + println("remapping $src to $dst") + newEntrypoints.computeIfAbsent(type) { mutableListOf() }.add(dst) + } + } + } + } + + json["entrypoints"] = newEntrypoints + + return JsonOutput.toJson(json).toByteArray() +} + private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinkingType): ByteArray { if(!classFileSettings.shouldRun()) return bytes val classNode = ClassNode() @@ -240,7 +289,7 @@ open class CompressJarTask : DefaultTask() { fun compressJar() { if (useProguard) applyProguard(inputJar, minecraftConfigs, project.rootDir) - squishJar(inputJar, classShrinkingType, jsonShrinkingType) + squishJar(inputJar, classShrinkingType, jsonShrinkingType, mappingsFile) deflate(outputJar, jarShrinkingType) } } \ No newline at end of file diff --git a/proguard.pro b/proguard.pro index 64846ac4..b3a9d8e9 100644 --- a/proguard.pro +++ b/proguard.pro @@ -44,6 +44,6 @@ -keep,allowoptimization class io.github.prospector.modmenu.** { *; } # ugly classloader hack # Fabric entrypoints --keep,allowoptimization class dev.nolij.zume.FabricZumeBootstrapper --keep,allowoptimization class dev.nolij.zume.modern.integration.ZumeModMenuIntegration --keep,allowoptimization class dev.nolij.zume.primitive.event.KeyBindingRegistrar { public *; } +-keep,allowoptimization,allowobfuscation class dev.nolij.zume.FabricZumeBootstrapper +-keep,allowoptimization,allowobfuscation class dev.nolij.zume.modern.integration.ZumeModMenuIntegration +-keep,allowoptimization,allowobfuscation class dev.nolij.zume.primitive.event.KeyBindingRegistrar { public *; } From 15f5418b905272517184dbe4309662ebb25852d0 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Thu, 16 May 2024 13:31:36 -0400 Subject: [PATCH 16/51] remove debug stuff --- .../src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 56a9fe73..c64f4ac5 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -70,7 +70,6 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js out.setLevel(Deflater.BEST_COMPRESSION) contents.forEach { var (name, bytes) = it if(name == "fabric.mod.json" && mappingsFile.exists()) { - println("remapping $name") bytes = remapFMJ(bytes, mappingsFile) } @@ -102,7 +101,6 @@ private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { val dstNamespaceIndex = mappingTree.getNamespaceId(mappingTree.dstNamespaces[0]) val json = (JsonSlurper().parse(bytes) as Map).toMutableMap() - //look for entrypoints, should be an object with string keys and array of strings values var entrypoints = (json["entrypoints"] as Map>?)?.toMutableMap() if (entrypoints == null) { throw IllegalStateException("fabric.mod.json does not contain entrypoints") @@ -120,10 +118,8 @@ private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { val newEntrypoints = mutableMapOf>() for ((type, classes) in entrypoints) { for (old in classes) { - println("checking $old") for ((src, dst) in mappings) { if(src == old) { - println("remapping $src to $dst") newEntrypoints.computeIfAbsent(type) { mutableListOf() }.add(dst) } } From 2af43ae8d236512efab4eec5d8f1c1ce46ef7b49 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 17 May 2024 19:17:39 -0400 Subject: [PATCH 17/51] change --- .../zume/impl/config/ZumeConfigImpl.java | 59 ++----------------- build.gradle.kts | 10 +++- .../dev/nolij/zumegradle/JarCompressing.kt | 1 + gradle.properties | 4 +- lexforge/build.gradle.kts | 2 - lexforge16/build.gradle.kts | 4 -- lexforge18/build.gradle.kts | 2 - 7 files changed, 17 insertions(+), 65 deletions(-) diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index a66f6cbc..2edddf48 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -2,7 +2,6 @@ import dev.nolij.zson.Zson; import dev.nolij.zson.ZsonParser; -import dev.nolij.zson.ZsonValue; import dev.nolij.zson.ZsonWriter; import dev.nolij.zume.impl.Zume; @@ -11,12 +10,9 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -import java.util.Map; import java.util.function.Consumer; public class ZumeConfigImpl { @@ -79,7 +75,9 @@ public class ZumeConfigImpl { DEFAULT: `true`""") public boolean thirdPersonToggleMode = true; - @Comment("Minimum zoom FOV.\nDEFAULT: `1.0`") + @Comment(""" + Minimum zoom FOV. + DEFAULT: `1.0`""") public double minFOV = 1D; @Comment(""" @@ -115,7 +113,7 @@ private static ZumeConfigImpl readFromFile(final File configFile) { int i = 0; while (true) { try { - return fromMap(ZsonParser.parse(new FileReader(configFile))); + return Zson.toObject(ZsonParser.parse(new FileReader(configFile)), ZumeConfigImpl.class); } catch (IllegalArgumentException e) { if (++i < MAX_RETRIES) { try { @@ -147,60 +145,13 @@ private static ZumeConfigImpl readConfigFile() { private void writeToFile(final File configFile) { this.configVersion = EXPECTED_VERSION; try (final FileWriter configWriter = new FileWriter(configFile)) { - ZSON.write(this.toMap(), configWriter); + ZSON.write(Zson.fromObject(this), configWriter); configWriter.flush(); } catch (IOException e) { throw new RuntimeException("Failed to write config file", e); } } - private Map toMap() { - Map map = Zson.object(); - for (Field field : ZumeConfigImpl.class.getDeclaredFields()) { - if(Modifier.isStatic(field.getModifiers())) continue; - Comment comment = field.getAnnotation(Comment.class); - if (comment == null) continue; - try { - map.put(field.getName(), new ZsonValue(comment.value(), field.get(this))); - } catch (IllegalAccessException e) { - throw new RuntimeException("Failed to get field " + field.getName(), e); - } - } - return map; - } - - private static ZumeConfigImpl fromMap(final Map map) { - ZumeConfigImpl result = new ZumeConfigImpl(); - for (Field field : ZumeConfigImpl.class.getDeclaredFields()) { - if(Modifier.isStatic(field.getModifiers())) continue; - setField(field, result, map.get(field.getName()).value); - } - return result; - } - - private static void setField(Field field, ZumeConfigImpl config, Object value) { - @SuppressWarnings("unchecked") - Class type = (Class) field.getType(); - try { - if(type.isPrimitive()) { - switch (type.getName()) { - case "boolean" -> field.setBoolean(config, (boolean) value); - case "short" -> field.setShort(config, (short) (int) value); - case "int" -> field.setInt(config, (int) value); - case "float" -> field.setFloat(config, (float) (double) value); - case "double" -> field.setDouble(config, (double) value); - } - } else { - field.set(config, type.cast(value)); - } - } catch (Exception e) { - throw new RuntimeException( - "Failed to set field " + field.getName() + " (type " + type.getSimpleName() + ") to " + value + " " + - "(type " + value.getClass().getSimpleName() + ")", e - ); - } - } - private static Consumer consumer; private static IFileWatcher instanceWatcher; private static IFileWatcher globalWatcher; diff --git a/build.gradle.kts b/build.gradle.kts index 90a3651c..4a4462a7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -178,6 +178,7 @@ allprojects { includeGroup("maven.modrinth") } } + maven("https://maven.blamejared.com") } tasks.withType { @@ -262,6 +263,10 @@ subprojects { disableRefmap() } } + + dependencies { + "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") + } } } @@ -364,6 +369,9 @@ tasks.shadowJar { exclude("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "pack.mcmeta") filesMatching("**/*.class") { + if(this.name == "dev/nolij/zume/ForgeZumeBootstrapper.class") { + return@filesMatching + } val reader = ClassReader(this.open()) val node = ClassNode() reader.accept(node, 0) @@ -377,7 +385,7 @@ tasks.shadowJar { } } - relocate("dev.nolij.zson", "dev.nolij.zume.shadow.dev.nolij.zson") + relocate("dev.nolij.zson", "dev.nolij.zume.zson") manifest { attributes( diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index c64f4ac5..d8b1caee 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -94,6 +94,7 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js } } +@Suppress("UNCHECKED_CAST") private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { val mappingTree = MemoryMappingTree() MappingReader.read(mappingsFile.toPath(), MappingFormat.PROGUARD, mappingTree) diff --git a/gradle.properties b/gradle.properties index e4d426d0..66e360ec 100644 --- a/gradle.properties +++ b/gradle.properties @@ -91,8 +91,8 @@ mixinbooter_version = 9.1 # Misc Dependencies # https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 -# idk -zson_version = 0.1 +# https://github.com/Nolij/ZSON/releases/ +zson_version = 0.1.0 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core log4j_version = 3.0.0-beta2 # https://central.sonatype.com/artifact/org.slf4j/slf4j-api diff --git a/lexforge/build.gradle.kts b/lexforge/build.gradle.kts index d80d85bf..d556806e 100644 --- a/lexforge/build.gradle.kts +++ b/lexforge/build.gradle.kts @@ -16,6 +16,4 @@ unimined.minecraft { dependencies { compileOnly(project(":stubs")) - - "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file diff --git a/lexforge16/build.gradle.kts b/lexforge16/build.gradle.kts index 2d33ac1b..4fbdcb1e 100644 --- a/lexforge16/build.gradle.kts +++ b/lexforge16/build.gradle.kts @@ -13,8 +13,4 @@ unimined.minecraft { mojmap() parchment(mcVersion = "lexforge16_minecraft_version"(), version = "lexforge16_parchment_version"()) } -} - -dependencies { - "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file diff --git a/lexforge18/build.gradle.kts b/lexforge18/build.gradle.kts index 83a48a1a..c6a00643 100644 --- a/lexforge18/build.gradle.kts +++ b/lexforge18/build.gradle.kts @@ -16,6 +16,4 @@ unimined.minecraft { dependencies { compileOnly(project(":stubs")) - - "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") } \ No newline at end of file From 0138bb237eb83c8a1ba22fc54676ba5a1c4ca00b Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 17 May 2024 19:18:21 -0400 Subject: [PATCH 18/51] remove comment annotation --- .../dev/nolij/zume/impl/config/ZumeConfigImpl.java | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 2edddf48..551af03e 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -3,13 +3,10 @@ import dev.nolij.zson.Zson; import dev.nolij.zson.ZsonParser; import dev.nolij.zson.ZsonWriter; +import dev.nolij.zson.Comment; import dev.nolij.zume.impl.Zume; import java.io.*; -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -249,10 +246,4 @@ public static void init(final Path instanceConfigPath, final String fileName, fi throw new RuntimeException("Failed to create file watcher", e); } } - - @Target(ElementType.FIELD) - @Retention(RetentionPolicy.RUNTIME) - public @interface Comment { - String value(); - } } From 100674db1442fbec118e463839b6f06a4f33cf8e Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sun, 19 May 2024 19:51:28 -0400 Subject: [PATCH 19/51] update to zson 0.2 --- .../dev/nolij/zume/impl/config/ZumeConfigImpl.java | 4 ++-- build.gradle.kts | 11 ++++++++--- gradle.properties | 2 +- lexforge/build.gradle.kts | 2 -- neoforge/build.gradle.kts | 2 -- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 551af03e..d92c7d24 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -110,7 +110,7 @@ private static ZumeConfigImpl readFromFile(final File configFile) { int i = 0; while (true) { try { - return Zson.toObject(ZsonParser.parse(new FileReader(configFile)), ZumeConfigImpl.class); + return Zson.map2Obj(ZsonParser.parse(new FileReader(configFile)), ZumeConfigImpl.class); } catch (IllegalArgumentException e) { if (++i < MAX_RETRIES) { try { @@ -142,7 +142,7 @@ private static ZumeConfigImpl readConfigFile() { private void writeToFile(final File configFile) { this.configVersion = EXPECTED_VERSION; try (final FileWriter configWriter = new FileWriter(configFile)) { - ZSON.write(Zson.fromObject(this), configWriter); + ZSON.write(Zson.obj2Map(this), configWriter); configWriter.flush(); } catch (IOException e) { throw new RuntimeException("Failed to write config file", e); diff --git a/build.gradle.kts b/build.gradle.kts index 2b978965..3fdc816b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -171,11 +171,16 @@ allprojects { excludeGroup("ca.weblite") } } - mavenLocal() + mavenLocal { + content { + includeGroup("dev.nolij") + } + } maven("https://repo.spongepowered.org/maven") maven("https://jitpack.io/") - maven("https://api.modrinth.com/maven") { - content { + exclusiveContent { + forRepository { maven("https://api.modrinth.com/maven") } + filter { includeGroup("maven.modrinth") } } diff --git a/gradle.properties b/gradle.properties index 39b8099d..8901035e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -102,7 +102,7 @@ embeddium_neoforge_version = 0.3.20-git-7cfe318+mc1.20.6 # https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 # https://github.com/Nolij/ZSON/releases/ -zson_version = 0.1.0 +zson_version = 0.2.0 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core log4j_version = 3.0.0-beta2 # https://central.sonatype.com/artifact/org.slf4j/slf4j-api diff --git a/lexforge/build.gradle.kts b/lexforge/build.gradle.kts index 0067f600..632ec406 100644 --- a/lexforge/build.gradle.kts +++ b/lexforge/build.gradle.kts @@ -43,8 +43,6 @@ repositories { dependencies { compileOnly(project(":stubs")) - - "minecraftLibraries"("blue.endless:jankson:${"jankson_version"()}") // mixins fail to apply due to Unimined not liking Embeddium's empty mixin list; test in prod // modRuntimeOnly("org.embeddedt:embeddium-1.20.1:${"embeddium_lexforge_version"()}") diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index a454c606..81d51f93 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -34,7 +34,5 @@ repositories { dependencies { compileOnly(project(":stubs")) - "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") - modRuntimeOnly("org.embeddedt:embeddium-1.20.6:${"embeddium_neoforge_version"()}") } \ No newline at end of file From 0e3d9b83f67c7c4f8f3488040e54e82cc1dbadf6 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 20 May 2024 07:32:33 -0400 Subject: [PATCH 20/51] remove mavenlocal --- build.gradle.kts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 3fdc816b..7a80b351 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -171,11 +171,6 @@ allprojects { excludeGroup("ca.weblite") } } - mavenLocal { - content { - includeGroup("dev.nolij") - } - } maven("https://repo.spongepowered.org/maven") maven("https://jitpack.io/") exclusiveContent { @@ -289,7 +284,7 @@ subprojects { } } - if(implName in lexForgeImpls) { + if(implName in arrayOf(*lexForgeImpls, *neoForgeImpls)) { tasks.withType { mixinRemap { disableRefmap() @@ -382,7 +377,7 @@ tasks.shadowJar { } exclude("*.xcf") - exclude("LICENSE_ZSON") + exclude("LICENSE_zson") configurations = immutableListOf(shade) archiveClassifier = null From 5c2316a332d8b2d3b342a91ecede68bda424f0cd Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 20 May 2024 18:52:58 -0400 Subject: [PATCH 21/51] whitelist :( --- build.gradle.kts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7a80b351..b4ec954e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -394,10 +394,11 @@ tasks.shadowJar { duplicatesStrategy = DuplicatesStrategy.EXCLUDE exclude("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "pack.mcmeta") - filesMatching("**/*.class") { - if(this.name == "dev/nolij/zume/ForgeZumeBootstrapper.class") { - return@filesMatching - } + filesMatching(immutableListOf( + "dev/nolij/zume/lexforge/LexZume.class", + "dev/nolij/zume/lexforge18/LexZume18.class", + "dev/nolij/zume/lexforge16/LexZume16.class", + "dev/nolij/zume/vintage/VintageZume.class")) { val reader = ClassReader(this.open()) val node = ClassNode() reader.accept(node, 0) From acae3c78aeee995f9ff0bdde307cec3792bad9b8 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 20 May 2024 19:23:03 -0400 Subject: [PATCH 22/51] shade downgraded zson broken because jvmdg --- build.gradle.kts | 8 ++++---- legacy/build.gradle.kts | 3 ++- modern/build.gradle.kts | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index d9b20424..04b55224 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -235,7 +235,7 @@ subprojects { } dependencies { - implementation("dev.nolij:zson:${"zson_version"()}") + implementation("dev.nolij:zson:${"zson_version"()}:downgraded-8") } if (implName in uniminedImpls) { @@ -284,7 +284,7 @@ subprojects { } } - if(implName in arrayOf(*lexForgeImpls, *neoForgeImpls)) { + if(implName in lexForgeImpls) { tasks.withType { mixinRemap { disableRefmap() @@ -292,7 +292,7 @@ subprojects { } dependencies { - "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}") + "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}:downgraded-8") } } } @@ -319,7 +319,7 @@ val shade: Configuration by configurations.creating { } dependencies { - shade("dev.nolij:zson:${"zson_version"()}") + shade("dev.nolij:zson:${"zson_version"()}:downgraded-8") compileOnly("org.apache.logging.log4j:log4j-core:${"log4j_version"()}") diff --git a/legacy/build.gradle.kts b/legacy/build.gradle.kts index 7eb9c19c..db622815 100644 --- a/legacy/build.gradle.kts +++ b/legacy/build.gradle.kts @@ -16,7 +16,8 @@ unimined.minecraft { } tasks.withType { - mixinRemap { + mixinRemap { + enableMixinExtra() disableRefmap() } } diff --git a/modern/build.gradle.kts b/modern/build.gradle.kts index 2b362d8c..53cc8fd8 100644 --- a/modern/build.gradle.kts +++ b/modern/build.gradle.kts @@ -28,6 +28,7 @@ unimined.minecraft { tasks.withType { mixinRemap { + enableMixinExtra() disableRefmap() } } From f050c991ca9b0e3c291f0a5ce7427c8f6c169194 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Thu, 23 May 2024 21:16:32 -0400 Subject: [PATCH 23/51] bump zson + add icon fixed now --- .idea/icon.png | Bin 0 -> 1913 bytes gradle.properties | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) create mode 100644 .idea/icon.png diff --git a/.idea/icon.png b/.idea/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..49c93e134a9a99fc2f25229ebef0e4a5ab05f428 GIT binary patch literal 1913 zcmeAS@N?(olHy`uVBq!ia0vp^d?3uh1|;P@bT2Y6u<&I%I|pPtyF2IS=ibqo zoU_Go!pS#x=Vq!IKmM~MQ`1hwQQ+W;2a_NCk3Oibn6>(Cx9*}X0gG6gHGW+9<-YKe zIOpq~#+!Ff-jTic^qrs2=De?aey{l5J?;rRbfTx-Q)SYTTBrN;@}teipB*`3RdTTQ z0&ndFUG2W9T2s{+r5_*Kf9vggg=6=wf7|~3fBNfn0q%?)cUy0)u{fplD3#%#=+RBF z4J?koPjFsO`oVd`I%kf;Bca1v8Nwyz@qgHKe&$4@j(Arcja5DWj@<5Gf3Ey3iiN%S z!|gsB(-mtql}@{!G+RB(PxNdx!vsFzuBNx>G& zPD#glz0A!=1^%b*%;fy2%n-YKPiqm^N4q1*q1Ah2UX-j{Wq$F1_VOz;(*^D~SCk&K zId$xv%b%@=@pHIJ>w@O+JmZ&Rc<@L|cSF^8Ww{N$nOYsEd&4u#j(_U-vE!Lo8dL2% z-SkYW>lZASrgb^$yz74aNib}=-I4H>^QJrfjn~~Sa!l2>Ep84^$q9qfKVN^9h0mSI z@o18zIJZ=fs(#qkk4`7*!?&t05s2SbQs4jR&I#Y!lTR_u-#=gKX~1Op$!}xqj)>0a zJ?U_;rSgraL4vT$1O@)gn&^bZ%ekapWGsBKG-Kh9s}J7XKcxBdAH(*LtbZq7zqn}N zwCum~hYPC?z0U|$-osN@nX$U`0%ux*@)bi*ea}hFKV+09KQWM0T&yrj{bX=TPs&9r zFFw=b)0B!+KJUDErIJxOXuf&(p6(arj>rC`r_6Y;<@`~v`Q`#Q&fhqneQN6Uyf~}c zyzuVbZejCxUn_oDqLMC^rCW01)|I(M=l>sye|~*K{B!dto`39h%=NEthix}~ZE_}z zt9Dm@^bz;ZwtgvgOLaqY5;rei6logvi%I@8L+#Fr-5lv`(SM$NKWRTH`{egY@@n;u z?>(`5c&>PU(fq>u4JTqB=oQ5m#TUvK&v(zdQu*E_``!A*8@ZlkP7k~@-zn;bu8l@Y ztL>q~hf=)#Ux>D~a3<$0*sZ`)hz8;=!#%&}ojs)?^Lu@kXBRM0GWzk6Tc zn~ztDUT!+g_oydx?v|~yUUeNl`Q&jD*Lou@F`lOf7HGWQ^6?!A1BMFeBI?$?}FZAwVTe znIRD+5xzcF$@#f@i7EL>sd^Q;1t0|sHWgMtW^QUpqC!P(PF}H9g{=};g%ywu64qBz z04piUwpEJo4N!2-FG^J~(=*UBP_pAvP*AWbN=dT{a&d!d2l8x{GD=Dctn~HE%ggo3 zjrH=2()A53EiLs8jP#9+bb%^#i!1X=5-W7`ij^UTz|3(;Elw`VEGWs$&r<-Io0ybe zT4JlD1hNPYAnr`9$VAwbR}A$Q(1ZFQ8GS=N1AT1TN;1=MXamVWw1NEvvCal$m{mY# zMQTo@OJ;6rUNO*Vc18v^U|TRG5bi|M7=cS8k_3`QkUOmWi!xJzK?Dj2J3||N3^AyB z8+}kHA%z+wO2DGPII-ih(TB&c9oM?e{-=OZe!|nmF+@XjZjd40VFezO(0028_KvS+ zNUr?rxZO^}d;bN#x5k?cQXk633Wqkhq^LwYXar3@YF7UIumzJ;{Pj}B*7ih!koTIN zi-WYzeCC<{S=aWMjm2|^Y~3=|rcy1dmD<4@CT=ymmgB1t*FU$9z2W?Hg}(lD{!sU{ z5SNy%tw&ZJIeX}8&kdW|n+p#A>@j>Del%3!``3NqLJT66?;lrgbH8=p#Mhv2alyLt zbqpno^5#rYQu@;s_+vfC>`q;!eXUcBX16xFZDQCXkzgz^rG6_Y9ecX^xvX Date: Thu, 23 May 2024 22:14:27 -0400 Subject: [PATCH 24/51] - disable jar task for :integration - obfuscate mixin plugin - remove constructors from mixins (untested) - inline advzipInstalled --- .../dev/nolij/zumegradle/JarCompressing.kt | 96 ++++++++++++------- integration/build.gradle.kts | 1 + proguard.pro | 2 +- 3 files changed, 63 insertions(+), 36 deletions(-) create mode 100644 integration/build.gradle.kts diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 4336a695..f4d73f77 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -16,6 +16,7 @@ import org.gradle.kotlin.dsl.support.uppercaseFirstChar import org.objectweb.asm.ClassReader import org.objectweb.asm.ClassWriter import org.objectweb.asm.tree.ClassNode +import org.objectweb.asm.tree.MethodNode import proguard.Configuration import proguard.ConfigurationParser import proguard.ProGuard @@ -73,6 +74,10 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js bytes = remapFMJ(bytes, mappingsFile) } + if(name.endsWith("mixins.json") && mappingsFile.exists()) { + bytes = remapMixinConfig(bytes, mappingsFile) + } + if (jsonProcessing != JsonShrinkingType.NONE && name.endsWith(".json") || name.endsWith(".mcmeta") || name == "mcmod.info") { bytes = when (jsonProcessing) { @@ -96,34 +101,19 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js @Suppress("UNCHECKED_CAST") private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { - val mappingTree = MemoryMappingTree() - MappingReader.read(mappingsFile.toPath(), MappingFormat.PROGUARD, mappingTree) - - val dstNamespaceIndex = mappingTree.getNamespaceId(mappingTree.dstNamespaces[0]) + val mappings = mappings(mappingsFile) val json = (JsonSlurper().parse(bytes) as Map).toMutableMap() var entrypoints = (json["entrypoints"] as Map>?)?.toMutableMap() if (entrypoints == null) { throw IllegalStateException("fabric.mod.json does not contain entrypoints") } - - val mappings = mutableMapOf() - - @Suppress("INACCESSIBLE_TYPE") - for (clazz: ClassMapping in mappingTree.classes) { - val dst = clazz.getDstName(dstNamespaceIndex).replace('/', '.') - val src = clazz.srcName.replace('/', '.') - mappings[src] = dst - } val newEntrypoints = mutableMapOf>() for ((type, classes) in entrypoints) { for (old in classes) { - for ((src, dst) in mappings) { - if(src == old) { - newEntrypoints.computeIfAbsent(type) { mutableListOf() }.add(dst) - } - } + val obf = mappings.obfuscate(old) + newEntrypoints.computeIfAbsent(type) { mutableListOf() }.add(obf) } } @@ -132,8 +122,19 @@ private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { return JsonOutput.toJson(json).toByteArray() } +@Suppress("UNCHECKED_CAST") +private fun remapMixinConfig(bytes: ByteArray, mappingsFile: File): ByteArray { + val mappings = mappings(mappingsFile) + val json = (JsonSlurper().parse(bytes) as Map).toMutableMap() + val old = json["plugin"] as String + val obf = mappings.obfuscate(old) + println("Remapping mixin config $old to $obf") + json["plugin"] = obf + + return JsonOutput.toJson(json).toByteArray() +} + private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinkingType): ByteArray { - if(!classFileSettings.shouldRun()) return bytes val classNode = ClassNode() ClassReader(bytes).accept(classNode, 0) @@ -146,21 +147,24 @@ private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinking if (classFileSettings.shouldStripSourceFiles()) { classNode.sourceFile = null } + + if(classNode.invisibleAnnotations?.map { it.desc }?.contains("Lorg/spongepowered/asm/mixin/Mixin;") == true) { + classNode.methods.removeAll { it.name == "" } + } val writer = ClassWriter(0) classNode.accept(writer) return writer.toByteArray() } -val advzipInstalled = isAdvzipInstalled() - -private fun isAdvzipInstalled(): Boolean { - return try { +val advzipInstalled = { + try { ProcessBuilder("advzip", "-V").start().waitFor() == 0 } catch (e: Exception) { false } -} +}() + fun deflate(zip: File, type: JarShrinkingType) { if (type == JarShrinkingType.NONE) return @@ -185,7 +189,7 @@ val JAVA_HOME = System.getProperty("java.home") @Suppress("UnstableApiUsage") fun applyProguard(jar: File, minecraftConfigs: List, configDir: File) { val inputJar = jar.copyTo( - jar.parentFile.resolve("${jar.nameWithoutExtension}_.jar"), true).also { + jar.parentFile.resolve(".${jar.nameWithoutExtension}_proguardRunning.jar"), true).also { it.deleteOnExit() } @@ -209,16 +213,16 @@ fun applyProguard(jar: File, minecraftConfigs: List, configDir: libraries.add(minecraftConfig.getMinecraft(prodNamespace, prodNamespace).toFile().absolutePath) - libraries.addAll(minecraftConfig.mods.getClasspathAs(prodNamespace, prodNamespace, - listOf( - minecraftConfig.sourceSet.compileClasspath.files, - minecraftConfig.sourceSet.runtimeClasspath.files) - .flatten() - .filter { !minecraftConfig.isMinecraftJar(it.toPath()) } - .toHashSet()) - .filter { it.extension == "jar" } - .filter { !it.name.startsWith("zume") } - .map { it.absolutePath }) + val minecrafts = listOf( + minecraftConfig.sourceSet.compileClasspath.files, + minecraftConfig.sourceSet.runtimeClasspath.files) + .flatten() + .filter { it: File -> !minecraftConfig.isMinecraftJar(it.toPath()) } + .toHashSet() + + libraries += minecraftConfig.mods.getClasspathAs(prodNamespace, prodNamespace, minecrafts) + .filter { it.extension == "jar" && !it.name.startsWith("zume") } + .map { it.absolutePath } } proguardCommand.add("-libraryjars") @@ -292,4 +296,26 @@ open class CompressJarTask : DefaultTask() { squishJar(inputJar, classShrinkingType, jsonShrinkingType, mappingsFile) deflate(outputJar, jarShrinkingType) } +} + +fun mappings(file: File, format: MappingFormat = MappingFormat.PROGUARD): MemoryMappingTree { + if (!file.exists()) { + error("Mappings file $file does not exist") + } + + val mappingTree = MemoryMappingTree() + MappingReader.read(file.toPath(), format, mappingTree) + return mappingTree +} + +@Suppress("INACCESSIBLE_TYPE", "NAME_SHADOWING") +fun MemoryMappingTree.obfuscate(src: String): String { + val src = src.replace('.', '/') + val dstNamespaceIndex = getNamespaceId(dstNamespaces[0]) + val classMapping = getClass(src) as ClassMapping? + if (classMapping == null) { + println("Class $src not found in mappings") + return src + } + return classMapping.getDstName(dstNamespaceIndex).replace('/', '.') } \ No newline at end of file diff --git a/integration/build.gradle.kts b/integration/build.gradle.kts new file mode 100644 index 00000000..69fba217 --- /dev/null +++ b/integration/build.gradle.kts @@ -0,0 +1 @@ +tasks.jar { enabled = false } \ No newline at end of file diff --git a/proguard.pro b/proguard.pro index ef3a1fea..96daae69 100644 --- a/proguard.pro +++ b/proguard.pro @@ -11,7 +11,7 @@ -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields --keep,allowoptimization class dev.nolij.zume.ZumeMixinPlugin # dont rename mixin plugin +-keep,allowoptimization,allowobfuscation class dev.nolij.zume.ZumeMixinPlugin -keep @org.spongepowered.asm.mixin.Mixin class dev.nolij.zume.** { *; } # dont touch mixins # Forge entrypoints From 942f0509674fc8b02d266703843540c76417ea32 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 24 May 2024 10:33:27 +0800 Subject: [PATCH 25/51] - repackage mixins to zume.mixin --- build.gradle.kts | 3 +++ .../src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt | 2 ++ proguard.pro | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 04b55224..7e38964c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -405,6 +405,9 @@ tasks.shadowJar { } relocate("dev.nolij.zson", "dev.nolij.zume.zson") + if(releaseChannel.proguard) { + relocate("dev.nolij.zume.mixin", "zume.mixin") + } manifest { attributes( diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index f4d73f77..b580d699 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -131,6 +131,8 @@ private fun remapMixinConfig(bytes: ByteArray, mappingsFile: File): ByteArray { println("Remapping mixin config $old to $obf") json["plugin"] = obf + json["package"] = "zume.mixin" + return JsonOutput.toJson(json).toByteArray() } diff --git a/proguard.pro b/proguard.pro index 96daae69..8c574229 100644 --- a/proguard.pro +++ b/proguard.pro @@ -12,7 +12,7 @@ -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields -keep,allowoptimization,allowobfuscation class dev.nolij.zume.ZumeMixinPlugin --keep @org.spongepowered.asm.mixin.Mixin class dev.nolij.zume.** { *; } # dont touch mixins +-keep @org.spongepowered.asm.mixin.Mixin class ** { *; } # dont touch mixins # Forge entrypoints -keep,allowobfuscation @*.*.fml.common.Mod class dev.nolij.zume.** { From be29bb07497d737a38edaa9b22244880f9fba850 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 24 May 2024 13:26:12 -0400 Subject: [PATCH 26/51] - fix removing constructors (should only remove empty constructors now) - cache mapping tree - actually inline advzipInstalled - remove cast --- .../dev/nolij/zumegradle/JarCompressing.kt | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index b580d699..c3774637 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -66,16 +66,18 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js jar.delete() val json = JsonSlurper() + + val mappings = if (mappingsFile.exists()) mappings(mappingsFile) else null JarOutputStream(jar.outputStream()).use { out -> out.setLevel(Deflater.BEST_COMPRESSION) contents.forEach { var (name, bytes) = it if(name == "fabric.mod.json" && mappingsFile.exists()) { - bytes = remapFMJ(bytes, mappingsFile) + bytes = remapFMJ(bytes, mappings!!) } if(name.endsWith("mixins.json") && mappingsFile.exists()) { - bytes = remapMixinConfig(bytes, mappingsFile) + bytes = remapMixinConfig(bytes, mappings!!) } if (jsonProcessing != JsonShrinkingType.NONE && @@ -100,9 +102,7 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js } @Suppress("UNCHECKED_CAST") -private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { - val mappings = mappings(mappingsFile) - +private fun remapFMJ(bytes: ByteArray, mappings: MemoryMappingTree): ByteArray { val json = (JsonSlurper().parse(bytes) as Map).toMutableMap() var entrypoints = (json["entrypoints"] as Map>?)?.toMutableMap() if (entrypoints == null) { @@ -123,12 +123,10 @@ private fun remapFMJ(bytes: ByteArray, mappingsFile: File): ByteArray { } @Suppress("UNCHECKED_CAST") -private fun remapMixinConfig(bytes: ByteArray, mappingsFile: File): ByteArray { - val mappings = mappings(mappingsFile) +private fun remapMixinConfig(bytes: ByteArray, mappings: MemoryMappingTree): ByteArray { val json = (JsonSlurper().parse(bytes) as Map).toMutableMap() val old = json["plugin"] as String val obf = mappings.obfuscate(old) - println("Remapping mixin config $old to $obf") json["plugin"] = obf json["package"] = "zume.mixin" @@ -151,7 +149,7 @@ private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinking } if(classNode.invisibleAnnotations?.map { it.desc }?.contains("Lorg/spongepowered/asm/mixin/Mixin;") == true) { - classNode.methods.removeAll { it.name == "" } + classNode.methods.removeAll { it.name == "" && it.instructions.size() <= 3 } // ALOAD, super(), RETURN } val writer = ClassWriter(0) @@ -159,13 +157,11 @@ private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinking return writer.toByteArray() } -val advzipInstalled = { - try { - ProcessBuilder("advzip", "-V").start().waitFor() == 0 - } catch (e: Exception) { - false - } -}() +val advzipInstalled = try { + ProcessBuilder("advzip", "-V").start().waitFor() == 0 +} catch (e: Exception) { + false +} fun deflate(zip: File, type: JarShrinkingType) { @@ -314,7 +310,7 @@ fun mappings(file: File, format: MappingFormat = MappingFormat.PROGUARD): Memory fun MemoryMappingTree.obfuscate(src: String): String { val src = src.replace('.', '/') val dstNamespaceIndex = getNamespaceId(dstNamespaces[0]) - val classMapping = getClass(src) as ClassMapping? + val classMapping: ClassMapping? = getClass(src) if (classMapping == null) { println("Class $src not found in mappings") return src From 5400383453754afad77a71326f0b08e6e9cdaec0 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 24 May 2024 17:50:13 -0400 Subject: [PATCH 27/51] file separator fix probably makes it work on windows, idk --- buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index c3774637..a35393f3 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -224,7 +224,7 @@ fun applyProguard(jar: File, minecraftConfigs: List, configDir: } proguardCommand.add("-libraryjars") - proguardCommand.add(libraries.joinToString(":") { "\"$it\"" }) + proguardCommand.add(libraries.joinToString(File.separator) { "\"$it\"" }) val configuration = Configuration() ConfigurationParser(proguardCommand.toTypedArray(), System.getProperties()).use { parser -> From 39ff1305d6a2e026cd3ec3955138db5d7787355a Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 24 May 2024 18:06:41 -0400 Subject: [PATCH 28/51] =?UTF-8?q?=F0=9F=97=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index a35393f3..e95fad78 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -224,7 +224,7 @@ fun applyProguard(jar: File, minecraftConfigs: List, configDir: } proguardCommand.add("-libraryjars") - proguardCommand.add(libraries.joinToString(File.separator) { "\"$it\"" }) + proguardCommand.add(libraries.joinToString(File.pathSeparator) { "\"$it\"" }) val configuration = Configuration() ConfigurationParser(proguardCommand.toTypedArray(), System.getProperties()).use { parser -> From 7f3293d07576356edd5c67538fcf0f32acf68ad7 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 24 May 2024 18:18:08 -0400 Subject: [PATCH 29/51] rename JarShrinkingType to DeflateAlgorithm [skip ci] --- build.gradle.kts | 16 +++++++------- .../dev/nolij/zumegradle/JarCompressing.kt | 22 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7e38964c..824a73b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,7 @@ @file:Suppress("UnstableApiUsage") import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import dev.nolij.zumegradle.ClassShrinkingType -import dev.nolij.zumegradle.JarShrinkingType +import dev.nolij.zumegradle.DeflateAlgorithm import dev.nolij.zumegradle.JsonShrinkingType import dev.nolij.zumegradle.MixinConfigMergingTransformer import dev.nolij.zumegradle.CompressJarTask @@ -37,12 +37,12 @@ plugins { operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") enum class ReleaseChannel( - val suffix: String? = null, - val releaseType: ReleaseType? = null, - val deflation: JarShrinkingType = JarShrinkingType.SEVENZIP, - val classes: ClassShrinkingType = ClassShrinkingType.STRIP_ALL, - val json: JsonShrinkingType = JsonShrinkingType.MINIFY, - val proguard: Boolean = true, + val suffix: String? = null, + val releaseType: ReleaseType? = null, + val deflation: DeflateAlgorithm = DeflateAlgorithm.SEVENZIP, + val classes: ClassShrinkingType = ClassShrinkingType.STRIP_ALL, + val json: JsonShrinkingType = JsonShrinkingType.MINIFY, + val proguard: Boolean = true, ) { DEV_BUILD( suffix = "dev", @@ -426,7 +426,7 @@ val compressJar = tasks.register("compressJar") { val shadowJar = tasks.shadowJar.get() inputJar = shadowJar.archiveFile.get().asFile - jarShrinkingType = releaseChannel.deflation + deflateAlgorithm = releaseChannel.deflation classShrinkingType = releaseChannel.classes jsonShrinkingType = releaseChannel.json if (releaseChannel.proguard) { diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index e95fad78..58bd97c1 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -16,7 +16,6 @@ import org.gradle.kotlin.dsl.support.uppercaseFirstChar import org.objectweb.asm.ClassReader import org.objectweb.asm.ClassWriter import org.objectweb.asm.tree.ClassNode -import org.objectweb.asm.tree.MethodNode import proguard.Configuration import proguard.ConfigurationParser import proguard.ProGuard @@ -27,7 +26,7 @@ import java.util.jar.JarFile import java.util.jar.JarOutputStream import java.util.zip.Deflater -enum class JarShrinkingType(val id: Int?) { +enum class DeflateAlgorithm(val id: Int?) { NONE(null), LIBDEFLATE(2), SEVENZIP(3), @@ -163,9 +162,8 @@ val advzipInstalled = try { false } - -fun deflate(zip: File, type: JarShrinkingType) { - if (type == JarShrinkingType.NONE) return +fun deflate(zip: File, type: DeflateAlgorithm) { + if (type == DeflateAlgorithm.NONE) return if (!advzipInstalled) { println("advzip is not installed; skipping re-deflation of $zip") return @@ -249,7 +247,7 @@ open class CompressJarTask : DefaultTask() { get() = if (useProguard) ClassShrinkingType.STRIP_NONE else field @Input - var jarShrinkingType = JarShrinkingType.LIBDEFLATE + var deflateAlgorithm = DeflateAlgorithm.LIBDEFLATE @Input var jsonShrinkingType = JsonShrinkingType.NONE @@ -270,11 +268,11 @@ open class CompressJarTask : DefaultTask() { classShrinkingType = ClassShrinkingType.valueOf(value.uppercase()) } - @Option(option = "compression-type", description = "How to compress the jar") - fun setJarShrinkingType(value: String) { - jarShrinkingType = value.uppercase().let { - if(it.matches(Regex("7Z(?:IP)?"))) JarShrinkingType.SEVENZIP - else JarShrinkingType.valueOf(it) + @Option(option = "compression-type", description = "How to recompress the jar") + fun setDeflateAlgorithm(value: String) { + deflateAlgorithm = value.uppercase().let { + if(it.matches(Regex("7Z(?:IP)?"))) DeflateAlgorithm.SEVENZIP + else DeflateAlgorithm.valueOf(it) } } @@ -292,7 +290,7 @@ open class CompressJarTask : DefaultTask() { if (useProguard) applyProguard(inputJar, minecraftConfigs, project.rootDir) squishJar(inputJar, classShrinkingType, jsonShrinkingType, mappingsFile) - deflate(outputJar, jarShrinkingType) + deflate(outputJar, deflateAlgorithm) } } From 545f16980cf0e72c1b381c8ceabaafd260af2200 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Sat, 25 May 2024 12:26:03 -0400 Subject: [PATCH 30/51] stop jabel from making the jvm throw a hissy fit --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7e278d99..307b8ec3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Gradle -org.gradle.jvmargs = -Xmx8G +org.gradle.jvmargs = -Xmx8G -XX:+EnableDynamicAgentLoading org.gradle.daemon = true org.gradle.parallel = true org.gradle.caching = true From 5cfebbc3acc19158bf49a8bdf7db3c8fa6d74ccf Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 27 May 2024 20:52:03 -0400 Subject: [PATCH 31/51] use Paths.get why not --- .../java/dev/nolij/zume/impl/config/ZumeConfigImpl.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index d92c7d24..94433314 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -7,9 +7,9 @@ import dev.nolij.zume.impl.Zume; import java.io.*; -import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.Paths; import java.util.function.Consumer; public class ZumeConfigImpl { @@ -177,9 +177,9 @@ public static void replace(final ZumeConfigImpl newConfig) throws InterruptedExc static { final Path dotMinecraft = switch (Zume.HOST_PLATFORM) { - case LINUX, UNKNOWN -> FileSystems.getDefault().getPath(System.getProperty("user.home"), ".minecraft"); - case WINDOWS -> FileSystems.getDefault().getPath(System.getenv("APPDATA"), ".minecraft"); - case MAC_OS -> FileSystems.getDefault().getPath(System.getProperty("user.home"), "Library", "Application Support", "minecraft"); + case LINUX, UNKNOWN -> Paths.get(System.getProperty("user.home"), ".minecraft"); + case WINDOWS -> Paths.get(System.getenv("APPDATA"), ".minecraft"); + case MAC_OS -> Paths.get(System.getProperty("user.home"), "Library", "Application Support", "minecraft"); }; GLOBAL_CONFIG_PATH = dotMinecraft.resolve("global"); From 6659e85c8f6a1e9416a556d2cf380468f42b8f3c Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 27 May 2024 21:05:16 -0400 Subject: [PATCH 32/51] bigfix --- .../kotlin/dev/nolij/zumegradle/JarCompressing.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 58bd97c1..6e18b064 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -52,7 +52,7 @@ enum class JsonShrinkingType { NONE, MINIFY, PRETTY_PRINT } -fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: JsonShrinkingType, mappingsFile: File) { +fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: JsonShrinkingType, mappingsFile: File?) { val contents = linkedMapOf() JarFile(jar).use { it.entries().asIterator().forEach { entry -> @@ -66,16 +66,17 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js val json = JsonSlurper() - val mappings = if (mappingsFile.exists()) mappings(mappingsFile) else null + val isObfuscating = mappingsFile?.exists() == true + val mappings = if (isObfuscating) mappings(mappingsFile!!) else null JarOutputStream(jar.outputStream()).use { out -> out.setLevel(Deflater.BEST_COMPRESSION) contents.forEach { var (name, bytes) = it - if(name == "fabric.mod.json" && mappingsFile.exists()) { + if(name == "fabric.mod.json" && isObfuscating) { bytes = remapFMJ(bytes, mappings!!) } - if(name.endsWith("mixins.json") && mappingsFile.exists()) { + if(name.endsWith("mixins.json") && isObfuscating) { bytes = remapMixinConfig(bytes, mappings!!) } @@ -261,7 +262,10 @@ open class CompressJarTask : DefaultTask() { val outputJar get() = inputJar // compressed jar will replace the input jar @get:OutputFile - val mappingsFile get() = inputJar.parentFile.resolve("${inputJar.nameWithoutExtension}-mappings.txt") + val mappingsFile + get() = if(useProguard) + inputJar.parentFile.resolve("${inputJar.nameWithoutExtension}-mappings.txt") + else null @Option(option = "class-file-compression", description = "How to process class files") fun setClassShrinkingType(value: String) { From a3da683f6507ee7235fbe59ce28d2a8aeeff282b Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Mon, 27 May 2024 21:42:55 -0400 Subject: [PATCH 33/51] fix proguard config a little bit --- proguard.pro | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/proguard.pro b/proguard.pro index 8c574229..8346d85e 100644 --- a/proguard.pro +++ b/proguard.pro @@ -12,7 +12,7 @@ -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields -keep,allowoptimization,allowobfuscation class dev.nolij.zume.ZumeMixinPlugin --keep @org.spongepowered.asm.mixin.Mixin class ** { *; } # dont touch mixins +-keep @org.spongepowered.asm.mixin.Mixin class * { *; } # dont touch mixins # Forge entrypoints -keep,allowobfuscation @*.*.fml.common.Mod class dev.nolij.zume.** { @@ -27,13 +27,9 @@ } # screens --keepclassmembers class dev.nolij.zume.** extends net.minecraft.class_437 { - public *; -} --keepclassmembers class dev.nolij.zume.** extends net.minecraft.client.gui.screens.Screen { - public *; -} --keepclassmembers class dev.nolij.zume.** extends net.minecraft.client.gui.screen.Screen { +-keepclassmembers class dev.nolij.zume.** extends net.minecraft.class_437, + net.minecraft.client.gui.screens.Screen, + net.minecraft.client.gui.screen.Screen { public *; } From 6103f69231d855f57a439765116b6c9e7128cc02 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 28 May 2024 09:37:52 -0400 Subject: [PATCH 34/51] move plugin version declarations to gradle.properties --- build.gradle.kts | 1 + buildSrc/build.gradle.kts | 34 ++++++++++++++++------------------ gradle.properties | 20 +++++++++++++++++++- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 824a73b1..cf9c92bc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,6 +26,7 @@ import java.nio.file.Files import java.time.ZonedDateTime plugins { + idea id("java") id("maven-publish") id("com.github.johnrengelman.shadow") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 1609b136..4d983202 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.* + plugins { `kotlin-dsl` } @@ -20,24 +22,20 @@ fun DependencyHandler.plugin(id: String, version: String) { this.implementation(group = id, name = "$id.gradle.plugin", version = version) } -dependencies { - // https://central.sonatype.com/artifact/org.ow2.asm/asm-tree - implementation("org.ow2.asm:asm-tree:9.7") - implementation("net.fabricmc:mapping-io:0.3.0") +val properties = Properties() +properties.load(file("build.gradle.kts").parentFile.parentFile.resolve("gradle.properties").inputStream()) - // https://central.sonatype.com/artifact/org.apache.ant/ant - implementation("org.apache.ant:ant:1.10.14") +operator fun String.invoke(): String = properties.getProperty(this) ?: error("Property $this not found") + +dependencies { + implementation("org.ow2.asm:asm-tree:${"asm_version"()}") + implementation("net.fabricmc:mapping-io:${"mapping_io_version"()}") + implementation("org.apache.ant:ant:${"shadow_ant_version"()}") + implementation("com.guardsquare:proguard-base:${"proguard_version"()}") - // https://central.sonatype.com/artifact/com.guardsquare/proguard-base - implementation("com.guardsquare:proguard-base:7.4.2") - // https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow - plugin(id = "com.github.johnrengelman.shadow", version = "8.1.1") - // https://github.com/unimined/unimined/releases/latest - plugin(id = "xyz.wagyourtail.unimined", version = "1.2.6") - // https://plugins.gradle.org/plugin/com.github.gmazzo.buildconfig - plugin(id = "com.github.gmazzo.buildconfig", version = "5.3.5") - // https://github.com/ajoberstar/grgit/releases/latest - plugin(id = "org.ajoberstar.grgit", version = "5.2.2") - // https://plugins.gradle.org/plugin/me.modmuss50.mod-publish-plugin - plugin(id = "me.modmuss50.mod-publish-plugin", version = "0.5.1") + plugin(id = "com.github.johnrengelman.shadow", version = "shadow_version"()) + plugin(id = "xyz.wagyourtail.unimined", version = "unimined_version"()) + plugin(id = "com.github.gmazzo.buildconfig", version = "buildconfig_version"()) + plugin(id = "org.ajoberstar.grgit", version = "grgit_version"()) + plugin(id = "me.modmuss50.mod-publish-plugin", version = "mod_publish_version"()) } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 307b8ec3..3fdb3d8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -116,4 +116,22 @@ mixin_version = 0.8.5 # https://github.com/LlamaLad7/MixinExtras/releases/latest mixinextras_version = 0.2.1 # https://central.sonatype.com/artifact/org.jetbrains/annotations -jetbrains_annotations_version = 24.1.0 \ No newline at end of file +jetbrains_annotations_version = 24.1.0 + +# Gradle Plugins +# https://maven.fabricmc.net/net/fabricmc/mapping-io/ +mapping_io_version = 0.3.0 +# https://github.com/johnrengelman/shadow/blob/main/gradle/dependencies.gradle +shadow_ant_version = 1.10.4 +# https://plugins.gradle.org/plugin/com.github.johnrengelman.shadow +shadow_version = 8.1.1 +# https://central.sonatype.com/artifact/com.guardsquare/proguard-base +proguard_version = 7.4.2 +# https://github.com/unimined/unimined/releases/latest +unimined_version = 1.2.6 +# https://plugins.gradle.org/plugin/com.github.gmazzo.buildconfig +buildconfig_version = 5.3.5 +# https://github.com/ajoberstar/grgit/releases/latest +grgit_version = 5.2.2 +# https://plugins.gradle.org/plugin/me.modmuss50.mod-publish-plugin +mod_publish_version = 0.5.1 \ No newline at end of file From 2361de9f605153b808af9e04c9c68ae10ee2728b Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 28 May 2024 09:48:35 -0400 Subject: [PATCH 35/51] remove idea plugin why did i put that there --- build.gradle.kts | 1 - buildSrc/build.gradle.kts | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index cf9c92bc..824a73b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -26,7 +26,6 @@ import java.nio.file.Files import java.time.ZonedDateTime plugins { - idea id("java") id("maven-publish") id("com.github.johnrengelman.shadow") diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 4d983202..675a30fe 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -22,8 +22,9 @@ fun DependencyHandler.plugin(id: String, version: String) { this.implementation(group = id, name = "$id.gradle.plugin", version = version) } -val properties = Properties() -properties.load(file("build.gradle.kts").parentFile.parentFile.resolve("gradle.properties").inputStream()) +val properties = Properties().apply { + load(rootDir.parentFile.resolve("gradle.properties").inputStream()) +} operator fun String.invoke(): String = properties.getProperty(this) ?: error("Property $this not found") From 20cbb60eeef3a6a28eb3ac905ba19f8a12ea13d7 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 28 May 2024 16:59:40 -0400 Subject: [PATCH 36/51] Include mappings in CI --- .github/workflows/build.yml | 4 +++- .github/workflows/pull_request.yml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d52b26c7..3ba99926 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,4 +22,6 @@ jobs: uses: actions/upload-artifact@v3 with: name: zume - path: "**/zume-*.jar" + path: | + **/zume-*.jar + **/*mappings.txt diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index f0805fa0..4b3f2555 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -23,4 +23,6 @@ jobs: uses: actions/upload-artifact@v3 with: name: zume - path: "**/zume-*.jar" + path: | + **/zume-*.jar + **/*mappings.txt From 604bf0f6890f5fe2860737e2a9d1834a179bdec7 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 28 May 2024 17:53:34 -0400 Subject: [PATCH 37/51] Prevent ProGuard from optimizing out mixin plugin methods --- proguard.pro | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 8346d85e..b5c9f339 100644 --- a/proguard.pro +++ b/proguard.pro @@ -11,7 +11,9 @@ -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields --keep,allowoptimization,allowobfuscation class dev.nolij.zume.ZumeMixinPlugin +-keepclassmembers class dev.nolij.zume.ZumeMixinPlugin { + public *; +} -keep @org.spongepowered.asm.mixin.Mixin class * { *; } # dont touch mixins # Forge entrypoints From 4b290528ae35a6ef1a9c9bfd7b7b23a35ae9e4db Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 28 May 2024 18:04:20 -0400 Subject: [PATCH 38/51] Fix compiling non-proguard builds --- buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 6e18b064..8b168293 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -9,6 +9,7 @@ import net.fabricmc.mappingio.tree.MemoryMappingTree import org.gradle.api.DefaultTask import org.gradle.api.tasks.Input import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.Optional import org.gradle.api.tasks.OutputFile import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.options.Option @@ -262,6 +263,7 @@ open class CompressJarTask : DefaultTask() { val outputJar get() = inputJar // compressed jar will replace the input jar @get:OutputFile + @get:Optional val mappingsFile get() = if(useProguard) inputJar.parentFile.resolve("${inputJar.nameWithoutExtension}-mappings.txt") From c6a11ec919c82bf4cd901173a660c70d1a9d976f Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 28 May 2024 21:28:38 -0400 Subject: [PATCH 39/51] allow optimization on mixin config class members --- proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index b5c9f339..3b01ae14 100644 --- a/proguard.pro +++ b/proguard.pro @@ -11,7 +11,7 @@ -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields --keepclassmembers class dev.nolij.zume.ZumeMixinPlugin { +-keep,allowobfuscation,allowoptimization class dev.nolij.zume.ZumeMixinPlugin { public *; } -keep @org.spongepowered.asm.mixin.Mixin class * { *; } # dont touch mixins From 18696363dfdae0da4c7039ac3f3ec9b73cf9a705 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Tue, 28 May 2024 21:37:40 -0400 Subject: [PATCH 40/51] bruh --- proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 3b01ae14..1850a522 100644 --- a/proguard.pro +++ b/proguard.pro @@ -11,7 +11,7 @@ -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields --keep,allowobfuscation,allowoptimization class dev.nolij.zume.ZumeMixinPlugin { +-keepclassmembers,allowoptimization class dev.nolij.zume.ZumeMixinPlugin { public *; } -keep @org.spongepowered.asm.mixin.Mixin class * { *; } # dont touch mixins From c63679ff808bac7cc269f2fca6455bae81741657 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 28 May 2024 21:48:47 -0400 Subject: [PATCH 41/51] Do not devirtualize methods --- proguard.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index 1850a522..f7b65eb4 100644 --- a/proguard.pro +++ b/proguard.pro @@ -1,7 +1,7 @@ -ignorewarnings -dontnote -optimizationpasses 10 --optimizations !class/merging/*,!method/marking/private,!*/specialization/*,!method/removal/parameter +-optimizations !class/merging/*,!method/marking/private,!method/marking/static,!*/specialization/*,!method/removal/parameter -allowaccessmodification #noinspection ShrinkerInvalidFlags -optimizeaggressively From def90b7c778bbb360f4e8d997546ad81ce4f8882 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Tue, 28 May 2024 22:16:33 -0400 Subject: [PATCH 42/51] Fix ProGuard rule not applying due to package rename --- proguard.pro | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proguard.pro b/proguard.pro index f7b65eb4..534d198f 100644 --- a/proguard.pro +++ b/proguard.pro @@ -8,6 +8,7 @@ -overloadaggressively -repackageclasses zume -keepattributes Runtime*Annotations # keep annotations +-keepattributes SourceFile,LineNumberTable -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields @@ -22,7 +23,7 @@ } # Platform implementations --keep,allowobfuscation class dev.nolij.zume.** implements dev.nolij.zume.api.platform.v0.IZumeImplementation { +-keep,allowobfuscation class dev.nolij.zume.** implements dev.nolij.zume.api.platform.v?.IZumeImplementation { # Forge Event Subscribers @*.*.fml.common.Mod$EventHandler ; @*.*.fml.common.eventhandler.SubscribeEvent ; From 5bd3fcc7e5678907d3d18e6908742865defba09c Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Thu, 30 May 2024 17:44:19 -0400 Subject: [PATCH 43/51] add a gradle property (from command line/code pending) to keep debug attributes in source files --- .../kotlin/dev/nolij/zumegradle/JarCompressing.kt | 14 ++++++++++++++ proguard.pro | 1 - 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 8b168293..6735ae75 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -22,6 +22,7 @@ import proguard.ConfigurationParser import proguard.ProGuard import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig import java.io.File +import java.util.Properties import java.util.jar.JarEntry import java.util.jar.JarFile import java.util.jar.JarOutputStream @@ -223,6 +224,19 @@ fun applyProguard(jar: File, minecraftConfigs: List, configDir: .map { it.absolutePath } } + val debug = Properties().apply { + val gradleproperties = configDir.resolve("gradle.properties") + if(gradleproperties.exists()) { + load(gradleproperties.inputStream()) + } + }.getProperty("zumegradle.proguard.keepAttrs").toBoolean() + + if(debug) { + proguardCommand.add("-keepattributes") + proguardCommand.add("*Annotation*,SourceFile,MethodParameters,L*Table") + proguardCommand.add("-dontobfuscate") + } + proguardCommand.add("-libraryjars") proguardCommand.add(libraries.joinToString(File.pathSeparator) { "\"$it\"" }) diff --git a/proguard.pro b/proguard.pro index 534d198f..230f6c9e 100644 --- a/proguard.pro +++ b/proguard.pro @@ -8,7 +8,6 @@ -overloadaggressively -repackageclasses zume -keepattributes Runtime*Annotations # keep annotations --keepattributes SourceFile,LineNumberTable -keep,allowoptimization public class dev.nolij.zume.api.** { public *; } # public APIs -keepclassmembers class dev.nolij.zume.impl.config.ZumeConfigImpl { public ; } # dont rename config fields From a20fc7d7228e8a7f880cd9500e0524d4a27329d2 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 30 May 2024 21:29:32 -0400 Subject: [PATCH 44/51] Reduce heap size for sanity --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3fdb3d8b..340e55a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Gradle -org.gradle.jvmargs = -Xmx8G -XX:+EnableDynamicAgentLoading +org.gradle.jvmargs = -Xmx4G -XX:+EnableDynamicAgentLoading org.gradle.daemon = true org.gradle.parallel = true org.gradle.caching = true From c6ceddc8733c872778b0b76c89537ff19adf6f62 Mon Sep 17 00:00:00 2001 From: embeddedt <42941056+embeddedt@users.noreply.github.com> Date: Thu, 30 May 2024 21:30:09 -0400 Subject: [PATCH 45/51] Bump ZSON --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 340e55a4..93a4b596 100644 --- a/gradle.properties +++ b/gradle.properties @@ -102,7 +102,7 @@ embeddium_neoforge_version = 0.3.20-git-7cfe318+mc1.20.6 # https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 # https://github.com/Nolij/ZSON/releases/ -zson_version = 0.2.1 +zson_version = 0.2.3 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core log4j_version = 3.0.0-beta2 # https://central.sonatype.com/artifact/org.slf4j/slf4j-api From a92261e7ef320ba7375377b89da817d94517faee Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Thu, 30 May 2024 21:58:31 -0400 Subject: [PATCH 46/51] run formatter, remove unused stuff from editorconfig --- .editorconfig | 198 +----------------- .github/workflows/dco.yml | 10 +- CHANGELOG.md | 3 +- README.md | 42 ++-- .../api/platform/v1/IZumeImplementation.java | 19 +- .../nolij/zume/api/platform/v1/ZumeAPI.java | 18 +- .../zume/api/util/v1/MethodHandleHelper.java | 7 +- .../java/dev/nolij/zume/impl/EasedDouble.java | 2 +- .../nolij/zume/impl/IZumeImplementation.java | 2 + .../main/java/dev/nolij/zume/impl/Zume.java | 16 +- .../nolij/zume/impl/config/FileWatcher.java | 2 +- .../nolij/zume/impl/config/IFileWatcher.java | 2 + .../zume/impl/config/ZumeConfigImpl.java | 43 ++-- archaic/build.gradle.kts | 4 +- .../dev/nolij/zume/archaic/ArchaicZume.java | 14 +- .../mixin/archaic/EntityRendererAccessor.java | 10 +- .../mixin/archaic/EntityRendererMixin.java | 16 +- build.gradle.kts | 182 ++++++++-------- buildSrc/build.gradle.kts | 2 +- .../dev/nolij/zumegradle/JarCompressing.kt | 110 +++++----- .../MixinConfigMergingTransformer.kt | 14 +- gradle.properties | 2 +- integration/embeddium/build.gradle.kts | 6 +- .../embeddium/ZumeEmbeddiumConfigScreen.java | 6 +- legacy/build.gradle.kts | 7 +- .../dev/nolij/zume/legacy/LegacyZume.java | 9 +- .../mixin/legacy/GameRendererAccessor.java | 6 + .../zume/mixin/legacy/GameRendererMixin.java | 2 +- .../zume/mixin/legacy/KeyBindingMixin.java | 6 +- .../main/resources/zume-legacy.mixins.json | 4 +- lexforge/build.gradle.kts | 16 +- .../java/dev/nolij/zume/lexforge/LexZume.java | 16 +- .../zume/mixin/lexforge/CameraMixin.java | 2 +- .../dev/nolij/zume/lexforge16/LexZume16.java | 2 +- .../zume/mixin/lexforge16/CameraMixin.java | 2 +- .../dev/nolij/zume/lexforge18/LexZume18.java | 2 +- .../zume/mixin/lexforge18/CameraMixin.java | 2 +- modern/build.gradle.kts | 8 +- .../nolij/zume/mixin/modern/CameraMixin.java | 2 +- .../zume/mixin/modern/MouseHandlerMixin.java | 4 +- .../dev/nolij/zume/modern/ModernZume.java | 2 +- .../modmenu/ZumeModMenuIntegration.java | 12 +- neoforge/build.gradle.kts | 4 +- .../java/dev/nolij/zume/neoforge/NeoZume.java | 32 ++- primitive/build.gradle.kts | 15 +- .../mixin/primitive/GameRendererAccessor.java | 1 + .../mixin/primitive/GameRendererMixin.java | 4 +- .../nolij/zume/primitive/PrimitiveZume.java | 2 +- settings.gradle.kts | 8 +- .../nolij/zume/FabricZumeBootstrapper.java | 10 +- .../dev/nolij/zume/ForgeZumeBootstrapper.java | 12 +- .../java/dev/nolij/zume/ZumeMixinPlugin.java | 15 +- .../net/minecraftforge/fml/common/Mod.java | 6 +- .../mixin/vintage/EntityRendererMixin.java | 8 +- .../dev/nolij/zume/vintage/VintageZume.java | 4 +- 55 files changed, 422 insertions(+), 533 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9078b44c..050ac30b 100644 --- a/.editorconfig +++ b/.editorconfig @@ -131,7 +131,7 @@ ij_java_for_statement_wrap = off ij_java_generate_final_locals = false ij_java_generate_final_parameters = false ij_java_if_brace_force = never -ij_java_imports_layout = *,|,javax.**,java.**,|,$* +ij_java_imports_layout = *, |, javax.**, java.**, |, $* ij_java_indent_case_from_switch = true ij_java_insert_inner_class_imports = false ij_java_insert_override_annotation = true @@ -168,7 +168,7 @@ ij_java_names_count_to_use_import_on_demand = 3 ij_java_new_line_after_lparen_in_annotation = false ij_java_new_line_after_lparen_in_deconstruction_pattern = true ij_java_new_line_after_lparen_in_record_header = false -ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.* +ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.* ij_java_parameter_annotation_wrap = off ij_java_parentheses_expression_new_line_after_left_paren = false ij_java_parentheses_expression_right_paren_on_new_line = false @@ -291,196 +291,6 @@ ij_java_wrap_comments = false ij_java_wrap_first_method_in_call_chain = false ij_java_wrap_long_lines = false -[{*.gant,*.groovy,*.gy}] -ij_smart_tabs = false -ij_groovy_align_group_field_declarations = false -ij_groovy_align_multiline_array_initializer_expression = false -ij_groovy_align_multiline_assignment = false -ij_groovy_align_multiline_binary_operation = false -ij_groovy_align_multiline_chained_methods = false -ij_groovy_align_multiline_extends_list = false -ij_groovy_align_multiline_for = true -ij_groovy_align_multiline_list_or_map = true -ij_groovy_align_multiline_method_parentheses = false -ij_groovy_align_multiline_parameters = true -ij_groovy_align_multiline_parameters_in_calls = false -ij_groovy_align_multiline_resources = true -ij_groovy_align_multiline_ternary_operation = false -ij_groovy_align_multiline_throws_list = false -ij_groovy_align_named_args_in_map = true -ij_groovy_align_throws_keyword = false -ij_groovy_array_initializer_new_line_after_left_brace = false -ij_groovy_array_initializer_right_brace_on_new_line = false -ij_groovy_array_initializer_wrap = off -ij_groovy_assert_statement_wrap = off -ij_groovy_assignment_wrap = off -ij_groovy_binary_operation_wrap = off -ij_groovy_blank_lines_after_class_header = 0 -ij_groovy_blank_lines_after_imports = 1 -ij_groovy_blank_lines_after_package = 1 -ij_groovy_blank_lines_around_class = 1 -ij_groovy_blank_lines_around_field = 0 -ij_groovy_blank_lines_around_field_in_interface = 0 -ij_groovy_blank_lines_around_method = 1 -ij_groovy_blank_lines_around_method_in_interface = 1 -ij_groovy_blank_lines_before_imports = 1 -ij_groovy_blank_lines_before_method_body = 0 -ij_groovy_blank_lines_before_package = 0 -ij_groovy_block_brace_style = end_of_line -ij_groovy_block_comment_add_space = false -ij_groovy_block_comment_at_first_column = true -ij_groovy_call_parameters_new_line_after_left_paren = false -ij_groovy_call_parameters_right_paren_on_new_line = false -ij_groovy_call_parameters_wrap = off -ij_groovy_catch_on_new_line = false -ij_groovy_class_annotation_wrap = split_into_lines -ij_groovy_class_brace_style = end_of_line -ij_groovy_class_count_to_use_import_on_demand = 5 -ij_groovy_do_while_brace_force = never -ij_groovy_else_on_new_line = false -ij_groovy_enable_groovydoc_formatting = true -ij_groovy_enum_constants_wrap = off -ij_groovy_extends_keyword_wrap = off -ij_groovy_extends_list_wrap = off -ij_groovy_field_annotation_wrap = split_into_lines -ij_groovy_finally_on_new_line = false -ij_groovy_for_brace_force = never -ij_groovy_for_statement_new_line_after_left_paren = false -ij_groovy_for_statement_right_paren_on_new_line = false -ij_groovy_for_statement_wrap = off -ij_groovy_ginq_general_clause_wrap_policy = 2 -ij_groovy_ginq_having_wrap_policy = 1 -ij_groovy_ginq_indent_having_clause = true -ij_groovy_ginq_indent_on_clause = true -ij_groovy_ginq_on_wrap_policy = 1 -ij_groovy_ginq_space_after_keyword = true -ij_groovy_if_brace_force = never -ij_groovy_import_annotation_wrap = 2 -ij_groovy_imports_layout = *,|,javax.**,java.**,|,$* -ij_groovy_indent_case_from_switch = true -ij_groovy_indent_label_blocks = true -ij_groovy_insert_inner_class_imports = false -ij_groovy_keep_blank_lines_before_right_brace = 2 -ij_groovy_keep_blank_lines_in_code = 2 -ij_groovy_keep_blank_lines_in_declarations = 2 -ij_groovy_keep_control_statement_in_one_line = true -ij_groovy_keep_first_column_comment = true -ij_groovy_keep_multiple_expressions_in_one_line = false -ij_groovy_keep_simple_blocks_in_one_line = false -ij_groovy_keep_simple_classes_in_one_line = true -ij_groovy_keep_simple_lambdas_in_one_line = true -ij_groovy_keep_simple_methods_in_one_line = true -ij_groovy_label_indent_absolute = false -ij_groovy_label_indent_size = 0 -ij_groovy_lambda_brace_style = end_of_line -ij_groovy_layout_static_imports_separately = true -ij_groovy_line_comment_add_space = false -ij_groovy_line_comment_add_space_on_reformat = false -ij_groovy_line_comment_at_first_column = true -ij_groovy_method_annotation_wrap = split_into_lines -ij_groovy_method_brace_style = end_of_line -ij_groovy_method_call_chain_wrap = off -ij_groovy_method_parameters_new_line_after_left_paren = false -ij_groovy_method_parameters_right_paren_on_new_line = false -ij_groovy_method_parameters_wrap = off -ij_groovy_modifier_list_wrap = false -ij_groovy_names_count_to_use_import_on_demand = 3 -ij_groovy_packages_to_use_import_on_demand = java.awt.*,javax.swing.* -ij_groovy_parameter_annotation_wrap = off -ij_groovy_parentheses_expression_new_line_after_left_paren = false -ij_groovy_parentheses_expression_right_paren_on_new_line = false -ij_groovy_prefer_parameters_wrap = false -ij_groovy_resource_list_new_line_after_left_paren = false -ij_groovy_resource_list_right_paren_on_new_line = false -ij_groovy_resource_list_wrap = off -ij_groovy_space_after_assert_separator = true -ij_groovy_space_after_colon = true -ij_groovy_space_after_comma = true -ij_groovy_space_after_comma_in_type_arguments = true -ij_groovy_space_after_for_semicolon = true -ij_groovy_space_after_quest = true -ij_groovy_space_after_type_cast = true -ij_groovy_space_before_annotation_parameter_list = false -ij_groovy_space_before_array_initializer_left_brace = false -ij_groovy_space_before_assert_separator = false -ij_groovy_space_before_catch_keyword = true -ij_groovy_space_before_catch_left_brace = true -ij_groovy_space_before_catch_parentheses = true -ij_groovy_space_before_class_left_brace = true -ij_groovy_space_before_closure_left_brace = true -ij_groovy_space_before_colon = true -ij_groovy_space_before_comma = false -ij_groovy_space_before_do_left_brace = true -ij_groovy_space_before_else_keyword = true -ij_groovy_space_before_else_left_brace = true -ij_groovy_space_before_finally_keyword = true -ij_groovy_space_before_finally_left_brace = true -ij_groovy_space_before_for_left_brace = true -ij_groovy_space_before_for_parentheses = true -ij_groovy_space_before_for_semicolon = false -ij_groovy_space_before_if_left_brace = true -ij_groovy_space_before_if_parentheses = true -ij_groovy_space_before_method_call_parentheses = false -ij_groovy_space_before_method_left_brace = true -ij_groovy_space_before_method_parentheses = false -ij_groovy_space_before_quest = true -ij_groovy_space_before_record_parentheses = false -ij_groovy_space_before_switch_left_brace = true -ij_groovy_space_before_switch_parentheses = true -ij_groovy_space_before_synchronized_left_brace = true -ij_groovy_space_before_synchronized_parentheses = true -ij_groovy_space_before_try_left_brace = true -ij_groovy_space_before_try_parentheses = true -ij_groovy_space_before_while_keyword = true -ij_groovy_space_before_while_left_brace = true -ij_groovy_space_before_while_parentheses = true -ij_groovy_space_in_named_argument = true -ij_groovy_space_in_named_argument_before_colon = false -ij_groovy_space_within_empty_array_initializer_braces = false -ij_groovy_space_within_empty_method_call_parentheses = false -ij_groovy_spaces_around_additive_operators = true -ij_groovy_spaces_around_assignment_operators = true -ij_groovy_spaces_around_bitwise_operators = true -ij_groovy_spaces_around_equality_operators = true -ij_groovy_spaces_around_lambda_arrow = true -ij_groovy_spaces_around_logical_operators = true -ij_groovy_spaces_around_multiplicative_operators = true -ij_groovy_spaces_around_regex_operators = true -ij_groovy_spaces_around_relational_operators = true -ij_groovy_spaces_around_shift_operators = true -ij_groovy_spaces_within_annotation_parentheses = false -ij_groovy_spaces_within_array_initializer_braces = false -ij_groovy_spaces_within_braces = true -ij_groovy_spaces_within_brackets = false -ij_groovy_spaces_within_cast_parentheses = false -ij_groovy_spaces_within_catch_parentheses = false -ij_groovy_spaces_within_for_parentheses = false -ij_groovy_spaces_within_gstring_injection_braces = false -ij_groovy_spaces_within_if_parentheses = false -ij_groovy_spaces_within_list_or_map = false -ij_groovy_spaces_within_method_call_parentheses = false -ij_groovy_spaces_within_method_parentheses = false -ij_groovy_spaces_within_parentheses = false -ij_groovy_spaces_within_switch_parentheses = false -ij_groovy_spaces_within_synchronized_parentheses = false -ij_groovy_spaces_within_try_parentheses = false -ij_groovy_spaces_within_tuple_expression = false -ij_groovy_spaces_within_while_parentheses = false -ij_groovy_special_else_if_treatment = true -ij_groovy_ternary_operation_wrap = off -ij_groovy_throws_keyword_wrap = off -ij_groovy_throws_list_wrap = off -ij_groovy_use_flying_geese_braces = false -ij_groovy_use_fq_class_names = false -ij_groovy_use_fq_class_names_in_javadoc = true -ij_groovy_use_relative_indents = false -ij_groovy_use_single_class_imports = true -ij_groovy_variable_annotation_wrap = off -ij_groovy_while_brace_force = never -ij_groovy_while_on_new_line = false -ij_groovy_wrap_chain_calls_after_dot = false -ij_groovy_wrap_long_lines = false - [{*.har,*.jsb2,*.jsb3,*.json,*.png.mcmeta,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config,mcmod.info,pack.mcmeta}] ij_smart_tabs = false ij_json_array_wrapping = split_into_lines @@ -496,3 +306,7 @@ ij_json_space_before_comma = false ij_json_spaces_within_braces = false ij_json_spaces_within_brackets = false ij_json_wrap_long_lines = false + +[*.properties] +ij_properties_spaces_around_key_value_delimiter = true +ij_properties_keep_blank_lines = true diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml index d7d1f907..f5485105 100644 --- a/.github/workflows/dco.yml +++ b/.github/workflows/dco.yml @@ -1,9 +1,9 @@ name: "DCO Assistant" on: issue_comment: - types: [created] + types: [ created ] pull_request_target: - types: [opened, closed, synchronize] + types: [ opened, closed, synchronize ] permissions: actions: write @@ -17,9 +17,9 @@ jobs: steps: - name: "DCO Assistant" if: ( - github.event.comment.body == 'recheck' || - github.event.comment.body == 'I have read and hereby affirm the entire contents of the Developer Certificate of Origin.' - ) || github.event_name == 'pull_request_target' + github.event.comment.body == 'recheck' || + github.event.comment.body == 'I have read and hereby affirm the entire contents of the Developer Certificate of Origin.' + ) || github.event_name == 'pull_request_target' uses: cla-assistant/github-action@v2.3.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index d0e24b7c..b9dc3a27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,2 +1,3 @@ - added Embeddium config screen integration -- further improvements to overall system stability and other minor adjustments have been made to enhance the user experience \ No newline at end of file +- further improvements to overall system stability and other minor adjustments have been made to enhance the user + experience \ No newline at end of file diff --git a/README.md b/README.md index 017a4424..b8b1bc11 100644 --- a/README.md +++ b/README.md @@ -1,27 +1,28 @@ # IMPORTANT LICENSE NOTICE -By using this project in any form, you hereby give your "express assent" for the terms of the license of this -project (see [License](#license)), and acknowledge that I (the author of this project) have fulfilled my obligation -under the license to "make a reasonable effort under the circumstances to obtain the express assent of recipients to +By using this project in any form, you hereby give your "express assent" for the terms of the license of this +project (see [License](#license)), and acknowledge that I (the author of this project) have fulfilled my obligation +under the license to "make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License". # Zume An ~~over-engineered~~ simple zoom mod. -This mod adds a keybind which zooms in your FOV while it's held down, allowing you to see further away, and keybinds +This mod adds a keybind which zooms in your FOV while it's held down, allowing you to see further away, and keybinds for increasing and decreasing the zoom level. # FAQ #### Q: Where is the config? -A: You'll find the config at `.minecraft/global/zume.json5` (note that this is the default `.minecraft` folder, not -the instance `.minecraft`). You can modify the file while the game is running, and the config will be automatically -reloaded. On platforms which have mod menus (such as Forge, and Fabric with [Mod Menu](https://modrinth.com/mod/modmenu) +A: You'll find the config at `.minecraft/global/zume.json5` (note that this is the default `.minecraft` folder, not +the instance `.minecraft`). You can modify the file while the game is running, and the config will be automatically +reloaded. On platforms which have mod menus (such as Forge, and Fabric with [Mod Menu](https://modrinth.com/mod/modmenu) installed), the config button for Zume will open this file in your system text editor. #### Q: discord where + A: https://discord.gg/6ZjX4mvCMR #### Q: What version is this for? @@ -38,34 +39,35 @@ A: Zume supports the following platforms: #### Q: Can you add support for \? -A: Every platform I intend to add support for myself is already supported. PRs are welcome for other platforms **if +A: Every platform I intend to add support for myself is already supported. PRs are welcome for other platforms **if the following conditions are met**: - Must not break single-jar compatibility with any already supported platform (obviously). -- Must not be for a platform that has a 1st-party compatibility layer for an already supported platform - explicit - Quilt support will not be accepted so long as Quilt maintains a Fabric compatibility layer; it'd be a waste of CI - time. [Sinytra Connector](https://github.com/Sinytra/Connector) is a 3rd-party compatibility layer, so explicit +- Must not be for a platform that has a 1st-party compatibility layer for an already supported platform - explicit + Quilt support will not be accepted so long as Quilt maintains a Fabric compatibility layer; it'd be a waste of CI + time. [Sinytra Connector](https://github.com/Sinytra/Connector) is a 3rd-party compatibility layer, so explicit Forge support will be provided. -- Must not manually maintain overridden game options; implementations that look like +- Must not manually maintain overridden game options; implementations that look like [Mooz's](https://github.com/embeddedt/Mooz/blob/92570f7449a7e71c1c0b988788027b10c00f1346/src/main/java/org/embeddedt/mooz/ClientProxy.java#L35-L56) - will not be accepted - no offense [embeddedt](https://github.com/embeddedt). Direct ASM is fine as long as functionality is similar enough. -- Must make a reasonable effort to be maximize compatibility with existing mods on target platforms - see use of - Neo/LexForge API over mixins in Neo/LexForge implementations, and use of `@WrapWithCondition` and + will not be accepted - no offense [embeddedt](https://github.com/embeddedt). Direct ASM is fine as long as + functionality is similar enough. +- Must make a reasonable effort to be maximize compatibility with existing mods on target platforms - see use of + Neo/LexForge API over mixins in Neo/LexForge implementations, and use of `@WrapWithCondition` and `@ModifyExpressionValue` and such from MixinExtras over `@Redirect` in most implementations. - Must follow existing format - add a Unimined subproject for each newly supported platform. -- Must not have exclusive features without significant justification - if you're adding a feature, add it to every +- Must not have exclusive features without significant justification - if you're adding a feature, add it to every version. #### Q: What kind of weird license is this? -A: OSL-3.0 is the closest equivalent to a LAGPL I could find. AGPL and GPL are incompatible with Minecraft, and LGPL +A: OSL-3.0 is the closest equivalent to a LAGPL I could find. AGPL and GPL are incompatible with Minecraft, and LGPL doesn't protect network use. OSL-3.0 protects network use and is compatible with Minecraft. #### Q: Why though? It's so strict!!!! -A: This is, and will remain, free, copyleft software. Any requests to change the license other than to make it even -stronger will be denied immediately (unfortunately GPL and AGPL aren't compatible with Minecraft due to linking -restrictions, as much as I'd like to use them). Even in situations where I use parts of other projects with more +A: This is, and will remain, free, copyleft software. Any requests to change the license other than to make it even +stronger will be denied immediately (unfortunately GPL and AGPL aren't compatible with Minecraft due to linking +restrictions, as much as I'd like to use them). Even in situations where I use parts of other projects with more "permissive" licenses, I will treat them as copyleft, free software. ## License diff --git a/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java b/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java index a5fa211b..a2dcaeba 100644 --- a/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java +++ b/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java @@ -8,12 +8,21 @@ @ApiStatus.OverrideOnly public interface IZumeImplementation { - @Contract(pure = true) boolean isZoomPressed(); - @Contract(pure = true) boolean isZoomInPressed(); - @Contract(pure = true) boolean isZoomOutPressed(); + @Contract(pure = true) + boolean isZoomPressed(); - @Contract(pure = true) @NotNull CameraPerspective getCameraPerspective(); + @Contract(pure = true) + boolean isZoomInPressed(); - @NonBlocking default void onZoomActivate() {} + @Contract(pure = true) + boolean isZoomOutPressed(); + + @Contract(pure = true) + @NotNull + CameraPerspective getCameraPerspective(); + + @NonBlocking + default void onZoomActivate() { + } } diff --git a/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java b/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java index 17a17e36..08193262 100644 --- a/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java +++ b/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java @@ -27,7 +27,7 @@ public static void openConfigFile() { /** * Invoke this in the initializer of your Zume implementation. * - * @param implementation The {@linkplain IZumeImplementation} Zume should use. + * @param implementation The {@linkplain IZumeImplementation} Zume should use. * @param instanceConfigPath The {@linkplain Path} Zume should use for storing the instance-specific config. */ public static void registerImplementation(@NotNull final IZumeImplementation implementation, @@ -61,6 +61,7 @@ public void onZoomActivate() { } //region Query Methods + /** * Returns `true` if Zoom is activated. */ @@ -87,8 +88,9 @@ public static boolean isMouseScrollHookActive() { //endregion //region Hooks + /** - * This should be invoked once at the beginning of every frame. + * This should be invoked once at the beginning of every frame. * It will handle Keybindings and Zoom Scrolling if the other hooks in this API are used correctly. */ public static void renderHook() { @@ -96,19 +98,19 @@ public static void renderHook() { } /** - * ONLY INVOKE THIS METHOD WHEN {@linkplain ZumeAPI#isFOVHookActive()} RETURNS `true`. + * ONLY INVOKE THIS METHOD WHEN {@linkplain ZumeAPI#isFOVHookActive()} RETURNS `true`. * That check was explicitly excluded from this method for efficiency and for mixin compatibility. * The {@linkplain IZumeImplementation} is responsible for this check. * * @param fov The unmodified FOV value - * {@return The new FOV transformed by Zume} + * {@return The new FOV transformed by Zume} */ public static double fovHook(double fov) { return Zume.transformFOV(fov); } /** - * This method assumes Zume is active and the camera perspective is third-person. + * This method assumes Zume is active and the camera perspective is third-person. * If it is not, using this value will cause bugs. * * @param distance The vanilla third-person camera distance @@ -122,7 +124,7 @@ public static double thirdPersonCameraHook(double distance) { * The return value of this method can be safely used without checking whether Zume is active. * * @param mouseSensitivity The unmodified mouse sensitivity - * {@return The new mouse sensitivity, transformed by Zume} + * {@return The new mouse sensitivity, transformed by Zume} */ public static double mouseSensitivityHook(double mouseSensitivity) { return Zume.transformMouseSensitivity(mouseSensitivity); @@ -132,7 +134,7 @@ public static double mouseSensitivityHook(double mouseSensitivity) { * The return value of this method can be safely used without checking whether Zume is active. * * @param cinematicCameraEnabled The unmodified cinematic camera state - * {@return The new cinematic camera state, transformed by Zume} + * {@return The new cinematic camera state, transformed by Zume} */ public static boolean cinematicCameraEnabledHook(boolean cinematicCameraEnabled) { return Zume.transformCinematicCamera(cinematicCameraEnabled); @@ -142,7 +144,7 @@ public static boolean cinematicCameraEnabledHook(boolean cinematicCameraEnabled) * The return value of this method can be safely used without checking whether Zume is active. * * @param scrollDelta The scroll delta (magnitude will be ignored, only the sign is used) - * {@return `true` if the invoker should prevent further handling of this scroll event} + * {@return `true` if the invoker should prevent further handling of this scroll event} */ public static boolean mouseScrollHook(int scrollDelta) { return Zume.interceptScroll(scrollDelta); diff --git a/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java b/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java index ef22247b..00c8cc0d 100644 --- a/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java +++ b/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java @@ -43,13 +43,14 @@ public MethodHandleHelper(@NotNull final ClassLoader classLoader, @NotNull final for (final String className : classNames) { try { return Class.forName(className, true, classLoader); - } catch (ClassNotFoundException ignored) { } + } catch (ClassNotFoundException ignored) { + } } return null; } - public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, + public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, @NotNull final String methodName, @Nullable Class... parameterTypes) { if (clazz == null || Arrays.stream(parameterTypes).anyMatch(Objects::isNull)) @@ -62,7 +63,7 @@ public MethodHandleHelper(@NotNull final ClassLoader classLoader, @NotNull final } } - public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, + public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, @NotNull final String methodName, @Nullable final MethodType methodType, @Nullable Class... parameterTypes) { diff --git a/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java b/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java index 0ef2820f..4bc117d0 100644 --- a/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java +++ b/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java @@ -72,7 +72,7 @@ public void set(double from, double target) { this.targetValue = target; } - public void set(double target) { + public void set(double target) { set(getEased(), target); } diff --git a/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java b/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java index 146ba551..27f942f3 100644 --- a/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java +++ b/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java @@ -3,7 +3,9 @@ public interface IZumeImplementation { boolean isZoomPressed(); + boolean isZoomInPressed(); + boolean isZoomOutPressed(); CameraPerspective getCameraPerspective(); diff --git a/api/src/main/java/dev/nolij/zume/impl/Zume.java b/api/src/main/java/dev/nolij/zume/impl/Zume.java index 7bcba744..ca1b20c6 100644 --- a/api/src/main/java/dev/nolij/zume/impl/Zume.java +++ b/api/src/main/java/dev/nolij/zume/impl/Zume.java @@ -1,8 +1,8 @@ package dev.nolij.zume.impl; +import dev.nolij.zume.api.util.v1.EasingHelper; import dev.nolij.zume.api.util.v1.MathHelper; import dev.nolij.zume.impl.config.ZumeConfigImpl; -import dev.nolij.zume.api.util.v1.EasingHelper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -83,7 +83,7 @@ private static void setZoom(final double fromZoom, final double targetZoom) { private static double getThirdPersonStartZoom() { return EasingHelper.inverseOut( - config.minThirdPersonZoomDistance, config.maxThirdPersonZoomDistance, + config.minThirdPersonZoomDistance, config.maxThirdPersonZoomDistance, 4D, config.zoomEasingExponent); } @@ -167,12 +167,12 @@ public static boolean shouldCancelScroll() { } public static boolean interceptScroll(final int scrollDelta) { - if (!shouldCancelScroll() || scrollDelta == 0) - return false; + if (!shouldCancelScroll() || scrollDelta == 0) + return false; - Zume.scrollDelta += MathHelper.sign(scrollDelta); - return true; - } + Zume.scrollDelta += MathHelper.sign(scrollDelta); + return true; + } private static boolean getToggleMode() { return shouldUseFirstPersonZoom() @@ -195,7 +195,7 @@ private static boolean shouldHook() { } private static boolean shouldUseFirstPersonZoom() { - return config.maxThirdPersonZoomDistance == 0 || + return config.maxThirdPersonZoomDistance == 0 || implementation.getCameraPerspective() == CameraPerspective.FIRST_PERSON; } diff --git a/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java index 14ab1069..19392bd9 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java @@ -75,7 +75,7 @@ public void start(Path file, Callback callback) throws IOException { try { if ((locked = tryLock()) && System.currentTimeMillis() > debounce && - Files.exists(changed) && + Files.exists(changed) && Files.isSameFile(changed, file)) { callback.invoke(); debounce = System.currentTimeMillis() + DEBOUNCE_DURATION_MS; diff --git a/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java index 06b8e5f0..a724214b 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java @@ -3,7 +3,9 @@ public interface IFileWatcher { void lock() throws InterruptedException; + boolean tryLock(); + void unlock(); } diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 94433314..4018519e 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -1,12 +1,15 @@ package dev.nolij.zume.impl.config; +import dev.nolij.zson.Comment; import dev.nolij.zson.Zson; import dev.nolij.zson.ZsonParser; import dev.nolij.zson.ZsonWriter; -import dev.nolij.zson.Comment; import dev.nolij.zume.impl.Zume; -import java.io.*; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -14,6 +17,8 @@ public class ZumeConfigImpl { + //@formatter:off + @Comment(""" Enable Cinematic Camera while zooming. If you disable this, you should also try setting `zoomSmoothnessMs` to `0`. @@ -95,6 +100,8 @@ public class ZumeConfigImpl { DEFAULT: `false`""") public boolean disable = false; + //@formatter:on + private static final int EXPECTED_VERSION = 1; @Comment("Used internally. Don't modify this.") @@ -111,23 +118,23 @@ private static ZumeConfigImpl readFromFile(final File configFile) { while (true) { try { return Zson.map2Obj(ZsonParser.parse(new FileReader(configFile)), ZumeConfigImpl.class); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { if (++i < MAX_RETRIES) { - try { - //noinspection BusyWait - Thread.sleep(i * 200L); + try { + //noinspection BusyWait + Thread.sleep(i * 200L); continue; - } catch (InterruptedException ignored) { - return null; - } - } + } catch (InterruptedException ignored) { + return null; + } + } Zume.LOGGER.error("Error parsing config after {} retries: ", i, e); return null; } catch (IOException e) { Zume.LOGGER.error("Error reading config: ", e); return null; - } - } + } + } } private static ZumeConfigImpl readConfigFile() { @@ -184,12 +191,12 @@ public static void replace(final ZumeConfigImpl newConfig) throws InterruptedExc GLOBAL_CONFIG_PATH = dotMinecraft.resolve("global"); if (Files.notExists(GLOBAL_CONFIG_PATH)) { - try { - Files.createDirectories(GLOBAL_CONFIG_PATH); - } catch (IOException e) { - Zume.LOGGER.error("Failed to create global config path: ", e); - } - } + try { + Files.createDirectories(GLOBAL_CONFIG_PATH); + } catch (IOException e) { + Zume.LOGGER.error("Failed to create global config path: ", e); + } + } } public static File getConfigFile() { diff --git a/archaic/build.gradle.kts b/archaic/build.gradle.kts index 39de4748..71cedcd7 100644 --- a/archaic/build.gradle.kts +++ b/archaic/build.gradle.kts @@ -4,12 +4,12 @@ operator fun String.invoke(): String = rootProject.properties[this] as? String ? unimined.minecraft { version("archaic_minecraft_version"()) - + minecraftForge { loader("archaic_forge_version"()) mixinConfig("zume-${project.name}.mixins.json") } - + mappings { searge() mcp("stable", "archaic_mappings_version"()) diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java index a2601497..4fa8c561 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java @@ -1,18 +1,18 @@ package dev.nolij.zume.archaic; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.FMLLaunchHandler; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.mixin.archaic.EntityRendererAccessor; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; import net.minecraft.client.Minecraft; import net.minecraft.launchwrapper.Launch; import net.minecraft.util.MouseFilter; @@ -87,9 +87,9 @@ public void onZoomActivate() { } private static final MethodHandle SET_CANCELED = MethodHandleHelper.PUBLIC.getMethodOrNull( - Event.class, - "setCanceled", - MethodType.methodType(void.class, MouseEvent.class, boolean.class), + Event.class, + "setCanceled", + MethodType.methodType(void.class, MouseEvent.class, boolean.class), boolean.class); @SubscribeEvent(priority = EventPriority.HIGHEST) diff --git a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java index 3792c800..42325ceb 100644 --- a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java @@ -7,20 +7,26 @@ @Mixin(EntityRenderer.class) public interface EntityRendererAccessor { - + @Accessor("smoothCamFilterX") void setSmoothCamFilterX(float value); + @Accessor("smoothCamFilterY") void setSmoothCamFilterY(float value); + @Accessor("smoothCamYaw") void setSmoothCamYaw(float value); + @Accessor("smoothCamPitch") void setSmoothCamPitch(float value); + @Accessor("smoothCamPartialTicks") void setSmoothCamPartialTicks(float value); + @Accessor("mouseFilterXAxis") void setMouseFilterXAxis(MouseFilter value); + @Accessor("mouseFilterYAxis") void setMouseFilterYAxis(MouseFilter value); - + } diff --git a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java index 78ea1e0e..46630671 100644 --- a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java @@ -11,7 +11,7 @@ @Mixin(EntityRenderer.class) public abstract class EntityRendererMixin { - + @Inject(method = "updateCameraAndRender", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { ZumeAPI.renderHook(); @@ -24,29 +24,29 @@ public abstract class EntityRendererMixin { return original; } - - @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, + + @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { return ZumeAPI.cinematicCameraEnabledHook(original); } - - @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, + + @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;mouseSensitivity:F")) public float zume$updateMouse$mouseSensitivity(float original) { return (float) ZumeAPI.mouseSensitivityHook(original); } - @ModifyExpressionValue(method = "orientCamera", + @ModifyExpressionValue(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistance:F")) public float zume$orientCamera$thirdPersonDistance(float original) { return (float) ZumeAPI.thirdPersonCameraHook(original); } - @ModifyExpressionValue(method = "orientCamera", + @ModifyExpressionValue(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistanceTemp:F")) public float zume$orientCamera$thirdPersonDistanceTemp(float original) { return (float) ZumeAPI.thirdPersonCameraHook(original); } - + } diff --git a/build.gradle.kts b/build.gradle.kts index 824a73b1..31b4dd23 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,10 +1,7 @@ @file:Suppress("UnstableApiUsage") + import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import dev.nolij.zumegradle.ClassShrinkingType -import dev.nolij.zumegradle.DeflateAlgorithm -import dev.nolij.zumegradle.JsonShrinkingType -import dev.nolij.zumegradle.MixinConfigMergingTransformer -import dev.nolij.zumegradle.CompressJarTask +import dev.nolij.zumegradle.* import kotlinx.serialization.encodeToString import me.modmuss50.mpp.HttpUtils import me.modmuss50.mpp.PublishModTask @@ -26,7 +23,7 @@ import java.nio.file.Files import java.time.ZonedDateTime plugins { - id("java") + id("java") id("maven-publish") id("com.github.johnrengelman.shadow") id("me.modmuss50.mod-publish-plugin") @@ -37,16 +34,17 @@ plugins { operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") enum class ReleaseChannel( - val suffix: String? = null, - val releaseType: ReleaseType? = null, - val deflation: DeflateAlgorithm = DeflateAlgorithm.SEVENZIP, - val classes: ClassShrinkingType = ClassShrinkingType.STRIP_ALL, - val json: JsonShrinkingType = JsonShrinkingType.MINIFY, - val proguard: Boolean = true, - ) { + val suffix: String? = null, + val releaseType: ReleaseType? = null, + val deflation: DeflateAlgorithm = DeflateAlgorithm.SEVENZIP, + val classes: ClassShrinkingType = ClassShrinkingType.STRIP_ALL, + val json: JsonShrinkingType = JsonShrinkingType.MINIFY, + val proguard: Boolean = true, +) { DEV_BUILD( suffix = "dev", - json = JsonShrinkingType.PRETTY_PRINT), + json = JsonShrinkingType.PRETTY_PRINT + ), PRE_RELEASE("pre"), RELEASE_CANDIDATE("rc"), RELEASE(releaseType = ReleaseType.STABLE), @@ -61,7 +59,7 @@ val releaseTagPrefix = "release/" val releaseTags = grgit.tag.list() .filter { tag -> tag.name.startsWith(releaseTagPrefix) } - .sortedWith { tag1, tag2 -> + .sortedWith { tag1, tag2 -> if (tag1.commit.dateTime == tag2.commit.dateTime) if (tag1.name.length != tag2.name.length) return@sortedWith tag1.name.length.compareTo(tag2.name.length) @@ -75,7 +73,7 @@ val releaseTags = grgit.tag.list() val isExternalCI = (rootProject.properties["external_publish"] as String?).toBoolean() val isRelease = rootProject.hasProperty("release_channel") || isExternalCI val releaseIncrement = if (isExternalCI) 0 else 1 -val releaseChannel: ReleaseChannel = +val releaseChannel: ReleaseChannel = if (isExternalCI) { val tagName = releaseTags.first().name val suffix = """\-(\w+)\.\d+$""".toRegex().find(tagName)?.groupValues?.get(1) @@ -101,7 +99,7 @@ val patchHistory = releaseTags .map { name -> name.substring(minorTagPrefix.length) } val maxPatch = patchHistory.maxOfOrNull { it.substringBefore('-').toInt() } -val patch = +val patch = maxPatch?.plus( if (patchHistory.contains(maxPatch.toString())) releaseIncrement @@ -112,14 +110,14 @@ var patchAndSuffix = patch.toString() if (releaseChannel.suffix != null) { patchAndSuffix += "-${releaseChannel.suffix}" - + if (isRelease) { patchAndSuffix += "." - + val maxBuild = patchHistory .mapNotNull { it.removePrefix(patchAndSuffix).toIntOrNull() } .maxOrNull() - + val build = (maxBuild?.plus(releaseIncrement)) ?: 1 patchAndSuffix += build.toString() } @@ -161,7 +159,7 @@ val uniminedImpls = arrayOf( *neoForgeImpls, ) -allprojects { +allprojects { apply(plugin = "java") apply(plugin = "maven-publish") @@ -173,15 +171,15 @@ allprojects { } maven("https://repo.spongepowered.org/maven") maven("https://jitpack.io/") - exclusiveContent { + exclusiveContent { forRepository { maven("https://api.modrinth.com/maven") } - filter { + filter { includeGroup("maven.modrinth") } } maven("https://maven.blamejared.com") } - + tasks.withType { if (name !in arrayOf("compileMcLauncherJava", "compilePatchedMcJava")) { options.encoding = "UTF-8" @@ -192,7 +190,7 @@ allprojects { } } } - + dependencies { compileOnly("org.jetbrains:annotations:${"jetbrains_annotations_version"()}") "com.pkware.jabel:jabel-javac-plugin:${"jabel_version"()}".also { @@ -213,7 +211,14 @@ allprojects { .mapValues { entry -> entry.value as String }) props["mod_version"] = Zume.version - filesMatching(immutableListOf("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "META-INF/neoforge.mods.toml")) { + filesMatching( + immutableListOf( + "fabric.mod.json", + "mcmod.info", + "META-INF/mods.toml", + "META-INF/neoforge.mods.toml" + ) + ) { expand(props) } } @@ -222,18 +227,18 @@ allprojects { subprojects { val subProject = this val implName = subProject.name - + group = "maven_group"() version = Zume.version - + base { archivesName = "${"mod_id"()}-${subProject.name}" } - + tasks.withType { enabled = false } - + dependencies { implementation("dev.nolij:zson:${"zson_version"()}:downgraded-8") } @@ -241,7 +246,7 @@ subprojects { if (implName in uniminedImpls) { apply(plugin = "xyz.wagyourtail.unimined") apply(plugin = "com.github.johnrengelman.shadow") - + unimined.minecraft(sourceSets["main"], lateApply = true) { combineWith(project(":api").sourceSets.main.get()) @@ -249,18 +254,18 @@ subprojects { runs.config("server") { disabled = true } - + runs.config("client") { jvmArgs += "-Dzume.configPathOverride=${rootProject.file("zume.json5").absolutePath}" } } - + defaultRemapJar = true } - + val outputJar = tasks.register("outputJar") { group = "build" - + val remapJarTasks = tasks.withType() dependsOn(remapJarTasks) mustRunAfter(remapJarTasks) @@ -275,7 +280,7 @@ subprojects { archiveClassifier = "output" isPreserveFileTimestamps = false isReproducibleFileOrder = true - + relocate("dev.nolij.zume.integration.implementation", "dev.nolij.zume.${implName}.integration") } @@ -283,14 +288,14 @@ subprojects { dependsOn(outputJar) } } - - if(implName in lexForgeImpls) { + + if (implName in lexForgeImpls) { tasks.withType { mixinRemap { disableRefmap() } } - + dependencies { "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}:downgraded-8") } @@ -299,7 +304,7 @@ subprojects { unimined.minecraft { version("modern_minecraft_version"()) - + runs.off = true fabric { @@ -322,12 +327,12 @@ dependencies { shade("dev.nolij:zson:${"zson_version"()}:downgraded-8") compileOnly("org.apache.logging.log4j:log4j-core:${"log4j_version"()}") - + compileOnly(project(":stubs")) - + implementation(project(":api")) - - uniminedImpls.forEach { + + uniminedImpls.forEach { implementation(project(":${it}")) { isTransitive = false } } } @@ -342,14 +347,14 @@ val sourcesJar = tasks.register("sourcesJar") { archiveClassifier = "sources" isPreserveFileTimestamps = false isReproducibleFileOrder = true - + from("LICENSE") { rename { "${it}_${"mod_id"()}" } } - + listOf( - sourceSets, - project(":api").sourceSets, + sourceSets, + project(":api").sourceSets, project(":integration:embeddium").sourceSets, uniminedImpls.flatMap { project(":${it}").sourceSets } ).flatten().forEach { @@ -363,34 +368,37 @@ tasks.shadowJar { packageName = "dev.nolij.zume.mixin" mixinPlugin = "dev.nolij.zume.ZumeMixinPlugin" } - + from("LICENSE") { rename { "${it}_${"mod_id"()}" } } - + exclude("*.xcf") exclude("LICENSE_zson") - + configurations = immutableListOf(shade) archiveClassifier = null isPreserveFileTimestamps = false isReproducibleFileOrder = true - + val apiJar = project(":api").tasks.jar dependsOn(apiJar) from(zipTree(apiJar.get().archiveFile.get())) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } - + uniminedImpls.map { project(it).tasks.named("outputJar").get() }.forEach { implJarTask -> dependsOn(implJarTask) from(zipTree(implJarTask.archiveFile.get())) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE exclude("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "pack.mcmeta") - filesMatching(immutableListOf( - "dev/nolij/zume/lexforge/LexZume.class", - "dev/nolij/zume/lexforge18/LexZume18.class", - "dev/nolij/zume/lexforge16/LexZume16.class", - "dev/nolij/zume/vintage/VintageZume.class")) { + filesMatching( + immutableListOf( + "dev/nolij/zume/lexforge/LexZume.class", + "dev/nolij/zume/lexforge18/LexZume18.class", + "dev/nolij/zume/lexforge16/LexZume16.class", + "dev/nolij/zume/vintage/VintageZume.class" + ) + ) { val reader = ClassReader(this.open()) val node = ClassNode() reader.accept(node, 0) @@ -403,12 +411,12 @@ tasks.shadowJar { } } } - + relocate("dev.nolij.zson", "dev.nolij.zume.zson") - if(releaseChannel.proguard) { + if (releaseChannel.proguard) { relocate("dev.nolij.zume.mixin", "zume.mixin") } - + manifest { attributes( "FMLCorePluginContainsFMLMod" to true, @@ -422,10 +430,10 @@ tasks.shadowJar { val compressJar = tasks.register("compressJar") { dependsOn(tasks.shadowJar) group = "build" - + val shadowJar = tasks.shadowJar.get() inputJar = shadowJar.archiveFile.get().asFile - + deflateAlgorithm = releaseChannel.deflation classShrinkingType = releaseChannel.classes jsonShrinkingType = releaseChannel.json @@ -444,7 +452,7 @@ afterEvaluate { if (!System.getenv("local_maven_url").isNullOrEmpty()) maven(System.getenv("local_maven_url")) } - + publications { create("mod_id"()) { artifact(compressJar.get().outputJar) @@ -456,32 +464,32 @@ afterEvaluate { tasks.withType { dependsOn(compressJar, sourcesJar) } - + fun getChangelog(): String { return file("CHANGELOG.md").readText() } - + publishMods { file = compressJar.get().outputJar additionalFiles.from(sourcesJar.get().archiveFile) if (releaseChannel.proguard) additionalFiles.from(compressJar.get().mappingsFile) - + type = releaseChannel.releaseType ?: ALPHA displayName = Zume.version version = Zume.version changelog = getChangelog() - + modLoaders.addAll("fabric", "forge", "neoforge") dryRun = !isRelease - + github { accessToken = providers.environmentVariable("GITHUB_TOKEN") repository = "Nolij/Zume" commitish = branchName tagName = releaseTagPrefix + Zume.version } - + if (dryRun.get() || releaseChannel.releaseType != null) { modrinth { accessToken = providers.environmentVariable("MODRINTH_TOKEN") @@ -519,9 +527,9 @@ afterEvaluate { start = "1.7.10" end = "1.12.2" } - + minecraftVersions.add("Beta 1.7.3") - + val snapshots: Set if (cfAccessToken.orNull != null) { val cfAPI = CurseforgeApi(cfAccessToken.get(), apiEndpoint.get()) @@ -530,7 +538,7 @@ afterEvaluate { "${it}-Snapshot" }.toHashSet() - snapshots = + snapshots = cfAPI.getGameVersions().map { it.name }.filter { @@ -541,9 +549,9 @@ afterEvaluate { } else { snapshots = HashSet() } - + snapshots.add("1.21-Snapshot") - + minecraftVersions.addAll(snapshots) } @@ -562,7 +570,7 @@ afterEvaluate { } } } - + tasks.withType { dependsOn(compressJar, sourcesJar) } @@ -588,15 +596,15 @@ afterEvaluate { val compareStart = currentTag?.name ?: grgit.log().minBy { it.dateTime }.id val compareEnd = releaseTagPrefix + Zume.version val compareLink = "https://github.com/Nolij/Zume/compare/${compareStart}...${compareEnd}" - + val webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK") val releaseChangeLog = getChangelog() val file = publishMods.file.asFile.get() - + var content = "# [Zume Test Build ${Zume.version}]" + "() has been released!\n" + "Changes since last build: <${compareLink}>" - + if (buildChangeLog.isNotBlank()) content += " ```md\n${buildChangeLog}\n```" content += "\nChanges since last release: ```md\n${releaseChangeLog}\n```" @@ -610,14 +618,20 @@ afterEvaluate { val bodyBuilder = MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("payload_json", http.json.encodeToString(webhook)) - .addFormDataPart("files[0]", file.name, file.asRequestBody("application/java-archive".toMediaTypeOrNull())) - + .addFormDataPart( + "files[0]", + file.name, + file.asRequestBody("application/java-archive".toMediaTypeOrNull()) + ) + var fileIndex = 1 for (additionalFile in publishMods.additionalFiles) { bodyBuilder.addFormDataPart( - "files[${fileIndex++}]", - additionalFile.name, - additionalFile.asRequestBody(Files.probeContentType(additionalFile.toPath()).toMediaTypeOrNull()) + "files[${fileIndex++}]", + additionalFile.name, + additionalFile.asRequestBody( + Files.probeContentType(additionalFile.toPath()).toMediaTypeOrNull() + ) ) } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 675a30fe..87c3e937 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -33,7 +33,7 @@ dependencies { implementation("net.fabricmc:mapping-io:${"mapping_io_version"()}") implementation("org.apache.ant:ant:${"shadow_ant_version"()}") implementation("com.guardsquare:proguard-base:${"proguard_version"()}") - + plugin(id = "com.github.johnrengelman.shadow", version = "shadow_version"()) plugin(id = "xyz.wagyourtail.unimined", version = "unimined_version"()) plugin(id = "com.github.gmazzo.buildconfig", version = "buildconfig_version"()) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 6735ae75..31e264bc 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -7,11 +7,8 @@ import net.fabricmc.mappingio.format.MappingFormat import net.fabricmc.mappingio.tree.MappingTree.ClassMapping import net.fabricmc.mappingio.tree.MemoryMappingTree import org.gradle.api.DefaultTask -import org.gradle.api.tasks.Input -import org.gradle.api.tasks.InputFile +import org.gradle.api.tasks.* import org.gradle.api.tasks.Optional -import org.gradle.api.tasks.OutputFile -import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.options.Option import org.gradle.kotlin.dsl.support.uppercaseFirstChar import org.objectweb.asm.ClassReader @@ -22,7 +19,7 @@ import proguard.ConfigurationParser import proguard.ProGuard import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig import java.io.File -import java.util.Properties +import java.util.* import java.util.jar.JarEntry import java.util.jar.JarFile import java.util.jar.JarOutputStream @@ -34,7 +31,7 @@ enum class DeflateAlgorithm(val id: Int?) { SEVENZIP(3), // ZOPFLI(4), // too slow ; - + override fun toString() = name.lowercase().uppercaseFirstChar() } @@ -44,7 +41,7 @@ enum class ClassShrinkingType { STRIP_SOURCE_FILES, STRIP_ALL, ; - + fun shouldStripLVTs() = this == STRIP_LVTS || this == STRIP_ALL fun shouldStripSourceFiles() = this == STRIP_SOURCE_FILES || this == STRIP_ALL fun shouldRun() = this != STRIP_NONE @@ -63,30 +60,34 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js } } } - + jar.delete() - + val json = JsonSlurper() - + val isObfuscating = mappingsFile?.exists() == true val mappings = if (isObfuscating) mappings(mappingsFile!!) else null JarOutputStream(jar.outputStream()).use { out -> out.setLevel(Deflater.BEST_COMPRESSION) - contents.forEach { var (name, bytes) = it - if(name == "fabric.mod.json" && isObfuscating) { + contents.forEach { + var (name, bytes) = it + if (name == "fabric.mod.json" && isObfuscating) { bytes = remapFMJ(bytes, mappings!!) } - - if(name.endsWith("mixins.json") && isObfuscating) { + + if (name.endsWith("mixins.json") && isObfuscating) { bytes = remapMixinConfig(bytes, mappings!!) } - - if (jsonProcessing != JsonShrinkingType.NONE && - name.endsWith(".json") || name.endsWith(".mcmeta") || name == "mcmod.info") { + + if (jsonProcessing != JsonShrinkingType.NONE && + name.endsWith(".json") || name.endsWith(".mcmeta") || name == "mcmod.info" + ) { bytes = when (jsonProcessing) { JsonShrinkingType.MINIFY -> JsonOutput.toJson(json.parse(bytes)).toByteArray() - JsonShrinkingType.PRETTY_PRINT -> JsonOutput.prettyPrint(JsonOutput.toJson(json.parse(bytes))).toByteArray() + JsonShrinkingType.PRETTY_PRINT -> JsonOutput.prettyPrint(JsonOutput.toJson(json.parse(bytes))) + .toByteArray() + else -> throw AssertionError() } } @@ -118,7 +119,7 @@ private fun remapFMJ(bytes: ByteArray, mappings: MemoryMappingTree): ByteArray { newEntrypoints.computeIfAbsent(type) { mutableListOf() }.add(obf) } } - + json["entrypoints"] = newEntrypoints return JsonOutput.toJson(json).toByteArray() @@ -130,9 +131,9 @@ private fun remapMixinConfig(bytes: ByteArray, mappings: MemoryMappingTree): Byt val old = json["plugin"] as String val obf = mappings.obfuscate(old) json["plugin"] = obf - + json["package"] = "zume.mixin" - + return JsonOutput.toJson(json).toByteArray() } @@ -149,8 +150,8 @@ private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinking if (classFileSettings.shouldStripSourceFiles()) { classNode.sourceFile = null } - - if(classNode.invisibleAnnotations?.map { it.desc }?.contains("Lorg/spongepowered/asm/mixin/Mixin;") == true) { + + if (classNode.invisibleAnnotations?.map { it.desc }?.contains("Lorg/spongepowered/asm/mixin/Mixin;") == true) { classNode.methods.removeAll { it.name == "" && it.instructions.size() <= 3 } // ALOAD, super(), RETURN } @@ -161,7 +162,7 @@ private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinking val advzipInstalled = try { ProcessBuilder("advzip", "-V").start().waitFor() == 0 -} catch (e: Exception) { +} catch (e: Exception) { false } @@ -171,7 +172,7 @@ fun deflate(zip: File, type: DeflateAlgorithm) { println("advzip is not installed; skipping re-deflation of $zip") return } - + try { val process = ProcessBuilder("advzip", "-z", "-${type.id}", zip.absolutePath).start() val exitCode = process.waitFor() @@ -188,10 +189,11 @@ val JAVA_HOME = System.getProperty("java.home") @Suppress("UnstableApiUsage") fun applyProguard(jar: File, minecraftConfigs: List, configDir: File) { val inputJar = jar.copyTo( - jar.parentFile.resolve(".${jar.nameWithoutExtension}_proguardRunning.jar"), true).also { - it.deleteOnExit() + jar.parentFile.resolve(".${jar.nameWithoutExtension}_proguardRunning.jar"), true + ).also { + it.deleteOnExit() } - + val config = configDir.resolve("proguard.pro") if (!config.exists()) { error("proguard.pro not found") @@ -202,19 +204,20 @@ fun applyProguard(jar: File, minecraftConfigs: List, configDir: "-injars", inputJar.absolutePath, "-outjars", jar.absolutePath, ) - + val libraries = HashSet() libraries.add("${JAVA_HOME}/jmods/java.base.jmod") libraries.add("${JAVA_HOME}/jmods/java.desktop.jmod") for (minecraftConfig in minecraftConfigs) { val prodNamespace = minecraftConfig.mcPatcher.prodNamespace - + libraries.add(minecraftConfig.getMinecraft(prodNamespace, prodNamespace).toFile().absolutePath) - + val minecrafts = listOf( - minecraftConfig.sourceSet.compileClasspath.files, - minecraftConfig.sourceSet.runtimeClasspath.files) + minecraftConfig.sourceSet.compileClasspath.files, + minecraftConfig.sourceSet.runtimeClasspath.files + ) .flatten() .filter { it: File -> !minecraftConfig.isMinecraftJar(it.toPath()) } .toHashSet() @@ -223,31 +226,30 @@ fun applyProguard(jar: File, minecraftConfigs: List, configDir: .filter { it.extension == "jar" && !it.name.startsWith("zume") } .map { it.absolutePath } } - - val debug = Properties().apply { + + val debug = Properties().apply { val gradleproperties = configDir.resolve("gradle.properties") - if(gradleproperties.exists()) { + if (gradleproperties.exists()) { load(gradleproperties.inputStream()) } }.getProperty("zumegradle.proguard.keepAttrs").toBoolean() - - if(debug) { + + if (debug) { proguardCommand.add("-keepattributes") proguardCommand.add("*Annotation*,SourceFile,MethodParameters,L*Table") proguardCommand.add("-dontobfuscate") } - + proguardCommand.add("-libraryjars") proguardCommand.add(libraries.joinToString(File.pathSeparator) { "\"$it\"" }) val configuration = Configuration() - ConfigurationParser(proguardCommand.toTypedArray(), System.getProperties()).use { parser -> - parser.parse(configuration) - } - + ConfigurationParser(proguardCommand.toTypedArray(), System.getProperties()) + .parse(configuration) + try { ProGuard(configuration).execute() - } catch(ex: Exception) { + } catch (ex: Exception) { throw IllegalStateException("ProGuard failed for $jar", ex) } finally { inputJar.delete() @@ -264,43 +266,43 @@ open class CompressJarTask : DefaultTask() { @Input var deflateAlgorithm = DeflateAlgorithm.LIBDEFLATE - + @Input var jsonShrinkingType = JsonShrinkingType.NONE - + @get:Input val useProguard get() = !this.minecraftConfigs.isEmpty() - + private var minecraftConfigs: List = emptyList() @get:OutputFile val outputJar get() = inputJar // compressed jar will replace the input jar - + @get:OutputFile @get:Optional val mappingsFile - get() = if(useProguard) + get() = if (useProguard) inputJar.parentFile.resolve("${inputJar.nameWithoutExtension}-mappings.txt") else null - + @Option(option = "class-file-compression", description = "How to process class files") fun setClassShrinkingType(value: String) { classShrinkingType = ClassShrinkingType.valueOf(value.uppercase()) } - + @Option(option = "compression-type", description = "How to recompress the jar") fun setDeflateAlgorithm(value: String) { deflateAlgorithm = value.uppercase().let { - if(it.matches(Regex("7Z(?:IP)?"))) DeflateAlgorithm.SEVENZIP + if (it.matches(Regex("7Z(?:IP)?"))) DeflateAlgorithm.SEVENZIP else DeflateAlgorithm.valueOf(it) } } - + @Option(option = "json-processing", description = "How to process json files") fun setJsonShrinkingType(value: String) { jsonShrinkingType = JsonShrinkingType.valueOf(value.uppercase()) } - + fun useProguard(minecraftConfigs: List) { this.minecraftConfigs = minecraftConfigs } diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt index f96b4c0e..eb08d01c 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt @@ -4,19 +4,21 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext import groovy.json.JsonOutput import groovy.json.JsonSlurper +import org.apache.tools.zip.ZipEntry +import org.apache.tools.zip.ZipOutputStream import org.gradle.api.file.FileTreeElement import org.gradle.api.tasks.Input -import org.apache.tools.zip.ZipOutputStream -import org.apache.tools.zip.ZipEntry class MixinConfigMergingTransformer : Transformer { - + private val JSON = JsonSlurper() @Input lateinit var modId: String + @Input lateinit var packageName: String + @Input lateinit var mixinPlugin: String @@ -56,7 +58,7 @@ class MixinConfigMergingTransformer : Transformer { override fun modifyOutputStream(os: ZipOutputStream?, preserveFileTimestamps: Boolean) { val mixinConfigEntry = ZipEntry("${modId}.mixins.json") os!!.putNextEntry(mixinConfigEntry) - + val mixinConfigJson = mutableMapOf( "required" to true, "minVersion" to "0.8", @@ -68,8 +70,8 @@ class MixinConfigMergingTransformer : Transformer { "defaultRequire" to 1, ) ) - - if(refMaps.isNotEmpty()) { + + if (refMaps.isNotEmpty()) { val refmapName = "${modId}-refmap.json" mixinConfigJson["refmap"] = refmapName os.putNextEntry(ZipEntry(refmapName)) diff --git a/gradle.properties b/gradle.properties index 3fdb3d8b..e02211c1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -102,7 +102,7 @@ embeddium_neoforge_version = 0.3.20-git-7cfe318+mc1.20.6 # https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 # https://github.com/Nolij/ZSON/releases/ -zson_version = 0.2.1 +zson_version = 0.2.3 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core log4j_version = 3.0.0-beta2 # https://central.sonatype.com/artifact/org.slf4j/slf4j-api diff --git a/integration/embeddium/build.gradle.kts b/integration/embeddium/build.gradle.kts index 31bae868..1aa902d5 100644 --- a/integration/embeddium/build.gradle.kts +++ b/integration/embeddium/build.gradle.kts @@ -6,9 +6,9 @@ operator fun String.invoke(): String = rootProject.properties[this] as? String ? unimined.minecraft { combineWith(project(":api").sourceSets.main.get()) - + version("modern_minecraft_version"()) - + runs.off = true fabric { @@ -18,7 +18,7 @@ unimined.minecraft { mappings { mojmap() } - + defaultRemapJar = false } diff --git a/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java b/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java index 3f9fbf5f..e2feddd2 100644 --- a/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java +++ b/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java @@ -1,11 +1,7 @@ package dev.nolij.zume.integration.implementation.embeddium; import com.google.common.collect.ImmutableList; -import me.jellysquid.mods.sodium.client.gui.options.Option; -import me.jellysquid.mods.sodium.client.gui.options.OptionFlag; -import me.jellysquid.mods.sodium.client.gui.options.OptionGroup; -import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; -import me.jellysquid.mods.sodium.client.gui.options.OptionPage; +import me.jellysquid.mods.sodium.client.gui.options.*; import me.jellysquid.mods.sodium.client.gui.options.control.Control; import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter; import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl; diff --git a/legacy/build.gradle.kts b/legacy/build.gradle.kts index db622815..0062fdb8 100644 --- a/legacy/build.gradle.kts +++ b/legacy/build.gradle.kts @@ -23,5 +23,10 @@ tasks.withType { } dependencies { - "modImplementation"(fabricApi.legacyFabricModule("legacy-fabric-keybindings-api-v1-common", "legacy_fabric_api_version"())) + "modImplementation"( + fabricApi.legacyFabricModule( + "legacy-fabric-keybindings-api-v1-common", + "legacy_fabric_api_version"() + ) + ) } \ No newline at end of file diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java b/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java index 6aa1edc4..382b7af0 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.legacy; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.mixin.legacy.GameRendererAccessor; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; @@ -52,14 +52,15 @@ public boolean isZoomOutPressed() { //noinspection JavaReflectionMemberAccess SmoothUtil.class.getMethod("method_10852"); useWorkaround = false; - } catch (NoSuchMethodException ignored) { } + } catch (NoSuchMethodException ignored) { + } USE_CINEMATIC_CAMERA_WORKAROUND = useWorkaround; - } + } @Override public void onZoomActivate() { - if (USE_CINEMATIC_CAMERA_WORKAROUND && + if (USE_CINEMATIC_CAMERA_WORKAROUND && ZumeConfigAPI.isCinematicZoomEnabled() && !MinecraftClient.getInstance().options.smoothCameraEnabled) { final GameRendererAccessor gameRenderer = (GameRendererAccessor) MinecraftClient.getInstance().gameRenderer; gameRenderer.setCursorXSmoother(new SmoothUtil()); diff --git a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java index 462f6d8f..729bddbd 100644 --- a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java @@ -10,16 +10,22 @@ public interface GameRendererAccessor { @Accessor("cursorXSmoother") void setCursorXSmoother(SmoothUtil value); + @Accessor("cursorYSmoother") void setCursorYSmoother(SmoothUtil value); + @Accessor("cursorDeltaX") void setCursorDeltaX(float value); + @Accessor("cursorDeltaY") void setCursorDeltaY(float value); + @Accessor("smoothedCursorDeltaX") void setSmoothedCursorDeltaX(float value); + @Accessor("smoothedCursorDeltaY") void setSmoothedCursorDeltaY(float value); + @Accessor("lastTickDelta") void setLastTickDelta(float value); diff --git a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java index fc781a56..79994031 100644 --- a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java @@ -51,7 +51,7 @@ public class GameRendererMixin { @ModifyVariable(method = "transformCamera", at = @At(value = "STORE", ordinal = 0), ordinal = 3) public double zume$transformCamera$thirdPersonDistance(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java index 99caae36..188b2405 100644 --- a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java @@ -15,10 +15,12 @@ @Mixin(KeyBinding.class) public class KeyBindingMixin { - @SuppressWarnings({"MissingUnique", "unused", "MismatchedQueryAndUpdateOfCollection"}) + @SuppressWarnings({ "MissingUnique", "unused", "MismatchedQueryAndUpdateOfCollection" }) private static Map field_15867; // vintage intermediary - @Shadow @Final private static Set categories; + @Shadow + @Final + private static Set categories; @Inject(method = "", at = @At("TAIL")) private static void static$TAIL(CallbackInfo ci) { diff --git a/legacy/src/main/resources/zume-legacy.mixins.json b/legacy/src/main/resources/zume-legacy.mixins.json index 37b5497c..1ca03fe1 100644 --- a/legacy/src/main/resources/zume-legacy.mixins.json +++ b/legacy/src/main/resources/zume-legacy.mixins.json @@ -4,11 +4,11 @@ "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", "client": [ - "legacy.MinecraftClientMixin", "legacy.GameOptionsMixin", "legacy.GameRendererAccessor", "legacy.GameRendererMixin", - "legacy.KeyBindingMixin" + "legacy.KeyBindingMixin", + "legacy.MinecraftClientMixin" ], "injectors": { "defaultRequire": 1 diff --git a/lexforge/build.gradle.kts b/lexforge/build.gradle.kts index 632ec406..2bd02159 100644 --- a/lexforge/build.gradle.kts +++ b/lexforge/build.gradle.kts @@ -8,7 +8,7 @@ val modRuntimeOnly: Configuration by configurations.creating { unimined.minecraft { combineWith(project(":integration:embeddium").sourceSets.main.get()) - + version("lexforge_minecraft_version"()) minecraftForge { @@ -28,12 +28,14 @@ unimined.minecraft { } } } - + runs.config("client") { - jvmArgs.addAll(listOf( - "-Dmixin.env.remapRefMap=true", - "-Dmixin.env.refMapRemappingFile=${(mcPatcher as ForgeLikeMinecraftTransformer).srgToMCPAsSRG}" - )) + jvmArgs.addAll( + listOf( + "-Dmixin.env.remapRefMap=true", + "-Dmixin.env.refMapRemappingFile=${(mcPatcher as ForgeLikeMinecraftTransformer).srgToMCPAsSRG}" + ) + ) } } @@ -43,7 +45,7 @@ repositories { dependencies { compileOnly(project(":stubs")) - + // mixins fail to apply due to Unimined not liking Embeddium's empty mixin list; test in prod // modRuntimeOnly("org.embeddedt:embeddium-1.20.1:${"embeddium_lexforge_version"()}") } \ No newline at end of file diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java b/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java index cbbc738f..65f8410c 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java +++ b/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.lexforge; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.integration.implementation.embeddium.ZumeEmbeddiumConfigScreen; import net.minecraft.client.Minecraft; @@ -94,13 +94,13 @@ private void calculateFOV(ViewportEvent.ComputeFov event) { ); private void onMouseScroll(InputEvent.MouseScrollingEvent event) { - final int scrollAmount; - try { - scrollAmount = (int) (double) GET_SCROLL_DELTA.invokeExact(event); - } catch (Throwable e) { - throw new AssertionError(e); - } - if (ZumeAPI.mouseScrollHook(scrollAmount)) { + final int scrollAmount; + try { + scrollAmount = (int) (double) GET_SCROLL_DELTA.invokeExact(event); + } catch (Throwable e) { + throw new AssertionError(e); + } + if (ZumeAPI.mouseScrollHook(scrollAmount)) { event.setCanceled(true); } } diff --git a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java index 899cb960..3fb6a1b6 100644 --- a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java index d233ac0d..7bd1e053 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java +++ b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java @@ -1,10 +1,10 @@ package dev.nolij.zume.lexforge16; import cpw.mods.modlauncher.api.INameMappingService; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.Options; diff --git a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java index 15a1417e..3dd348e9 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java index 0b4a8dbc..366ae5f8 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java +++ b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java @@ -1,9 +1,9 @@ package dev.nolij.zume.lexforge18; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientRegistry; diff --git a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java index 8ca0e075..60868e95 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/modern/build.gradle.kts b/modern/build.gradle.kts index 53cc8fd8..b3c2b3c1 100644 --- a/modern/build.gradle.kts +++ b/modern/build.gradle.kts @@ -8,7 +8,7 @@ val modRuntimeOnly: Configuration by configurations.creating { unimined.minecraft { combineWith(project(":integration:embeddium").sourceSets.main.get()) - + version("modern_minecraft_version"()) fabric { @@ -20,7 +20,7 @@ unimined.minecraft { mojmap() devFallbackNamespace("intermediary") } - + mods { remap(modRuntimeOnly) } @@ -40,9 +40,9 @@ repositories { dependencies { compileOnly(project(":stubs")) - + "modImplementation"(fabricApi.fabricModule("fabric-key-binding-api-v1", "modern_fabric_api_version"())) - + "modImplementation"("com.terraformersmc:modmenu:7.+") modRuntimeOnly("org.embeddedt:embeddium-fabric-1.20.1:${"embeddium_fabric_version"()}") diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java index c7aacd9d..37ed9d95 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$update$clipToSpace(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java index 25372c76..26f242c9 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java @@ -15,7 +15,7 @@ public abstract class MouseHandlerMixin { @Dynamic @ModifyExpressionValue(method = { - "turnPlayer", + "turnPlayer", "method_1606(D)V" // 20.5+ compat }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { @@ -26,7 +26,7 @@ public abstract class MouseHandlerMixin { @Dynamic @Group(name = "zume$getMouseSensitivity", min = 1, max = 1) @ModifyExpressionValue(method = { - "turnPlayer", + "turnPlayer", "method_1606(D)V" // 20.5+ compat }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;", ordinal = 0), require = 0) public T zume$updateMouse$getMouseSensitivity$getValue(T original) { diff --git a/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java b/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java index d6a79f74..0553a320 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java +++ b/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.modern; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.integration.implementation.embeddium.ZumeEmbeddiumConfigScreen; import net.fabricmc.api.ClientModInitializer; diff --git a/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java b/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java index baa69a6a..c27db8a0 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java +++ b/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java @@ -28,14 +28,14 @@ public String getModId() { @Override public Function getConfigScreenFactory() { return (parent) -> { - try { - //noinspection DataFlowIssue - return new ModernZumeConfigScreen((Component) LITERALTEXT_INIT.invokeExact(""), parent); - } catch (Throwable e) { + try { + //noinspection DataFlowIssue + return new ModernZumeConfigScreen((Component) LITERALTEXT_INIT.invokeExact(""), parent); + } catch (Throwable e) { ZumeAPI.getLogger().error("Error opening config screen: ", e); return null; - } - }; + } + }; } @Override diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 81d51f93..e93d6602 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -6,7 +6,7 @@ val modRuntimeOnly: Configuration by configurations.creating { unimined.minecraft { combineWith(project(":integration:embeddium").sourceSets.main.get()) - + version("neoforge_minecraft_version"()) neoForged { @@ -33,6 +33,6 @@ repositories { dependencies { compileOnly(project(":stubs")) - + modRuntimeOnly("org.embeddedt:embeddium-1.20.6:${"embeddium_neoforge_version"()}") } \ No newline at end of file diff --git a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java index 34e140e6..66de67cb 100644 --- a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.neoforge; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.integration.implementation.embeddium.ZumeEmbeddiumConfigScreen; import net.minecraft.client.Minecraft; @@ -16,11 +16,7 @@ import net.neoforged.fml.common.Mod; import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.fml.loading.FMLPaths; -import net.neoforged.neoforge.client.event.CalculateDetachedCameraDistanceEvent; -import net.neoforged.neoforge.client.event.CalculatePlayerTurnEvent; -import net.neoforged.neoforge.client.event.InputEvent; -import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; -import net.neoforged.neoforge.client.event.ViewportEvent; +import net.neoforged.neoforge.client.event.*; import net.neoforged.neoforge.common.NeoForge; import org.jetbrains.annotations.NotNull; @@ -54,6 +50,7 @@ public class NeoZume implements IZumeImplementation { private static final Class TICK_EVENT_PHASE = METHOD_HANDLE_HELPER.getClassOrNull( "net.neoforged.neoforge.event.TickEvent$Phase"); private static final Enum TICK_EVENT_PHASE_START; + static { if (TICK_EVENT_PHASE == null) { TICK_EVENT_PHASE_START = null; @@ -65,6 +62,7 @@ public class NeoZume implements IZumeImplementation { } } } + private static final MethodHandle RENDER_TICK_EVENT_PHASE_GETTER = METHOD_HANDLE_HELPER.getGetterOrNull( RENDER_TICK_EVENT, "phase", TICK_EVENT_PHASE, MethodType.methodType(Enum.class, Object.class)); private static final Class RENDER_FRAME_EVENT = METHOD_HANDLE_HELPER.getClassOrNull( @@ -88,13 +86,13 @@ public NeoZume(IEventBus modEventBus, ModContainer modContainer) { .newInstance(); } else //noinspection ConstantValue,UnreachableCode if (CONFIG_SCREEN_EXT_RECORD != null) { - return CONFIG_SCREEN_EXT_RECORD - .getDeclaredConstructor(BiFunction.class) - .newInstance((BiFunction) (minecraft, parent) -> - new NeoZumeConfigScreen(parent)); - } else { - return null; - } + return CONFIG_SCREEN_EXT_RECORD + .getDeclaredConstructor(BiFunction.class) + .newInstance((BiFunction) (minecraft, parent) -> + new NeoZumeConfigScreen(parent)); + } else { + return null; + } } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException(e); @@ -114,9 +112,9 @@ public NeoZume(IEventBus modEventBus, ModContainer modContainer) { //noinspection unchecked NeoForge.EVENT_BUS.addListener((Class) RENDER_FRAME_EVENT, this::render); } else if ( - RENDER_TICK_EVENT != null && - RENDER_TICK_EVENT_PHASE_GETTER != null && - TICK_EVENT_PHASE_START != null) { + RENDER_TICK_EVENT != null && + RENDER_TICK_EVENT_PHASE_GETTER != null && + TICK_EVENT_PHASE_START != null) { //noinspection unchecked NeoForge.EVENT_BUS.addListener((Class) RENDER_TICK_EVENT, this::renderLegacy); } else { @@ -192,7 +190,7 @@ private void onMouseScroll(InputEvent.MouseScrollingEvent event) { } private void calculateDetachedCameraDistance(CalculateDetachedCameraDistanceEvent event) { - event.setDistance(ZumeAPI.thirdPersonCameraHook(event.getDistance())); + event.setDistance(ZumeAPI.thirdPersonCameraHook(event.getDistance())); } } diff --git a/primitive/build.gradle.kts b/primitive/build.gradle.kts index 82808627..df67b05c 100644 --- a/primitive/build.gradle.kts +++ b/primitive/build.gradle.kts @@ -6,7 +6,7 @@ unimined.minecraft { side("client") version("primitive_minecraft_version"()) - + runs.config("client") { javaVersion = JavaVersion.VERSION_17 } @@ -34,7 +34,12 @@ repositories { } dependencies { - "modImplementation"(fabricApi.stationModule(moduleName = "station-keybindings-v0", version = "station_api_version"())) { + "modImplementation"( + fabricApi.stationModule( + moduleName = "station-keybindings-v0", + version = "station_api_version"() + ) + ) { exclude(module = "fabric-loader") exclude(group = "org.ow2.asm") } @@ -43,9 +48,9 @@ dependencies { exclude(module = "fabric-loader") exclude(group = "org.ow2.asm") } - + implementation("io.github.llamalad7:mixinextras-fabric:${"mixinextras_version"()}") - implementation("org.slf4j:slf4j-api:${"slf4j_version"()}") - implementation("org.apache.logging.log4j:log4j-slf4j18-impl:${"log4j_slf4j_version"()}") + implementation("org.slf4j:slf4j-api:${"slf4j_version"()}") + implementation("org.apache.logging.log4j:log4j-slf4j18-impl:${"log4j_slf4j_version"()}") } \ No newline at end of file diff --git a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java index caf9094a..d855fc67 100644 --- a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java @@ -10,6 +10,7 @@ public interface GameRendererAccessor { @Accessor("field_2353") void setCinematicYawSmoother(SmoothUtil value); + @Accessor("field_2354") void setCinematicPitchSmoother(SmoothUtil value); diff --git a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java index 6e8bb8e3..01062cef 100644 --- a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java @@ -37,12 +37,12 @@ public abstract class GameRendererMixin { @ModifyExpressionValue(method = "method_1851", at = @At(value = "FIELD", target = "Lnet/minecraft/class_555;field_2359:F")) public float zume$transformCamera$thirdPersonDistance(float original) { - return (float) ZumeAPI.thirdPersonCameraHook(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } @ModifyExpressionValue(method = "method_1851", at = @At(value = "FIELD", target = "Lnet/minecraft/class_555;field_2360:F")) public float zume$transformCamera$lastThirdPersonDistance(float original) { - return (float) ZumeAPI.thirdPersonCameraHook(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java index 4ed5813a..9edf8b5c 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.primitive; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.mixin.primitive.GameRendererAccessor; import dev.nolij.zume.mixin.primitive.MinecraftAccessor; import net.fabricmc.api.ClientModInitializer; diff --git a/settings.gradle.kts b/settings.gradle.kts index 6cec65cd..3ce27f47 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,11 +1,11 @@ pluginManagement { - repositories { - gradlePluginPortal() - } + repositories { + gradlePluginPortal() + } } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") + id("org.gradle.toolchains.foojay-resolver-convention") version ("0.7.0") } rootProject.name = "zume" diff --git a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java index 014e8171..f779b5df 100644 --- a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java @@ -1,9 +1,9 @@ package dev.nolij.zume; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.legacy.LegacyZume; import dev.nolij.zume.modern.ModernZume; import dev.nolij.zume.primitive.PrimitiveZume; -import dev.nolij.zume.legacy.LegacyZume; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; import net.fabricmc.loader.impl.gui.FabricGuiEntry; @@ -12,10 +12,10 @@ public class FabricZumeBootstrapper implements ClientModInitializer, PreLaunchEntrypoint { private static final String MISSING_DEPENDENCY_MESSAGE = """ - Failed to detect which variant of Zume to load! Ensure all dependencies are installed: - Fabric (14.4+): Fabric API (fabric-key-binding-api-v1) - Legacy Fabric (7.10-12.2): Legacy Fabric API (legacy-fabric-keybinding-api-v1-common) - Babric (b7.3): Station API (station-keybindings-v0)"""; + Failed to detect which variant of Zume to load! Ensure all dependencies are installed: + Fabric (14.4+): Fabric API (fabric-key-binding-api-v1) + Legacy Fabric (7.10-12.2): Legacy Fabric API (legacy-fabric-keybinding-api-v1-common) + Babric (b7.3): Station API (station-keybindings-v0)"""; @Override public void onPreLaunch() { diff --git a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java index 21ffb958..3b74755c 100644 --- a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java @@ -1,8 +1,8 @@ package dev.nolij.zume; import dev.nolij.zume.lexforge.LexZume; -import dev.nolij.zume.lexforge18.LexZume18; import dev.nolij.zume.lexforge16.LexZume16; +import dev.nolij.zume.lexforge18.LexZume18; import dev.nolij.zume.vintage.VintageZume; import net.minecraftforge.fml.common.Mod; @@ -20,11 +20,11 @@ public class ForgeZumeBootstrapper { public ForgeZumeBootstrapper() { if (ZumeMixinPlugin.ZUME_VARIANT == null) throw new AssertionError(""" - Mixins did not load! Zume requires Mixins in order to work properly. - Please install one of the following mixin loaders: - 14.4 - 16.0: MixinBootstrap - 8.9 - 12.2: MixinBooter >= 5.0 - 7.10 - 12.2: UniMixins >= 0.1.15"""); + Mixins did not load! Zume requires Mixins in order to work properly. + Please install one of the following mixin loaders: + 14.4 - 16.0: MixinBootstrap + 8.9 - 12.2: MixinBooter >= 5.0 + 7.10 - 12.2: UniMixins >= 0.1.15"""); switch (ZumeMixinPlugin.ZUME_VARIANT) { case ZumeVariant.LEXFORGE -> new LexZume(); diff --git a/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java b/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java index 3268b0dc..d8475479 100644 --- a/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java +++ b/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java @@ -39,7 +39,8 @@ else if (CLASS_LOADER.getResource("net/minecraftforge/oredict/OreDictionary.clas "getVersion", MethodType.methodType(String.class) ).invokeExact(); - } catch (Throwable ignored) { } + } catch (Throwable ignored) { + } if (forgeVersion != null) { final int major = Integer.parseInt(forgeVersion.substring(0, forgeVersion.indexOf('.'))); @@ -63,7 +64,8 @@ else if (major > 25) } @Override - public void onLoad(String mixinPackage) {} + public void onLoad(String mixinPackage) { + } @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { @@ -79,7 +81,8 @@ public String getRefMapperConfig() { } @Override - public void acceptTargets(Set myTargets, Set otherTargets) {} + public void acceptTargets(Set myTargets, Set otherTargets) { + } @Override public List getMixins() { @@ -87,9 +90,11 @@ public List getMixins() { } @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + } @Override - public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { + } } diff --git a/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java b/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java index f6a844b6..82b12200 100644 --- a/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java +++ b/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java @@ -6,7 +6,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE}) +@Target({ ElementType.TYPE }) public @interface Mod { // Pre/Modern Forge @@ -14,9 +14,13 @@ // Vintage Forge String modid() default ""; + String name() default ""; + String version() default ""; + String acceptedMinecraftVersions() default ""; + String guiFactory() default ""; } diff --git a/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java index c1da7466..a46e80d9 100644 --- a/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java +++ b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java @@ -10,13 +10,13 @@ @Mixin(EntityRenderer.class) public abstract class EntityRendererMixin { - @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, + @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { return ZumeAPI.cinematicCameraEnabledHook(original); } - @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, + @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;mouseSensitivity:F")) public float zume$updateMouse$mouseSensitivity(float original) { return (float) ZumeAPI.mouseSensitivityHook(original); @@ -24,7 +24,7 @@ public abstract class EntityRendererMixin { @ModifyVariable(method = "orientCamera", at = @At(value = "STORE", ordinal = 0), ordinal = 3) public double zume$orientCamera$thirdPersonDistance(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } - + } diff --git a/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java b/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java index 92e6d5d8..9d704930 100644 --- a/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java +++ b/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.vintage; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraft.launchwrapper.Launch; @@ -28,7 +28,7 @@ @Mod( modid = MOD_ID, name = MOD_NAME, - version = MOD_VERSION, + version = MOD_VERSION, acceptedMinecraftVersions = VINTAGE_VERSION_RANGE, guiFactory = "dev.nolij.zume.vintage.VintageConfigProvider") public class VintageZume implements IZumeImplementation { From 2544a773f78b1cb8d7b63678997fcb23d3b421fe Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 31 May 2024 07:47:57 -0400 Subject: [PATCH 47/51] obfuscate old forge config guis - saves ~500 bytes just need the providers also not tested --- .../zume/archaic/ArchaicConfigProvider.java | 15 ----------- .../zume/archaic/ArchaicZumeConfigGUI.java | 25 ++++++++++++++++++ proguard.pro | 2 +- .../zume/vintage/VintageConfigProvider.java | 21 --------------- .../zume/vintage/VintageZumeConfigGUI.java | 26 +++++++++++++++++++ 5 files changed, 52 insertions(+), 37 deletions(-) create mode 100644 archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZumeConfigGUI.java create mode 100644 vintage/src/main/java/dev/nolij/zume/vintage/VintageZumeConfigGUI.java diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicConfigProvider.java b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicConfigProvider.java index d7ada8ae..4ac649cc 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicConfigProvider.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicConfigProvider.java @@ -14,21 +14,6 @@ @SuppressWarnings("unused") public class ArchaicConfigProvider implements IModGuiFactory { - public static class ArchaicZumeConfigGUI extends GuiConfig { - - public ArchaicZumeConfigGUI(GuiScreen parentScreen) { - super(parentScreen, Collections.emptyList(), MOD_ID, false, false, "config"); - - ZumeAPI.openConfigFile(); - } - - @Override - public void initGui() { - Minecraft.getMinecraft().displayGuiScreen(parentScreen); - } - - } - @Override public Class mainConfigGuiClass() { return ArchaicZumeConfigGUI.class; diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZumeConfigGUI.java b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZumeConfigGUI.java new file mode 100644 index 00000000..73728f80 --- /dev/null +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZumeConfigGUI.java @@ -0,0 +1,25 @@ +package dev.nolij.zume.archaic; + +import cpw.mods.fml.client.config.GuiConfig; +import dev.nolij.zume.api.platform.v1.ZumeAPI; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +import java.util.Collections; + +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +public class ArchaicZumeConfigGUI extends GuiConfig { + + public ArchaicZumeConfigGUI(GuiScreen parentScreen) { + super(parentScreen, Collections.emptyList(), MOD_ID, false, false, "config"); + + ZumeAPI.openConfigFile(); + } + + @Override + public void initGui() { + Minecraft.getMinecraft().displayGuiScreen(parentScreen); + } + +} diff --git a/proguard.pro b/proguard.pro index 230f6c9e..3968d8e5 100644 --- a/proguard.pro +++ b/proguard.pro @@ -37,7 +37,7 @@ # Legacy Forge config providers -keep,allowoptimization class dev.nolij.zume.** implements *.*.fml.client.IModGuiFactory --keep,allowoptimization class dev.nolij.zume.** extends *.*.fml.client.config.GuiConfig { *; } +-keep,allowoptimization,allowobfuscation class dev.nolij.zume.** extends *.*.fml.client.config.GuiConfig { *; } -keep,allowoptimization class io.github.prospector.modmenu.** { *; } # ugly classloader hack diff --git a/vintage/src/main/java/dev/nolij/zume/vintage/VintageConfigProvider.java b/vintage/src/main/java/dev/nolij/zume/vintage/VintageConfigProvider.java index f659ed79..1aefb2d8 100644 --- a/vintage/src/main/java/dev/nolij/zume/vintage/VintageConfigProvider.java +++ b/vintage/src/main/java/dev/nolij/zume/vintage/VintageConfigProvider.java @@ -1,35 +1,14 @@ package dev.nolij.zume.vintage; -import dev.nolij.zume.api.platform.v1.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; -import net.minecraftforge.fml.client.config.GuiConfig; -import java.util.Collections; import java.util.Set; -import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; - @SuppressWarnings("unused") public class VintageConfigProvider implements IModGuiFactory { - public static class VintageZumeConfigGUI extends GuiConfig { - - public VintageZumeConfigGUI(GuiScreen parentScreen) { - super(parentScreen, Collections.emptyList(), MOD_ID, false, false, "config"); - - ZumeAPI.openConfigFile(); - } - - @Override - public void initGui() { - this.onGuiClosed(); - Minecraft.getMinecraft().displayGuiScreen(parentScreen); - } - - } - @Override public GuiScreen createConfigGui(GuiScreen parentScreen) { return new VintageZumeConfigGUI(parentScreen); diff --git a/vintage/src/main/java/dev/nolij/zume/vintage/VintageZumeConfigGUI.java b/vintage/src/main/java/dev/nolij/zume/vintage/VintageZumeConfigGUI.java new file mode 100644 index 00000000..d0cf8ce8 --- /dev/null +++ b/vintage/src/main/java/dev/nolij/zume/vintage/VintageZumeConfigGUI.java @@ -0,0 +1,26 @@ +package dev.nolij.zume.vintage; + +import dev.nolij.zume.api.platform.v1.ZumeAPI; +import net.minecraftforge.fml.client.config.GuiConfig; +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.GuiScreen; + +import java.util.Collections; + +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +public class VintageZumeConfigGUI extends GuiConfig { + + public VintageZumeConfigGUI(GuiScreen parentScreen) { + super(parentScreen, Collections.emptyList(), MOD_ID, false, false, "config"); + + ZumeAPI.openConfigFile(); + } + + @Override + public void initGui() { + this.onGuiClosed(); + Minecraft.getMinecraft().displayGuiScreen(parentScreen); + } + +} From a41e5068a649a8c36c66aef5f244508c3329af71 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 31 May 2024 10:03:11 -0400 Subject: [PATCH 48/51] obfuscate old forge config gui providers - saves ~200 bytes --- .../dev/nolij/zumegradle/JarCompressing.kt | 16 ++++++++++++++-- proguard.pro | 6 ++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 31e264bc..0cdeba4d 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -93,7 +93,7 @@ fun squishJar(jar: File, classProcessing: ClassShrinkingType, jsonProcessing: Js } if (name.endsWith(".class")) { - bytes = processClassFile(bytes, classProcessing) + bytes = processClassFile(bytes, classProcessing, mappings!!) } out.putNextEntry(JarEntry(name)) @@ -137,7 +137,7 @@ private fun remapMixinConfig(bytes: ByteArray, mappings: MemoryMappingTree): Byt return JsonOutput.toJson(json).toByteArray() } -private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinkingType): ByteArray { +private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinkingType, mappings: MemoryMappingTree): ByteArray { val classNode = ClassNode() ClassReader(bytes).accept(classNode, 0) @@ -150,6 +150,18 @@ private fun processClassFile(bytes: ByteArray, classFileSettings: ClassShrinking if (classFileSettings.shouldStripSourceFiles()) { classNode.sourceFile = null } + + for(annotation in classNode.visibleAnnotations ?: emptyList()) { + if(annotation.desc.endsWith("fml/common/Mod;")) { + for (i in 0 until annotation.values.size step 2) { + if (annotation.values[i] == "guiFactory") { + var old = annotation.values[i + 1] as String + annotation.values[i + 1] = mappings.obfuscate(old) + println("Remapped guiFactory: $old -> ${annotation.values[i + 1]}") + } + } + } + } if (classNode.invisibleAnnotations?.map { it.desc }?.contains("Lorg/spongepowered/asm/mixin/Mixin;") == true) { classNode.methods.removeAll { it.name == "" && it.instructions.size() <= 3 } // ALOAD, super(), RETURN diff --git a/proguard.pro b/proguard.pro index 3968d8e5..955db377 100644 --- a/proguard.pro +++ b/proguard.pro @@ -36,8 +36,10 @@ } # Legacy Forge config providers --keep,allowoptimization class dev.nolij.zume.** implements *.*.fml.client.IModGuiFactory --keep,allowoptimization,allowobfuscation class dev.nolij.zume.** extends *.*.fml.client.config.GuiConfig { *; } +-keep,allowoptimization,allowobfuscation class dev.nolij.zume.** implements *.*.fml.client.IModGuiFactory +-keepclassmembers,allowoptimization class dev.nolij.zume.** extends *.*.fml.client.config.GuiConfig { + public ; +} -keep,allowoptimization class io.github.prospector.modmenu.** { *; } # ugly classloader hack From a23c821681bf19b04e13df8d30b6900c58b4019a Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 31 May 2024 17:13:50 -0400 Subject: [PATCH 49/51] Revert "run formatter, remove unused stuff from editorconfig" This reverts commit a92261e7 --- .editorconfig | 198 +++++++++++++++++- .github/workflows/dco.yml | 10 +- CHANGELOG.md | 3 +- README.md | 42 ++-- .../api/platform/v1/IZumeImplementation.java | 19 +- .../nolij/zume/api/platform/v1/ZumeAPI.java | 18 +- .../zume/api/util/v1/MethodHandleHelper.java | 7 +- .../java/dev/nolij/zume/impl/EasedDouble.java | 2 +- .../nolij/zume/impl/IZumeImplementation.java | 2 - .../main/java/dev/nolij/zume/impl/Zume.java | 16 +- .../nolij/zume/impl/config/FileWatcher.java | 2 +- .../nolij/zume/impl/config/IFileWatcher.java | 2 - .../zume/impl/config/ZumeConfigImpl.java | 43 ++-- archaic/build.gradle.kts | 4 +- .../dev/nolij/zume/archaic/ArchaicZume.java | 14 +- .../mixin/archaic/EntityRendererAccessor.java | 10 +- .../mixin/archaic/EntityRendererMixin.java | 16 +- build.gradle.kts | 182 ++++++++-------- buildSrc/build.gradle.kts | 2 +- .../dev/nolij/zumegradle/JarCompressing.kt | 5 +- .../MixinConfigMergingTransformer.kt | 14 +- gradle.properties | 2 +- integration/embeddium/build.gradle.kts | 6 +- .../embeddium/ZumeEmbeddiumConfigScreen.java | 6 +- legacy/build.gradle.kts | 7 +- .../dev/nolij/zume/legacy/LegacyZume.java | 9 +- .../mixin/legacy/GameRendererAccessor.java | 6 - .../zume/mixin/legacy/GameRendererMixin.java | 2 +- .../zume/mixin/legacy/KeyBindingMixin.java | 6 +- .../main/resources/zume-legacy.mixins.json | 4 +- lexforge/build.gradle.kts | 16 +- .../java/dev/nolij/zume/lexforge/LexZume.java | 16 +- .../zume/mixin/lexforge/CameraMixin.java | 2 +- .../dev/nolij/zume/lexforge16/LexZume16.java | 2 +- .../zume/mixin/lexforge16/CameraMixin.java | 2 +- .../dev/nolij/zume/lexforge18/LexZume18.java | 2 +- .../zume/mixin/lexforge18/CameraMixin.java | 2 +- modern/build.gradle.kts | 8 +- .../nolij/zume/mixin/modern/CameraMixin.java | 2 +- .../zume/mixin/modern/MouseHandlerMixin.java | 4 +- .../dev/nolij/zume/modern/ModernZume.java | 2 +- .../modmenu/ZumeModMenuIntegration.java | 12 +- neoforge/build.gradle.kts | 4 +- .../java/dev/nolij/zume/neoforge/NeoZume.java | 32 +-- primitive/build.gradle.kts | 15 +- .../mixin/primitive/GameRendererAccessor.java | 1 - .../mixin/primitive/GameRendererMixin.java | 4 +- .../nolij/zume/primitive/PrimitiveZume.java | 2 +- settings.gradle.kts | 8 +- .../nolij/zume/FabricZumeBootstrapper.java | 10 +- .../dev/nolij/zume/ForgeZumeBootstrapper.java | 12 +- .../java/dev/nolij/zume/ZumeMixinPlugin.java | 15 +- .../net/minecraftforge/fml/common/Mod.java | 6 +- .../mixin/vintage/EntityRendererMixin.java | 8 +- .../dev/nolij/zume/vintage/VintageZume.java | 4 +- 55 files changed, 483 insertions(+), 367 deletions(-) diff --git a/.editorconfig b/.editorconfig index 050ac30b..9078b44c 100644 --- a/.editorconfig +++ b/.editorconfig @@ -131,7 +131,7 @@ ij_java_for_statement_wrap = off ij_java_generate_final_locals = false ij_java_generate_final_parameters = false ij_java_if_brace_force = never -ij_java_imports_layout = *, |, javax.**, java.**, |, $* +ij_java_imports_layout = *,|,javax.**,java.**,|,$* ij_java_indent_case_from_switch = true ij_java_insert_inner_class_imports = false ij_java_insert_override_annotation = true @@ -168,7 +168,7 @@ ij_java_names_count_to_use_import_on_demand = 3 ij_java_new_line_after_lparen_in_annotation = false ij_java_new_line_after_lparen_in_deconstruction_pattern = true ij_java_new_line_after_lparen_in_record_header = false -ij_java_packages_to_use_import_on_demand = java.awt.*, javax.swing.* +ij_java_packages_to_use_import_on_demand = java.awt.*,javax.swing.* ij_java_parameter_annotation_wrap = off ij_java_parentheses_expression_new_line_after_left_paren = false ij_java_parentheses_expression_right_paren_on_new_line = false @@ -291,6 +291,196 @@ ij_java_wrap_comments = false ij_java_wrap_first_method_in_call_chain = false ij_java_wrap_long_lines = false +[{*.gant,*.groovy,*.gy}] +ij_smart_tabs = false +ij_groovy_align_group_field_declarations = false +ij_groovy_align_multiline_array_initializer_expression = false +ij_groovy_align_multiline_assignment = false +ij_groovy_align_multiline_binary_operation = false +ij_groovy_align_multiline_chained_methods = false +ij_groovy_align_multiline_extends_list = false +ij_groovy_align_multiline_for = true +ij_groovy_align_multiline_list_or_map = true +ij_groovy_align_multiline_method_parentheses = false +ij_groovy_align_multiline_parameters = true +ij_groovy_align_multiline_parameters_in_calls = false +ij_groovy_align_multiline_resources = true +ij_groovy_align_multiline_ternary_operation = false +ij_groovy_align_multiline_throws_list = false +ij_groovy_align_named_args_in_map = true +ij_groovy_align_throws_keyword = false +ij_groovy_array_initializer_new_line_after_left_brace = false +ij_groovy_array_initializer_right_brace_on_new_line = false +ij_groovy_array_initializer_wrap = off +ij_groovy_assert_statement_wrap = off +ij_groovy_assignment_wrap = off +ij_groovy_binary_operation_wrap = off +ij_groovy_blank_lines_after_class_header = 0 +ij_groovy_blank_lines_after_imports = 1 +ij_groovy_blank_lines_after_package = 1 +ij_groovy_blank_lines_around_class = 1 +ij_groovy_blank_lines_around_field = 0 +ij_groovy_blank_lines_around_field_in_interface = 0 +ij_groovy_blank_lines_around_method = 1 +ij_groovy_blank_lines_around_method_in_interface = 1 +ij_groovy_blank_lines_before_imports = 1 +ij_groovy_blank_lines_before_method_body = 0 +ij_groovy_blank_lines_before_package = 0 +ij_groovy_block_brace_style = end_of_line +ij_groovy_block_comment_add_space = false +ij_groovy_block_comment_at_first_column = true +ij_groovy_call_parameters_new_line_after_left_paren = false +ij_groovy_call_parameters_right_paren_on_new_line = false +ij_groovy_call_parameters_wrap = off +ij_groovy_catch_on_new_line = false +ij_groovy_class_annotation_wrap = split_into_lines +ij_groovy_class_brace_style = end_of_line +ij_groovy_class_count_to_use_import_on_demand = 5 +ij_groovy_do_while_brace_force = never +ij_groovy_else_on_new_line = false +ij_groovy_enable_groovydoc_formatting = true +ij_groovy_enum_constants_wrap = off +ij_groovy_extends_keyword_wrap = off +ij_groovy_extends_list_wrap = off +ij_groovy_field_annotation_wrap = split_into_lines +ij_groovy_finally_on_new_line = false +ij_groovy_for_brace_force = never +ij_groovy_for_statement_new_line_after_left_paren = false +ij_groovy_for_statement_right_paren_on_new_line = false +ij_groovy_for_statement_wrap = off +ij_groovy_ginq_general_clause_wrap_policy = 2 +ij_groovy_ginq_having_wrap_policy = 1 +ij_groovy_ginq_indent_having_clause = true +ij_groovy_ginq_indent_on_clause = true +ij_groovy_ginq_on_wrap_policy = 1 +ij_groovy_ginq_space_after_keyword = true +ij_groovy_if_brace_force = never +ij_groovy_import_annotation_wrap = 2 +ij_groovy_imports_layout = *,|,javax.**,java.**,|,$* +ij_groovy_indent_case_from_switch = true +ij_groovy_indent_label_blocks = true +ij_groovy_insert_inner_class_imports = false +ij_groovy_keep_blank_lines_before_right_brace = 2 +ij_groovy_keep_blank_lines_in_code = 2 +ij_groovy_keep_blank_lines_in_declarations = 2 +ij_groovy_keep_control_statement_in_one_line = true +ij_groovy_keep_first_column_comment = true +ij_groovy_keep_multiple_expressions_in_one_line = false +ij_groovy_keep_simple_blocks_in_one_line = false +ij_groovy_keep_simple_classes_in_one_line = true +ij_groovy_keep_simple_lambdas_in_one_line = true +ij_groovy_keep_simple_methods_in_one_line = true +ij_groovy_label_indent_absolute = false +ij_groovy_label_indent_size = 0 +ij_groovy_lambda_brace_style = end_of_line +ij_groovy_layout_static_imports_separately = true +ij_groovy_line_comment_add_space = false +ij_groovy_line_comment_add_space_on_reformat = false +ij_groovy_line_comment_at_first_column = true +ij_groovy_method_annotation_wrap = split_into_lines +ij_groovy_method_brace_style = end_of_line +ij_groovy_method_call_chain_wrap = off +ij_groovy_method_parameters_new_line_after_left_paren = false +ij_groovy_method_parameters_right_paren_on_new_line = false +ij_groovy_method_parameters_wrap = off +ij_groovy_modifier_list_wrap = false +ij_groovy_names_count_to_use_import_on_demand = 3 +ij_groovy_packages_to_use_import_on_demand = java.awt.*,javax.swing.* +ij_groovy_parameter_annotation_wrap = off +ij_groovy_parentheses_expression_new_line_after_left_paren = false +ij_groovy_parentheses_expression_right_paren_on_new_line = false +ij_groovy_prefer_parameters_wrap = false +ij_groovy_resource_list_new_line_after_left_paren = false +ij_groovy_resource_list_right_paren_on_new_line = false +ij_groovy_resource_list_wrap = off +ij_groovy_space_after_assert_separator = true +ij_groovy_space_after_colon = true +ij_groovy_space_after_comma = true +ij_groovy_space_after_comma_in_type_arguments = true +ij_groovy_space_after_for_semicolon = true +ij_groovy_space_after_quest = true +ij_groovy_space_after_type_cast = true +ij_groovy_space_before_annotation_parameter_list = false +ij_groovy_space_before_array_initializer_left_brace = false +ij_groovy_space_before_assert_separator = false +ij_groovy_space_before_catch_keyword = true +ij_groovy_space_before_catch_left_brace = true +ij_groovy_space_before_catch_parentheses = true +ij_groovy_space_before_class_left_brace = true +ij_groovy_space_before_closure_left_brace = true +ij_groovy_space_before_colon = true +ij_groovy_space_before_comma = false +ij_groovy_space_before_do_left_brace = true +ij_groovy_space_before_else_keyword = true +ij_groovy_space_before_else_left_brace = true +ij_groovy_space_before_finally_keyword = true +ij_groovy_space_before_finally_left_brace = true +ij_groovy_space_before_for_left_brace = true +ij_groovy_space_before_for_parentheses = true +ij_groovy_space_before_for_semicolon = false +ij_groovy_space_before_if_left_brace = true +ij_groovy_space_before_if_parentheses = true +ij_groovy_space_before_method_call_parentheses = false +ij_groovy_space_before_method_left_brace = true +ij_groovy_space_before_method_parentheses = false +ij_groovy_space_before_quest = true +ij_groovy_space_before_record_parentheses = false +ij_groovy_space_before_switch_left_brace = true +ij_groovy_space_before_switch_parentheses = true +ij_groovy_space_before_synchronized_left_brace = true +ij_groovy_space_before_synchronized_parentheses = true +ij_groovy_space_before_try_left_brace = true +ij_groovy_space_before_try_parentheses = true +ij_groovy_space_before_while_keyword = true +ij_groovy_space_before_while_left_brace = true +ij_groovy_space_before_while_parentheses = true +ij_groovy_space_in_named_argument = true +ij_groovy_space_in_named_argument_before_colon = false +ij_groovy_space_within_empty_array_initializer_braces = false +ij_groovy_space_within_empty_method_call_parentheses = false +ij_groovy_spaces_around_additive_operators = true +ij_groovy_spaces_around_assignment_operators = true +ij_groovy_spaces_around_bitwise_operators = true +ij_groovy_spaces_around_equality_operators = true +ij_groovy_spaces_around_lambda_arrow = true +ij_groovy_spaces_around_logical_operators = true +ij_groovy_spaces_around_multiplicative_operators = true +ij_groovy_spaces_around_regex_operators = true +ij_groovy_spaces_around_relational_operators = true +ij_groovy_spaces_around_shift_operators = true +ij_groovy_spaces_within_annotation_parentheses = false +ij_groovy_spaces_within_array_initializer_braces = false +ij_groovy_spaces_within_braces = true +ij_groovy_spaces_within_brackets = false +ij_groovy_spaces_within_cast_parentheses = false +ij_groovy_spaces_within_catch_parentheses = false +ij_groovy_spaces_within_for_parentheses = false +ij_groovy_spaces_within_gstring_injection_braces = false +ij_groovy_spaces_within_if_parentheses = false +ij_groovy_spaces_within_list_or_map = false +ij_groovy_spaces_within_method_call_parentheses = false +ij_groovy_spaces_within_method_parentheses = false +ij_groovy_spaces_within_parentheses = false +ij_groovy_spaces_within_switch_parentheses = false +ij_groovy_spaces_within_synchronized_parentheses = false +ij_groovy_spaces_within_try_parentheses = false +ij_groovy_spaces_within_tuple_expression = false +ij_groovy_spaces_within_while_parentheses = false +ij_groovy_special_else_if_treatment = true +ij_groovy_ternary_operation_wrap = off +ij_groovy_throws_keyword_wrap = off +ij_groovy_throws_list_wrap = off +ij_groovy_use_flying_geese_braces = false +ij_groovy_use_fq_class_names = false +ij_groovy_use_fq_class_names_in_javadoc = true +ij_groovy_use_relative_indents = false +ij_groovy_use_single_class_imports = true +ij_groovy_variable_annotation_wrap = off +ij_groovy_while_brace_force = never +ij_groovy_while_on_new_line = false +ij_groovy_wrap_chain_calls_after_dot = false +ij_groovy_wrap_long_lines = false + [{*.har,*.jsb2,*.jsb3,*.json,*.png.mcmeta,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config,mcmod.info,pack.mcmeta}] ij_smart_tabs = false ij_json_array_wrapping = split_into_lines @@ -306,7 +496,3 @@ ij_json_space_before_comma = false ij_json_spaces_within_braces = false ij_json_spaces_within_brackets = false ij_json_wrap_long_lines = false - -[*.properties] -ij_properties_spaces_around_key_value_delimiter = true -ij_properties_keep_blank_lines = true diff --git a/.github/workflows/dco.yml b/.github/workflows/dco.yml index f5485105..d7d1f907 100644 --- a/.github/workflows/dco.yml +++ b/.github/workflows/dco.yml @@ -1,9 +1,9 @@ name: "DCO Assistant" on: issue_comment: - types: [ created ] + types: [created] pull_request_target: - types: [ opened, closed, synchronize ] + types: [opened, closed, synchronize] permissions: actions: write @@ -17,9 +17,9 @@ jobs: steps: - name: "DCO Assistant" if: ( - github.event.comment.body == 'recheck' || - github.event.comment.body == 'I have read and hereby affirm the entire contents of the Developer Certificate of Origin.' - ) || github.event_name == 'pull_request_target' + github.event.comment.body == 'recheck' || + github.event.comment.body == 'I have read and hereby affirm the entire contents of the Developer Certificate of Origin.' + ) || github.event_name == 'pull_request_target' uses: cla-assistant/github-action@v2.3.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index b9dc3a27..d0e24b7c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,2 @@ - added Embeddium config screen integration -- further improvements to overall system stability and other minor adjustments have been made to enhance the user - experience \ No newline at end of file +- further improvements to overall system stability and other minor adjustments have been made to enhance the user experience \ No newline at end of file diff --git a/README.md b/README.md index b8b1bc11..017a4424 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,27 @@ # IMPORTANT LICENSE NOTICE -By using this project in any form, you hereby give your "express assent" for the terms of the license of this -project (see [License](#license)), and acknowledge that I (the author of this project) have fulfilled my obligation -under the license to "make a reasonable effort under the circumstances to obtain the express assent of recipients to +By using this project in any form, you hereby give your "express assent" for the terms of the license of this +project (see [License](#license)), and acknowledge that I (the author of this project) have fulfilled my obligation +under the license to "make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License". # Zume An ~~over-engineered~~ simple zoom mod. -This mod adds a keybind which zooms in your FOV while it's held down, allowing you to see further away, and keybinds +This mod adds a keybind which zooms in your FOV while it's held down, allowing you to see further away, and keybinds for increasing and decreasing the zoom level. # FAQ #### Q: Where is the config? -A: You'll find the config at `.minecraft/global/zume.json5` (note that this is the default `.minecraft` folder, not -the instance `.minecraft`). You can modify the file while the game is running, and the config will be automatically -reloaded. On platforms which have mod menus (such as Forge, and Fabric with [Mod Menu](https://modrinth.com/mod/modmenu) +A: You'll find the config at `.minecraft/global/zume.json5` (note that this is the default `.minecraft` folder, not +the instance `.minecraft`). You can modify the file while the game is running, and the config will be automatically +reloaded. On platforms which have mod menus (such as Forge, and Fabric with [Mod Menu](https://modrinth.com/mod/modmenu) installed), the config button for Zume will open this file in your system text editor. #### Q: discord where - A: https://discord.gg/6ZjX4mvCMR #### Q: What version is this for? @@ -39,35 +38,34 @@ A: Zume supports the following platforms: #### Q: Can you add support for \? -A: Every platform I intend to add support for myself is already supported. PRs are welcome for other platforms **if +A: Every platform I intend to add support for myself is already supported. PRs are welcome for other platforms **if the following conditions are met**: - Must not break single-jar compatibility with any already supported platform (obviously). -- Must not be for a platform that has a 1st-party compatibility layer for an already supported platform - explicit - Quilt support will not be accepted so long as Quilt maintains a Fabric compatibility layer; it'd be a waste of CI - time. [Sinytra Connector](https://github.com/Sinytra/Connector) is a 3rd-party compatibility layer, so explicit +- Must not be for a platform that has a 1st-party compatibility layer for an already supported platform - explicit + Quilt support will not be accepted so long as Quilt maintains a Fabric compatibility layer; it'd be a waste of CI + time. [Sinytra Connector](https://github.com/Sinytra/Connector) is a 3rd-party compatibility layer, so explicit Forge support will be provided. -- Must not manually maintain overridden game options; implementations that look like +- Must not manually maintain overridden game options; implementations that look like [Mooz's](https://github.com/embeddedt/Mooz/blob/92570f7449a7e71c1c0b988788027b10c00f1346/src/main/java/org/embeddedt/mooz/ClientProxy.java#L35-L56) - will not be accepted - no offense [embeddedt](https://github.com/embeddedt). Direct ASM is fine as long as - functionality is similar enough. -- Must make a reasonable effort to be maximize compatibility with existing mods on target platforms - see use of - Neo/LexForge API over mixins in Neo/LexForge implementations, and use of `@WrapWithCondition` and + will not be accepted - no offense [embeddedt](https://github.com/embeddedt). Direct ASM is fine as long as functionality is similar enough. +- Must make a reasonable effort to be maximize compatibility with existing mods on target platforms - see use of + Neo/LexForge API over mixins in Neo/LexForge implementations, and use of `@WrapWithCondition` and `@ModifyExpressionValue` and such from MixinExtras over `@Redirect` in most implementations. - Must follow existing format - add a Unimined subproject for each newly supported platform. -- Must not have exclusive features without significant justification - if you're adding a feature, add it to every +- Must not have exclusive features without significant justification - if you're adding a feature, add it to every version. #### Q: What kind of weird license is this? -A: OSL-3.0 is the closest equivalent to a LAGPL I could find. AGPL and GPL are incompatible with Minecraft, and LGPL +A: OSL-3.0 is the closest equivalent to a LAGPL I could find. AGPL and GPL are incompatible with Minecraft, and LGPL doesn't protect network use. OSL-3.0 protects network use and is compatible with Minecraft. #### Q: Why though? It's so strict!!!! -A: This is, and will remain, free, copyleft software. Any requests to change the license other than to make it even -stronger will be denied immediately (unfortunately GPL and AGPL aren't compatible with Minecraft due to linking -restrictions, as much as I'd like to use them). Even in situations where I use parts of other projects with more +A: This is, and will remain, free, copyleft software. Any requests to change the license other than to make it even +stronger will be denied immediately (unfortunately GPL and AGPL aren't compatible with Minecraft due to linking +restrictions, as much as I'd like to use them). Even in situations where I use parts of other projects with more "permissive" licenses, I will treat them as copyleft, free software. ## License diff --git a/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java b/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java index a2dcaeba..a5fa211b 100644 --- a/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java +++ b/api/src/main/java/dev/nolij/zume/api/platform/v1/IZumeImplementation.java @@ -8,21 +8,12 @@ @ApiStatus.OverrideOnly public interface IZumeImplementation { - @Contract(pure = true) - boolean isZoomPressed(); + @Contract(pure = true) boolean isZoomPressed(); + @Contract(pure = true) boolean isZoomInPressed(); + @Contract(pure = true) boolean isZoomOutPressed(); - @Contract(pure = true) - boolean isZoomInPressed(); + @Contract(pure = true) @NotNull CameraPerspective getCameraPerspective(); - @Contract(pure = true) - boolean isZoomOutPressed(); - - @Contract(pure = true) - @NotNull - CameraPerspective getCameraPerspective(); - - @NonBlocking - default void onZoomActivate() { - } + @NonBlocking default void onZoomActivate() {} } diff --git a/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java b/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java index 08193262..17a17e36 100644 --- a/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java +++ b/api/src/main/java/dev/nolij/zume/api/platform/v1/ZumeAPI.java @@ -27,7 +27,7 @@ public static void openConfigFile() { /** * Invoke this in the initializer of your Zume implementation. * - * @param implementation The {@linkplain IZumeImplementation} Zume should use. + * @param implementation The {@linkplain IZumeImplementation} Zume should use. * @param instanceConfigPath The {@linkplain Path} Zume should use for storing the instance-specific config. */ public static void registerImplementation(@NotNull final IZumeImplementation implementation, @@ -61,7 +61,6 @@ public void onZoomActivate() { } //region Query Methods - /** * Returns `true` if Zoom is activated. */ @@ -88,9 +87,8 @@ public static boolean isMouseScrollHookActive() { //endregion //region Hooks - /** - * This should be invoked once at the beginning of every frame. + * This should be invoked once at the beginning of every frame. * It will handle Keybindings and Zoom Scrolling if the other hooks in this API are used correctly. */ public static void renderHook() { @@ -98,19 +96,19 @@ public static void renderHook() { } /** - * ONLY INVOKE THIS METHOD WHEN {@linkplain ZumeAPI#isFOVHookActive()} RETURNS `true`. + * ONLY INVOKE THIS METHOD WHEN {@linkplain ZumeAPI#isFOVHookActive()} RETURNS `true`. * That check was explicitly excluded from this method for efficiency and for mixin compatibility. * The {@linkplain IZumeImplementation} is responsible for this check. * * @param fov The unmodified FOV value - * {@return The new FOV transformed by Zume} + * {@return The new FOV transformed by Zume} */ public static double fovHook(double fov) { return Zume.transformFOV(fov); } /** - * This method assumes Zume is active and the camera perspective is third-person. + * This method assumes Zume is active and the camera perspective is third-person. * If it is not, using this value will cause bugs. * * @param distance The vanilla third-person camera distance @@ -124,7 +122,7 @@ public static double thirdPersonCameraHook(double distance) { * The return value of this method can be safely used without checking whether Zume is active. * * @param mouseSensitivity The unmodified mouse sensitivity - * {@return The new mouse sensitivity, transformed by Zume} + * {@return The new mouse sensitivity, transformed by Zume} */ public static double mouseSensitivityHook(double mouseSensitivity) { return Zume.transformMouseSensitivity(mouseSensitivity); @@ -134,7 +132,7 @@ public static double mouseSensitivityHook(double mouseSensitivity) { * The return value of this method can be safely used without checking whether Zume is active. * * @param cinematicCameraEnabled The unmodified cinematic camera state - * {@return The new cinematic camera state, transformed by Zume} + * {@return The new cinematic camera state, transformed by Zume} */ public static boolean cinematicCameraEnabledHook(boolean cinematicCameraEnabled) { return Zume.transformCinematicCamera(cinematicCameraEnabled); @@ -144,7 +142,7 @@ public static boolean cinematicCameraEnabledHook(boolean cinematicCameraEnabled) * The return value of this method can be safely used without checking whether Zume is active. * * @param scrollDelta The scroll delta (magnitude will be ignored, only the sign is used) - * {@return `true` if the invoker should prevent further handling of this scroll event} + * {@return `true` if the invoker should prevent further handling of this scroll event} */ public static boolean mouseScrollHook(int scrollDelta) { return Zume.interceptScroll(scrollDelta); diff --git a/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java b/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java index 00c8cc0d..ef22247b 100644 --- a/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java +++ b/api/src/main/java/dev/nolij/zume/api/util/v1/MethodHandleHelper.java @@ -43,14 +43,13 @@ public MethodHandleHelper(@NotNull final ClassLoader classLoader, @NotNull final for (final String className : classNames) { try { return Class.forName(className, true, classLoader); - } catch (ClassNotFoundException ignored) { - } + } catch (ClassNotFoundException ignored) { } } return null; } - public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, + public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, @NotNull final String methodName, @Nullable Class... parameterTypes) { if (clazz == null || Arrays.stream(parameterTypes).anyMatch(Objects::isNull)) @@ -63,7 +62,7 @@ public MethodHandleHelper(@NotNull final ClassLoader classLoader, @NotNull final } } - public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, + public @Nullable MethodHandle getMethodOrNull(@Nullable final Class clazz, @NotNull final String methodName, @Nullable final MethodType methodType, @Nullable Class... parameterTypes) { diff --git a/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java b/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java index 4bc117d0..0ef2820f 100644 --- a/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java +++ b/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java @@ -72,7 +72,7 @@ public void set(double from, double target) { this.targetValue = target; } - public void set(double target) { + public void set(double target) { set(getEased(), target); } diff --git a/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java b/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java index 27f942f3..146ba551 100644 --- a/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java +++ b/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java @@ -3,9 +3,7 @@ public interface IZumeImplementation { boolean isZoomPressed(); - boolean isZoomInPressed(); - boolean isZoomOutPressed(); CameraPerspective getCameraPerspective(); diff --git a/api/src/main/java/dev/nolij/zume/impl/Zume.java b/api/src/main/java/dev/nolij/zume/impl/Zume.java index ca1b20c6..7bcba744 100644 --- a/api/src/main/java/dev/nolij/zume/impl/Zume.java +++ b/api/src/main/java/dev/nolij/zume/impl/Zume.java @@ -1,8 +1,8 @@ package dev.nolij.zume.impl; -import dev.nolij.zume.api.util.v1.EasingHelper; import dev.nolij.zume.api.util.v1.MathHelper; import dev.nolij.zume.impl.config.ZumeConfigImpl; +import dev.nolij.zume.api.util.v1.EasingHelper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -83,7 +83,7 @@ private static void setZoom(final double fromZoom, final double targetZoom) { private static double getThirdPersonStartZoom() { return EasingHelper.inverseOut( - config.minThirdPersonZoomDistance, config.maxThirdPersonZoomDistance, + config.minThirdPersonZoomDistance, config.maxThirdPersonZoomDistance, 4D, config.zoomEasingExponent); } @@ -167,12 +167,12 @@ public static boolean shouldCancelScroll() { } public static boolean interceptScroll(final int scrollDelta) { - if (!shouldCancelScroll() || scrollDelta == 0) - return false; + if (!shouldCancelScroll() || scrollDelta == 0) + return false; - Zume.scrollDelta += MathHelper.sign(scrollDelta); - return true; - } + Zume.scrollDelta += MathHelper.sign(scrollDelta); + return true; + } private static boolean getToggleMode() { return shouldUseFirstPersonZoom() @@ -195,7 +195,7 @@ private static boolean shouldHook() { } private static boolean shouldUseFirstPersonZoom() { - return config.maxThirdPersonZoomDistance == 0 || + return config.maxThirdPersonZoomDistance == 0 || implementation.getCameraPerspective() == CameraPerspective.FIRST_PERSON; } diff --git a/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java index 19392bd9..14ab1069 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java @@ -75,7 +75,7 @@ public void start(Path file, Callback callback) throws IOException { try { if ((locked = tryLock()) && System.currentTimeMillis() > debounce && - Files.exists(changed) && + Files.exists(changed) && Files.isSameFile(changed, file)) { callback.invoke(); debounce = System.currentTimeMillis() + DEBOUNCE_DURATION_MS; diff --git a/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java index a724214b..06b8e5f0 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java @@ -3,9 +3,7 @@ public interface IFileWatcher { void lock() throws InterruptedException; - boolean tryLock(); - void unlock(); } diff --git a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index 4018519e..94433314 100644 --- a/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -1,15 +1,12 @@ package dev.nolij.zume.impl.config; -import dev.nolij.zson.Comment; import dev.nolij.zson.Zson; import dev.nolij.zson.ZsonParser; import dev.nolij.zson.ZsonWriter; +import dev.nolij.zson.Comment; import dev.nolij.zume.impl.Zume; -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -17,8 +14,6 @@ public class ZumeConfigImpl { - //@formatter:off - @Comment(""" Enable Cinematic Camera while zooming. If you disable this, you should also try setting `zoomSmoothnessMs` to `0`. @@ -100,8 +95,6 @@ public class ZumeConfigImpl { DEFAULT: `false`""") public boolean disable = false; - //@formatter:on - private static final int EXPECTED_VERSION = 1; @Comment("Used internally. Don't modify this.") @@ -118,23 +111,23 @@ private static ZumeConfigImpl readFromFile(final File configFile) { while (true) { try { return Zson.map2Obj(ZsonParser.parse(new FileReader(configFile)), ZumeConfigImpl.class); - } catch (IllegalArgumentException e) { + } catch (IllegalArgumentException e) { if (++i < MAX_RETRIES) { - try { - //noinspection BusyWait - Thread.sleep(i * 200L); + try { + //noinspection BusyWait + Thread.sleep(i * 200L); continue; - } catch (InterruptedException ignored) { - return null; - } - } + } catch (InterruptedException ignored) { + return null; + } + } Zume.LOGGER.error("Error parsing config after {} retries: ", i, e); return null; } catch (IOException e) { Zume.LOGGER.error("Error reading config: ", e); return null; - } - } + } + } } private static ZumeConfigImpl readConfigFile() { @@ -191,12 +184,12 @@ public static void replace(final ZumeConfigImpl newConfig) throws InterruptedExc GLOBAL_CONFIG_PATH = dotMinecraft.resolve("global"); if (Files.notExists(GLOBAL_CONFIG_PATH)) { - try { - Files.createDirectories(GLOBAL_CONFIG_PATH); - } catch (IOException e) { - Zume.LOGGER.error("Failed to create global config path: ", e); - } - } + try { + Files.createDirectories(GLOBAL_CONFIG_PATH); + } catch (IOException e) { + Zume.LOGGER.error("Failed to create global config path: ", e); + } + } } public static File getConfigFile() { diff --git a/archaic/build.gradle.kts b/archaic/build.gradle.kts index 71cedcd7..39de4748 100644 --- a/archaic/build.gradle.kts +++ b/archaic/build.gradle.kts @@ -4,12 +4,12 @@ operator fun String.invoke(): String = rootProject.properties[this] as? String ? unimined.minecraft { version("archaic_minecraft_version"()) - + minecraftForge { loader("archaic_forge_version"()) mixinConfig("zume-${project.name}.mixins.json") } - + mappings { searge() mcp("stable", "archaic_mappings_version"()) diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java index 4fa8c561..a2601497 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java @@ -1,18 +1,18 @@ package dev.nolij.zume.archaic; -import cpw.mods.fml.client.registry.ClientRegistry; -import cpw.mods.fml.common.Mod; -import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.Event; import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.relauncher.FMLLaunchHandler; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.mixin.archaic.EntityRendererAccessor; +import cpw.mods.fml.client.registry.ClientRegistry; +import cpw.mods.fml.common.Mod; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; import net.minecraft.client.Minecraft; import net.minecraft.launchwrapper.Launch; import net.minecraft.util.MouseFilter; @@ -87,9 +87,9 @@ public void onZoomActivate() { } private static final MethodHandle SET_CANCELED = MethodHandleHelper.PUBLIC.getMethodOrNull( - Event.class, - "setCanceled", - MethodType.methodType(void.class, MouseEvent.class, boolean.class), + Event.class, + "setCanceled", + MethodType.methodType(void.class, MouseEvent.class, boolean.class), boolean.class); @SubscribeEvent(priority = EventPriority.HIGHEST) diff --git a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java index 42325ceb..3792c800 100644 --- a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java @@ -7,26 +7,20 @@ @Mixin(EntityRenderer.class) public interface EntityRendererAccessor { - + @Accessor("smoothCamFilterX") void setSmoothCamFilterX(float value); - @Accessor("smoothCamFilterY") void setSmoothCamFilterY(float value); - @Accessor("smoothCamYaw") void setSmoothCamYaw(float value); - @Accessor("smoothCamPitch") void setSmoothCamPitch(float value); - @Accessor("smoothCamPartialTicks") void setSmoothCamPartialTicks(float value); - @Accessor("mouseFilterXAxis") void setMouseFilterXAxis(MouseFilter value); - @Accessor("mouseFilterYAxis") void setMouseFilterYAxis(MouseFilter value); - + } diff --git a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java index 46630671..78ea1e0e 100644 --- a/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java @@ -11,7 +11,7 @@ @Mixin(EntityRenderer.class) public abstract class EntityRendererMixin { - + @Inject(method = "updateCameraAndRender", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { ZumeAPI.renderHook(); @@ -24,29 +24,29 @@ public abstract class EntityRendererMixin { return original; } - - @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, + + @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { return ZumeAPI.cinematicCameraEnabledHook(original); } - - @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, + + @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;mouseSensitivity:F")) public float zume$updateMouse$mouseSensitivity(float original) { return (float) ZumeAPI.mouseSensitivityHook(original); } - @ModifyExpressionValue(method = "orientCamera", + @ModifyExpressionValue(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistance:F")) public float zume$orientCamera$thirdPersonDistance(float original) { return (float) ZumeAPI.thirdPersonCameraHook(original); } - @ModifyExpressionValue(method = "orientCamera", + @ModifyExpressionValue(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistanceTemp:F")) public float zume$orientCamera$thirdPersonDistanceTemp(float original) { return (float) ZumeAPI.thirdPersonCameraHook(original); } - + } diff --git a/build.gradle.kts b/build.gradle.kts index 31b4dd23..824a73b1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,10 @@ @file:Suppress("UnstableApiUsage") - import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import dev.nolij.zumegradle.* +import dev.nolij.zumegradle.ClassShrinkingType +import dev.nolij.zumegradle.DeflateAlgorithm +import dev.nolij.zumegradle.JsonShrinkingType +import dev.nolij.zumegradle.MixinConfigMergingTransformer +import dev.nolij.zumegradle.CompressJarTask import kotlinx.serialization.encodeToString import me.modmuss50.mpp.HttpUtils import me.modmuss50.mpp.PublishModTask @@ -23,7 +26,7 @@ import java.nio.file.Files import java.time.ZonedDateTime plugins { - id("java") + id("java") id("maven-publish") id("com.github.johnrengelman.shadow") id("me.modmuss50.mod-publish-plugin") @@ -34,17 +37,16 @@ plugins { operator fun String.invoke(): String = rootProject.properties[this] as? String ?: error("Property $this not found") enum class ReleaseChannel( - val suffix: String? = null, - val releaseType: ReleaseType? = null, - val deflation: DeflateAlgorithm = DeflateAlgorithm.SEVENZIP, - val classes: ClassShrinkingType = ClassShrinkingType.STRIP_ALL, - val json: JsonShrinkingType = JsonShrinkingType.MINIFY, - val proguard: Boolean = true, -) { + val suffix: String? = null, + val releaseType: ReleaseType? = null, + val deflation: DeflateAlgorithm = DeflateAlgorithm.SEVENZIP, + val classes: ClassShrinkingType = ClassShrinkingType.STRIP_ALL, + val json: JsonShrinkingType = JsonShrinkingType.MINIFY, + val proguard: Boolean = true, + ) { DEV_BUILD( suffix = "dev", - json = JsonShrinkingType.PRETTY_PRINT - ), + json = JsonShrinkingType.PRETTY_PRINT), PRE_RELEASE("pre"), RELEASE_CANDIDATE("rc"), RELEASE(releaseType = ReleaseType.STABLE), @@ -59,7 +61,7 @@ val releaseTagPrefix = "release/" val releaseTags = grgit.tag.list() .filter { tag -> tag.name.startsWith(releaseTagPrefix) } - .sortedWith { tag1, tag2 -> + .sortedWith { tag1, tag2 -> if (tag1.commit.dateTime == tag2.commit.dateTime) if (tag1.name.length != tag2.name.length) return@sortedWith tag1.name.length.compareTo(tag2.name.length) @@ -73,7 +75,7 @@ val releaseTags = grgit.tag.list() val isExternalCI = (rootProject.properties["external_publish"] as String?).toBoolean() val isRelease = rootProject.hasProperty("release_channel") || isExternalCI val releaseIncrement = if (isExternalCI) 0 else 1 -val releaseChannel: ReleaseChannel = +val releaseChannel: ReleaseChannel = if (isExternalCI) { val tagName = releaseTags.first().name val suffix = """\-(\w+)\.\d+$""".toRegex().find(tagName)?.groupValues?.get(1) @@ -99,7 +101,7 @@ val patchHistory = releaseTags .map { name -> name.substring(minorTagPrefix.length) } val maxPatch = patchHistory.maxOfOrNull { it.substringBefore('-').toInt() } -val patch = +val patch = maxPatch?.plus( if (patchHistory.contains(maxPatch.toString())) releaseIncrement @@ -110,14 +112,14 @@ var patchAndSuffix = patch.toString() if (releaseChannel.suffix != null) { patchAndSuffix += "-${releaseChannel.suffix}" - + if (isRelease) { patchAndSuffix += "." - + val maxBuild = patchHistory .mapNotNull { it.removePrefix(patchAndSuffix).toIntOrNull() } .maxOrNull() - + val build = (maxBuild?.plus(releaseIncrement)) ?: 1 patchAndSuffix += build.toString() } @@ -159,7 +161,7 @@ val uniminedImpls = arrayOf( *neoForgeImpls, ) -allprojects { +allprojects { apply(plugin = "java") apply(plugin = "maven-publish") @@ -171,15 +173,15 @@ allprojects { } maven("https://repo.spongepowered.org/maven") maven("https://jitpack.io/") - exclusiveContent { + exclusiveContent { forRepository { maven("https://api.modrinth.com/maven") } - filter { + filter { includeGroup("maven.modrinth") } } maven("https://maven.blamejared.com") } - + tasks.withType { if (name !in arrayOf("compileMcLauncherJava", "compilePatchedMcJava")) { options.encoding = "UTF-8" @@ -190,7 +192,7 @@ allprojects { } } } - + dependencies { compileOnly("org.jetbrains:annotations:${"jetbrains_annotations_version"()}") "com.pkware.jabel:jabel-javac-plugin:${"jabel_version"()}".also { @@ -211,14 +213,7 @@ allprojects { .mapValues { entry -> entry.value as String }) props["mod_version"] = Zume.version - filesMatching( - immutableListOf( - "fabric.mod.json", - "mcmod.info", - "META-INF/mods.toml", - "META-INF/neoforge.mods.toml" - ) - ) { + filesMatching(immutableListOf("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "META-INF/neoforge.mods.toml")) { expand(props) } } @@ -227,18 +222,18 @@ allprojects { subprojects { val subProject = this val implName = subProject.name - + group = "maven_group"() version = Zume.version - + base { archivesName = "${"mod_id"()}-${subProject.name}" } - + tasks.withType { enabled = false } - + dependencies { implementation("dev.nolij:zson:${"zson_version"()}:downgraded-8") } @@ -246,7 +241,7 @@ subprojects { if (implName in uniminedImpls) { apply(plugin = "xyz.wagyourtail.unimined") apply(plugin = "com.github.johnrengelman.shadow") - + unimined.minecraft(sourceSets["main"], lateApply = true) { combineWith(project(":api").sourceSets.main.get()) @@ -254,18 +249,18 @@ subprojects { runs.config("server") { disabled = true } - + runs.config("client") { jvmArgs += "-Dzume.configPathOverride=${rootProject.file("zume.json5").absolutePath}" } } - + defaultRemapJar = true } - + val outputJar = tasks.register("outputJar") { group = "build" - + val remapJarTasks = tasks.withType() dependsOn(remapJarTasks) mustRunAfter(remapJarTasks) @@ -280,7 +275,7 @@ subprojects { archiveClassifier = "output" isPreserveFileTimestamps = false isReproducibleFileOrder = true - + relocate("dev.nolij.zume.integration.implementation", "dev.nolij.zume.${implName}.integration") } @@ -288,14 +283,14 @@ subprojects { dependsOn(outputJar) } } - - if (implName in lexForgeImpls) { + + if(implName in lexForgeImpls) { tasks.withType { mixinRemap { disableRefmap() } } - + dependencies { "minecraftLibraries"("dev.nolij:zson:${"zson_version"()}:downgraded-8") } @@ -304,7 +299,7 @@ subprojects { unimined.minecraft { version("modern_minecraft_version"()) - + runs.off = true fabric { @@ -327,12 +322,12 @@ dependencies { shade("dev.nolij:zson:${"zson_version"()}:downgraded-8") compileOnly("org.apache.logging.log4j:log4j-core:${"log4j_version"()}") - + compileOnly(project(":stubs")) - + implementation(project(":api")) - - uniminedImpls.forEach { + + uniminedImpls.forEach { implementation(project(":${it}")) { isTransitive = false } } } @@ -347,14 +342,14 @@ val sourcesJar = tasks.register("sourcesJar") { archiveClassifier = "sources" isPreserveFileTimestamps = false isReproducibleFileOrder = true - + from("LICENSE") { rename { "${it}_${"mod_id"()}" } } - + listOf( - sourceSets, - project(":api").sourceSets, + sourceSets, + project(":api").sourceSets, project(":integration:embeddium").sourceSets, uniminedImpls.flatMap { project(":${it}").sourceSets } ).flatten().forEach { @@ -368,37 +363,34 @@ tasks.shadowJar { packageName = "dev.nolij.zume.mixin" mixinPlugin = "dev.nolij.zume.ZumeMixinPlugin" } - + from("LICENSE") { rename { "${it}_${"mod_id"()}" } } - + exclude("*.xcf") exclude("LICENSE_zson") - + configurations = immutableListOf(shade) archiveClassifier = null isPreserveFileTimestamps = false isReproducibleFileOrder = true - + val apiJar = project(":api").tasks.jar dependsOn(apiJar) from(zipTree(apiJar.get().archiveFile.get())) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE } - + uniminedImpls.map { project(it).tasks.named("outputJar").get() }.forEach { implJarTask -> dependsOn(implJarTask) from(zipTree(implJarTask.archiveFile.get())) { duplicatesStrategy = DuplicatesStrategy.EXCLUDE exclude("fabric.mod.json", "mcmod.info", "META-INF/mods.toml", "pack.mcmeta") - filesMatching( - immutableListOf( - "dev/nolij/zume/lexforge/LexZume.class", - "dev/nolij/zume/lexforge18/LexZume18.class", - "dev/nolij/zume/lexforge16/LexZume16.class", - "dev/nolij/zume/vintage/VintageZume.class" - ) - ) { + filesMatching(immutableListOf( + "dev/nolij/zume/lexforge/LexZume.class", + "dev/nolij/zume/lexforge18/LexZume18.class", + "dev/nolij/zume/lexforge16/LexZume16.class", + "dev/nolij/zume/vintage/VintageZume.class")) { val reader = ClassReader(this.open()) val node = ClassNode() reader.accept(node, 0) @@ -411,12 +403,12 @@ tasks.shadowJar { } } } - + relocate("dev.nolij.zson", "dev.nolij.zume.zson") - if (releaseChannel.proguard) { + if(releaseChannel.proguard) { relocate("dev.nolij.zume.mixin", "zume.mixin") } - + manifest { attributes( "FMLCorePluginContainsFMLMod" to true, @@ -430,10 +422,10 @@ tasks.shadowJar { val compressJar = tasks.register("compressJar") { dependsOn(tasks.shadowJar) group = "build" - + val shadowJar = tasks.shadowJar.get() inputJar = shadowJar.archiveFile.get().asFile - + deflateAlgorithm = releaseChannel.deflation classShrinkingType = releaseChannel.classes jsonShrinkingType = releaseChannel.json @@ -452,7 +444,7 @@ afterEvaluate { if (!System.getenv("local_maven_url").isNullOrEmpty()) maven(System.getenv("local_maven_url")) } - + publications { create("mod_id"()) { artifact(compressJar.get().outputJar) @@ -464,32 +456,32 @@ afterEvaluate { tasks.withType { dependsOn(compressJar, sourcesJar) } - + fun getChangelog(): String { return file("CHANGELOG.md").readText() } - + publishMods { file = compressJar.get().outputJar additionalFiles.from(sourcesJar.get().archiveFile) if (releaseChannel.proguard) additionalFiles.from(compressJar.get().mappingsFile) - + type = releaseChannel.releaseType ?: ALPHA displayName = Zume.version version = Zume.version changelog = getChangelog() - + modLoaders.addAll("fabric", "forge", "neoforge") dryRun = !isRelease - + github { accessToken = providers.environmentVariable("GITHUB_TOKEN") repository = "Nolij/Zume" commitish = branchName tagName = releaseTagPrefix + Zume.version } - + if (dryRun.get() || releaseChannel.releaseType != null) { modrinth { accessToken = providers.environmentVariable("MODRINTH_TOKEN") @@ -527,9 +519,9 @@ afterEvaluate { start = "1.7.10" end = "1.12.2" } - + minecraftVersions.add("Beta 1.7.3") - + val snapshots: Set if (cfAccessToken.orNull != null) { val cfAPI = CurseforgeApi(cfAccessToken.get(), apiEndpoint.get()) @@ -538,7 +530,7 @@ afterEvaluate { "${it}-Snapshot" }.toHashSet() - snapshots = + snapshots = cfAPI.getGameVersions().map { it.name }.filter { @@ -549,9 +541,9 @@ afterEvaluate { } else { snapshots = HashSet() } - + snapshots.add("1.21-Snapshot") - + minecraftVersions.addAll(snapshots) } @@ -570,7 +562,7 @@ afterEvaluate { } } } - + tasks.withType { dependsOn(compressJar, sourcesJar) } @@ -596,15 +588,15 @@ afterEvaluate { val compareStart = currentTag?.name ?: grgit.log().minBy { it.dateTime }.id val compareEnd = releaseTagPrefix + Zume.version val compareLink = "https://github.com/Nolij/Zume/compare/${compareStart}...${compareEnd}" - + val webhookUrl = providers.environmentVariable("DISCORD_WEBHOOK") val releaseChangeLog = getChangelog() val file = publishMods.file.asFile.get() - + var content = "# [Zume Test Build ${Zume.version}]" + "() has been released!\n" + "Changes since last build: <${compareLink}>" - + if (buildChangeLog.isNotBlank()) content += " ```md\n${buildChangeLog}\n```" content += "\nChanges since last release: ```md\n${releaseChangeLog}\n```" @@ -618,20 +610,14 @@ afterEvaluate { val bodyBuilder = MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("payload_json", http.json.encodeToString(webhook)) - .addFormDataPart( - "files[0]", - file.name, - file.asRequestBody("application/java-archive".toMediaTypeOrNull()) - ) - + .addFormDataPart("files[0]", file.name, file.asRequestBody("application/java-archive".toMediaTypeOrNull())) + var fileIndex = 1 for (additionalFile in publishMods.additionalFiles) { bodyBuilder.addFormDataPart( - "files[${fileIndex++}]", - additionalFile.name, - additionalFile.asRequestBody( - Files.probeContentType(additionalFile.toPath()).toMediaTypeOrNull() - ) + "files[${fileIndex++}]", + additionalFile.name, + additionalFile.asRequestBody(Files.probeContentType(additionalFile.toPath()).toMediaTypeOrNull()) ) } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 87c3e937..675a30fe 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -33,7 +33,7 @@ dependencies { implementation("net.fabricmc:mapping-io:${"mapping_io_version"()}") implementation("org.apache.ant:ant:${"shadow_ant_version"()}") implementation("com.guardsquare:proguard-base:${"proguard_version"()}") - + plugin(id = "com.github.johnrengelman.shadow", version = "shadow_version"()) plugin(id = "xyz.wagyourtail.unimined", version = "unimined_version"()) plugin(id = "com.github.gmazzo.buildconfig", version = "buildconfig_version"()) diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index 0cdeba4d..ccc33ff1 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -7,8 +7,11 @@ import net.fabricmc.mappingio.format.MappingFormat import net.fabricmc.mappingio.tree.MappingTree.ClassMapping import net.fabricmc.mappingio.tree.MemoryMappingTree import org.gradle.api.DefaultTask -import org.gradle.api.tasks.* +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputFile import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputFile +import org.gradle.api.tasks.TaskAction import org.gradle.api.tasks.options.Option import org.gradle.kotlin.dsl.support.uppercaseFirstChar import org.objectweb.asm.ClassReader diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt index eb08d01c..f96b4c0e 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/MixinConfigMergingTransformer.kt @@ -4,21 +4,19 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext import groovy.json.JsonOutput import groovy.json.JsonSlurper -import org.apache.tools.zip.ZipEntry -import org.apache.tools.zip.ZipOutputStream import org.gradle.api.file.FileTreeElement import org.gradle.api.tasks.Input +import org.apache.tools.zip.ZipOutputStream +import org.apache.tools.zip.ZipEntry class MixinConfigMergingTransformer : Transformer { - + private val JSON = JsonSlurper() @Input lateinit var modId: String - @Input lateinit var packageName: String - @Input lateinit var mixinPlugin: String @@ -58,7 +56,7 @@ class MixinConfigMergingTransformer : Transformer { override fun modifyOutputStream(os: ZipOutputStream?, preserveFileTimestamps: Boolean) { val mixinConfigEntry = ZipEntry("${modId}.mixins.json") os!!.putNextEntry(mixinConfigEntry) - + val mixinConfigJson = mutableMapOf( "required" to true, "minVersion" to "0.8", @@ -70,8 +68,8 @@ class MixinConfigMergingTransformer : Transformer { "defaultRequire" to 1, ) ) - - if (refMaps.isNotEmpty()) { + + if(refMaps.isNotEmpty()) { val refmapName = "${modId}-refmap.json" mixinConfigJson["refmap"] = refmapName os.putNextEntry(ZipEntry(refmapName)) diff --git a/gradle.properties b/gradle.properties index 93a4b596..340e55a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -102,7 +102,7 @@ embeddium_neoforge_version = 0.3.20-git-7cfe318+mc1.20.6 # https://central.sonatype.com/artifact/com.pkware.jabel/jabel-javac-plugin jabel_version = 1.0.1-1 # https://github.com/Nolij/ZSON/releases/ -zson_version = 0.2.3 +zson_version = 0.2.1 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core log4j_version = 3.0.0-beta2 # https://central.sonatype.com/artifact/org.slf4j/slf4j-api diff --git a/integration/embeddium/build.gradle.kts b/integration/embeddium/build.gradle.kts index 1aa902d5..31bae868 100644 --- a/integration/embeddium/build.gradle.kts +++ b/integration/embeddium/build.gradle.kts @@ -6,9 +6,9 @@ operator fun String.invoke(): String = rootProject.properties[this] as? String ? unimined.minecraft { combineWith(project(":api").sourceSets.main.get()) - + version("modern_minecraft_version"()) - + runs.off = true fabric { @@ -18,7 +18,7 @@ unimined.minecraft { mappings { mojmap() } - + defaultRemapJar = false } diff --git a/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java b/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java index e2feddd2..3f9fbf5f 100644 --- a/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java +++ b/integration/embeddium/src/main/java/dev/nolij/zume/integration/implementation/embeddium/ZumeEmbeddiumConfigScreen.java @@ -1,7 +1,11 @@ package dev.nolij.zume.integration.implementation.embeddium; import com.google.common.collect.ImmutableList; -import me.jellysquid.mods.sodium.client.gui.options.*; +import me.jellysquid.mods.sodium.client.gui.options.Option; +import me.jellysquid.mods.sodium.client.gui.options.OptionFlag; +import me.jellysquid.mods.sodium.client.gui.options.OptionGroup; +import me.jellysquid.mods.sodium.client.gui.options.OptionImpl; +import me.jellysquid.mods.sodium.client.gui.options.OptionPage; import me.jellysquid.mods.sodium.client.gui.options.control.Control; import me.jellysquid.mods.sodium.client.gui.options.control.ControlValueFormatter; import me.jellysquid.mods.sodium.client.gui.options.control.SliderControl; diff --git a/legacy/build.gradle.kts b/legacy/build.gradle.kts index 0062fdb8..db622815 100644 --- a/legacy/build.gradle.kts +++ b/legacy/build.gradle.kts @@ -23,10 +23,5 @@ tasks.withType { } dependencies { - "modImplementation"( - fabricApi.legacyFabricModule( - "legacy-fabric-keybindings-api-v1-common", - "legacy_fabric_api_version"() - ) - ) + "modImplementation"(fabricApi.legacyFabricModule("legacy-fabric-keybindings-api-v1-common", "legacy_fabric_api_version"())) } \ No newline at end of file diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java b/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java index 382b7af0..6aa1edc4 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.legacy; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.mixin.legacy.GameRendererAccessor; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; @@ -52,15 +52,14 @@ public boolean isZoomOutPressed() { //noinspection JavaReflectionMemberAccess SmoothUtil.class.getMethod("method_10852"); useWorkaround = false; - } catch (NoSuchMethodException ignored) { - } + } catch (NoSuchMethodException ignored) { } USE_CINEMATIC_CAMERA_WORKAROUND = useWorkaround; - } + } @Override public void onZoomActivate() { - if (USE_CINEMATIC_CAMERA_WORKAROUND && + if (USE_CINEMATIC_CAMERA_WORKAROUND && ZumeConfigAPI.isCinematicZoomEnabled() && !MinecraftClient.getInstance().options.smoothCameraEnabled) { final GameRendererAccessor gameRenderer = (GameRendererAccessor) MinecraftClient.getInstance().gameRenderer; gameRenderer.setCursorXSmoother(new SmoothUtil()); diff --git a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java index 729bddbd..462f6d8f 100644 --- a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java @@ -10,22 +10,16 @@ public interface GameRendererAccessor { @Accessor("cursorXSmoother") void setCursorXSmoother(SmoothUtil value); - @Accessor("cursorYSmoother") void setCursorYSmoother(SmoothUtil value); - @Accessor("cursorDeltaX") void setCursorDeltaX(float value); - @Accessor("cursorDeltaY") void setCursorDeltaY(float value); - @Accessor("smoothedCursorDeltaX") void setSmoothedCursorDeltaX(float value); - @Accessor("smoothedCursorDeltaY") void setSmoothedCursorDeltaY(float value); - @Accessor("lastTickDelta") void setLastTickDelta(float value); diff --git a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java index 79994031..fc781a56 100644 --- a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java @@ -51,7 +51,7 @@ public class GameRendererMixin { @ModifyVariable(method = "transformCamera", at = @At(value = "STORE", ordinal = 0), ordinal = 3) public double zume$transformCamera$thirdPersonDistance(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java index 188b2405..99caae36 100644 --- a/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java @@ -15,12 +15,10 @@ @Mixin(KeyBinding.class) public class KeyBindingMixin { - @SuppressWarnings({ "MissingUnique", "unused", "MismatchedQueryAndUpdateOfCollection" }) + @SuppressWarnings({"MissingUnique", "unused", "MismatchedQueryAndUpdateOfCollection"}) private static Map field_15867; // vintage intermediary - @Shadow - @Final - private static Set categories; + @Shadow @Final private static Set categories; @Inject(method = "", at = @At("TAIL")) private static void static$TAIL(CallbackInfo ci) { diff --git a/legacy/src/main/resources/zume-legacy.mixins.json b/legacy/src/main/resources/zume-legacy.mixins.json index 1ca03fe1..37b5497c 100644 --- a/legacy/src/main/resources/zume-legacy.mixins.json +++ b/legacy/src/main/resources/zume-legacy.mixins.json @@ -4,11 +4,11 @@ "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", "client": [ + "legacy.MinecraftClientMixin", "legacy.GameOptionsMixin", "legacy.GameRendererAccessor", "legacy.GameRendererMixin", - "legacy.KeyBindingMixin", - "legacy.MinecraftClientMixin" + "legacy.KeyBindingMixin" ], "injectors": { "defaultRequire": 1 diff --git a/lexforge/build.gradle.kts b/lexforge/build.gradle.kts index 2bd02159..632ec406 100644 --- a/lexforge/build.gradle.kts +++ b/lexforge/build.gradle.kts @@ -8,7 +8,7 @@ val modRuntimeOnly: Configuration by configurations.creating { unimined.minecraft { combineWith(project(":integration:embeddium").sourceSets.main.get()) - + version("lexforge_minecraft_version"()) minecraftForge { @@ -28,14 +28,12 @@ unimined.minecraft { } } } - + runs.config("client") { - jvmArgs.addAll( - listOf( - "-Dmixin.env.remapRefMap=true", - "-Dmixin.env.refMapRemappingFile=${(mcPatcher as ForgeLikeMinecraftTransformer).srgToMCPAsSRG}" - ) - ) + jvmArgs.addAll(listOf( + "-Dmixin.env.remapRefMap=true", + "-Dmixin.env.refMapRemappingFile=${(mcPatcher as ForgeLikeMinecraftTransformer).srgToMCPAsSRG}" + )) } } @@ -45,7 +43,7 @@ repositories { dependencies { compileOnly(project(":stubs")) - + // mixins fail to apply due to Unimined not liking Embeddium's empty mixin list; test in prod // modRuntimeOnly("org.embeddedt:embeddium-1.20.1:${"embeddium_lexforge_version"()}") } \ No newline at end of file diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java b/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java index 65f8410c..cbbc738f 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java +++ b/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.lexforge; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.integration.implementation.embeddium.ZumeEmbeddiumConfigScreen; import net.minecraft.client.Minecraft; @@ -94,13 +94,13 @@ private void calculateFOV(ViewportEvent.ComputeFov event) { ); private void onMouseScroll(InputEvent.MouseScrollingEvent event) { - final int scrollAmount; - try { - scrollAmount = (int) (double) GET_SCROLL_DELTA.invokeExact(event); - } catch (Throwable e) { - throw new AssertionError(e); - } - if (ZumeAPI.mouseScrollHook(scrollAmount)) { + final int scrollAmount; + try { + scrollAmount = (int) (double) GET_SCROLL_DELTA.invokeExact(event); + } catch (Throwable e) { + throw new AssertionError(e); + } + if (ZumeAPI.mouseScrollHook(scrollAmount)) { event.setCanceled(true); } } diff --git a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java index 3fb6a1b6..899cb960 100644 --- a/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java index 7bd1e053..d233ac0d 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java +++ b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16.java @@ -1,10 +1,10 @@ package dev.nolij.zume.lexforge16; import cpw.mods.modlauncher.api.INameMappingService; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.Options; diff --git a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java index 3dd348e9..15a1417e 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java index 366ae5f8..0b4a8dbc 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java +++ b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18.java @@ -1,9 +1,9 @@ package dev.nolij.zume.lexforge18; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientRegistry; diff --git a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java index 60868e95..8ca0e075 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$setup$getMaxZoom(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/modern/build.gradle.kts b/modern/build.gradle.kts index b3c2b3c1..53cc8fd8 100644 --- a/modern/build.gradle.kts +++ b/modern/build.gradle.kts @@ -8,7 +8,7 @@ val modRuntimeOnly: Configuration by configurations.creating { unimined.minecraft { combineWith(project(":integration:embeddium").sourceSets.main.get()) - + version("modern_minecraft_version"()) fabric { @@ -20,7 +20,7 @@ unimined.minecraft { mojmap() devFallbackNamespace("intermediary") } - + mods { remap(modRuntimeOnly) } @@ -40,9 +40,9 @@ repositories { dependencies { compileOnly(project(":stubs")) - + "modImplementation"(fabricApi.fabricModule("fabric-key-binding-api-v1", "modern_fabric_api_version"())) - + "modImplementation"("com.terraformersmc:modmenu:7.+") modRuntimeOnly("org.embeddedt:embeddium-fabric-1.20.1:${"embeddium_fabric_version"()}") diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java index 37ed9d95..c7aacd9d 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java @@ -11,7 +11,7 @@ public abstract class CameraMixin { @ModifyArg(method = "setup", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Camera;getMaxZoom(D)D")) public double zume$update$clipToSpace(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java index 26f242c9..25372c76 100644 --- a/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseHandlerMixin.java @@ -15,7 +15,7 @@ public abstract class MouseHandlerMixin { @Dynamic @ModifyExpressionValue(method = { - "turnPlayer", + "turnPlayer", "method_1606(D)V" // 20.5+ compat }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { @@ -26,7 +26,7 @@ public abstract class MouseHandlerMixin { @Dynamic @Group(name = "zume$getMouseSensitivity", min = 1, max = 1) @ModifyExpressionValue(method = { - "turnPlayer", + "turnPlayer", "method_1606(D)V" // 20.5+ compat }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;", ordinal = 0), require = 0) public T zume$updateMouse$getMouseSensitivity$getValue(T original) { diff --git a/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java b/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java index 0553a320..d6a79f74 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java +++ b/modern/src/main/java/dev/nolij/zume/modern/ModernZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.modern; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.integration.implementation.embeddium.ZumeEmbeddiumConfigScreen; import net.fabricmc.api.ClientModInitializer; diff --git a/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java b/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java index c27db8a0..baa69a6a 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java +++ b/modern/src/main/java/dev/nolij/zume/modern/integration/modmenu/ZumeModMenuIntegration.java @@ -28,14 +28,14 @@ public String getModId() { @Override public Function getConfigScreenFactory() { return (parent) -> { - try { - //noinspection DataFlowIssue - return new ModernZumeConfigScreen((Component) LITERALTEXT_INIT.invokeExact(""), parent); - } catch (Throwable e) { + try { + //noinspection DataFlowIssue + return new ModernZumeConfigScreen((Component) LITERALTEXT_INIT.invokeExact(""), parent); + } catch (Throwable e) { ZumeAPI.getLogger().error("Error opening config screen: ", e); return null; - } - }; + } + }; } @Override diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index e93d6602..81d51f93 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -6,7 +6,7 @@ val modRuntimeOnly: Configuration by configurations.creating { unimined.minecraft { combineWith(project(":integration:embeddium").sourceSets.main.get()) - + version("neoforge_minecraft_version"()) neoForged { @@ -33,6 +33,6 @@ repositories { dependencies { compileOnly(project(":stubs")) - + modRuntimeOnly("org.embeddedt:embeddium-1.20.6:${"embeddium_neoforge_version"()}") } \ No newline at end of file diff --git a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java index 66de67cb..34e140e6 100644 --- a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.neoforge; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import dev.nolij.zume.integration.implementation.embeddium.ZumeEmbeddiumConfigScreen; import net.minecraft.client.Minecraft; @@ -16,7 +16,11 @@ import net.neoforged.fml.common.Mod; import net.neoforged.fml.loading.FMLEnvironment; import net.neoforged.fml.loading.FMLPaths; -import net.neoforged.neoforge.client.event.*; +import net.neoforged.neoforge.client.event.CalculateDetachedCameraDistanceEvent; +import net.neoforged.neoforge.client.event.CalculatePlayerTurnEvent; +import net.neoforged.neoforge.client.event.InputEvent; +import net.neoforged.neoforge.client.event.RegisterKeyMappingsEvent; +import net.neoforged.neoforge.client.event.ViewportEvent; import net.neoforged.neoforge.common.NeoForge; import org.jetbrains.annotations.NotNull; @@ -50,7 +54,6 @@ public class NeoZume implements IZumeImplementation { private static final Class TICK_EVENT_PHASE = METHOD_HANDLE_HELPER.getClassOrNull( "net.neoforged.neoforge.event.TickEvent$Phase"); private static final Enum TICK_EVENT_PHASE_START; - static { if (TICK_EVENT_PHASE == null) { TICK_EVENT_PHASE_START = null; @@ -62,7 +65,6 @@ public class NeoZume implements IZumeImplementation { } } } - private static final MethodHandle RENDER_TICK_EVENT_PHASE_GETTER = METHOD_HANDLE_HELPER.getGetterOrNull( RENDER_TICK_EVENT, "phase", TICK_EVENT_PHASE, MethodType.methodType(Enum.class, Object.class)); private static final Class RENDER_FRAME_EVENT = METHOD_HANDLE_HELPER.getClassOrNull( @@ -86,13 +88,13 @@ public NeoZume(IEventBus modEventBus, ModContainer modContainer) { .newInstance(); } else //noinspection ConstantValue,UnreachableCode if (CONFIG_SCREEN_EXT_RECORD != null) { - return CONFIG_SCREEN_EXT_RECORD - .getDeclaredConstructor(BiFunction.class) - .newInstance((BiFunction) (minecraft, parent) -> - new NeoZumeConfigScreen(parent)); - } else { - return null; - } + return CONFIG_SCREEN_EXT_RECORD + .getDeclaredConstructor(BiFunction.class) + .newInstance((BiFunction) (minecraft, parent) -> + new NeoZumeConfigScreen(parent)); + } else { + return null; + } } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { throw new RuntimeException(e); @@ -112,9 +114,9 @@ public NeoZume(IEventBus modEventBus, ModContainer modContainer) { //noinspection unchecked NeoForge.EVENT_BUS.addListener((Class) RENDER_FRAME_EVENT, this::render); } else if ( - RENDER_TICK_EVENT != null && - RENDER_TICK_EVENT_PHASE_GETTER != null && - TICK_EVENT_PHASE_START != null) { + RENDER_TICK_EVENT != null && + RENDER_TICK_EVENT_PHASE_GETTER != null && + TICK_EVENT_PHASE_START != null) { //noinspection unchecked NeoForge.EVENT_BUS.addListener((Class) RENDER_TICK_EVENT, this::renderLegacy); } else { @@ -190,7 +192,7 @@ private void onMouseScroll(InputEvent.MouseScrollingEvent event) { } private void calculateDetachedCameraDistance(CalculateDetachedCameraDistanceEvent event) { - event.setDistance(ZumeAPI.thirdPersonCameraHook(event.getDistance())); + event.setDistance(ZumeAPI.thirdPersonCameraHook(event.getDistance())); } } diff --git a/primitive/build.gradle.kts b/primitive/build.gradle.kts index df67b05c..82808627 100644 --- a/primitive/build.gradle.kts +++ b/primitive/build.gradle.kts @@ -6,7 +6,7 @@ unimined.minecraft { side("client") version("primitive_minecraft_version"()) - + runs.config("client") { javaVersion = JavaVersion.VERSION_17 } @@ -34,12 +34,7 @@ repositories { } dependencies { - "modImplementation"( - fabricApi.stationModule( - moduleName = "station-keybindings-v0", - version = "station_api_version"() - ) - ) { + "modImplementation"(fabricApi.stationModule(moduleName = "station-keybindings-v0", version = "station_api_version"())) { exclude(module = "fabric-loader") exclude(group = "org.ow2.asm") } @@ -48,9 +43,9 @@ dependencies { exclude(module = "fabric-loader") exclude(group = "org.ow2.asm") } - + implementation("io.github.llamalad7:mixinextras-fabric:${"mixinextras_version"()}") - implementation("org.slf4j:slf4j-api:${"slf4j_version"()}") - implementation("org.apache.logging.log4j:log4j-slf4j18-impl:${"log4j_slf4j_version"()}") + implementation("org.slf4j:slf4j-api:${"slf4j_version"()}") + implementation("org.apache.logging.log4j:log4j-slf4j18-impl:${"log4j_slf4j_version"()}") } \ No newline at end of file diff --git a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java index d855fc67..caf9094a 100644 --- a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java @@ -10,7 +10,6 @@ public interface GameRendererAccessor { @Accessor("field_2353") void setCinematicYawSmoother(SmoothUtil value); - @Accessor("field_2354") void setCinematicPitchSmoother(SmoothUtil value); diff --git a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java index 01062cef..6e8bb8e3 100644 --- a/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java @@ -37,12 +37,12 @@ public abstract class GameRendererMixin { @ModifyExpressionValue(method = "method_1851", at = @At(value = "FIELD", target = "Lnet/minecraft/class_555;field_2359:F")) public float zume$transformCamera$thirdPersonDistance(float original) { - return (float) ZumeAPI.thirdPersonCameraHook(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } @ModifyExpressionValue(method = "method_1851", at = @At(value = "FIELD", target = "Lnet/minecraft/class_555;field_2360:F")) public float zume$transformCamera$lastThirdPersonDistance(float original) { - return (float) ZumeAPI.thirdPersonCameraHook(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java index 9edf8b5c..4ed5813a 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.primitive; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.mixin.primitive.GameRendererAccessor; import dev.nolij.zume.mixin.primitive.MinecraftAccessor; import net.fabricmc.api.ClientModInitializer; diff --git a/settings.gradle.kts b/settings.gradle.kts index 3ce27f47..6cec65cd 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,11 +1,11 @@ pluginManagement { - repositories { - gradlePluginPortal() - } + repositories { + gradlePluginPortal() + } } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version ("0.7.0") + id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") } rootProject.name = "zume" diff --git a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java index f779b5df..014e8171 100644 --- a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java @@ -1,9 +1,9 @@ package dev.nolij.zume; import dev.nolij.zume.api.platform.v1.ZumeAPI; -import dev.nolij.zume.legacy.LegacyZume; import dev.nolij.zume.modern.ModernZume; import dev.nolij.zume.primitive.PrimitiveZume; +import dev.nolij.zume.legacy.LegacyZume; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; import net.fabricmc.loader.impl.gui.FabricGuiEntry; @@ -12,10 +12,10 @@ public class FabricZumeBootstrapper implements ClientModInitializer, PreLaunchEntrypoint { private static final String MISSING_DEPENDENCY_MESSAGE = """ - Failed to detect which variant of Zume to load! Ensure all dependencies are installed: - Fabric (14.4+): Fabric API (fabric-key-binding-api-v1) - Legacy Fabric (7.10-12.2): Legacy Fabric API (legacy-fabric-keybinding-api-v1-common) - Babric (b7.3): Station API (station-keybindings-v0)"""; + Failed to detect which variant of Zume to load! Ensure all dependencies are installed: + Fabric (14.4+): Fabric API (fabric-key-binding-api-v1) + Legacy Fabric (7.10-12.2): Legacy Fabric API (legacy-fabric-keybinding-api-v1-common) + Babric (b7.3): Station API (station-keybindings-v0)"""; @Override public void onPreLaunch() { diff --git a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java index 3b74755c..21ffb958 100644 --- a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java @@ -1,8 +1,8 @@ package dev.nolij.zume; import dev.nolij.zume.lexforge.LexZume; -import dev.nolij.zume.lexforge16.LexZume16; import dev.nolij.zume.lexforge18.LexZume18; +import dev.nolij.zume.lexforge16.LexZume16; import dev.nolij.zume.vintage.VintageZume; import net.minecraftforge.fml.common.Mod; @@ -20,11 +20,11 @@ public class ForgeZumeBootstrapper { public ForgeZumeBootstrapper() { if (ZumeMixinPlugin.ZUME_VARIANT == null) throw new AssertionError(""" - Mixins did not load! Zume requires Mixins in order to work properly. - Please install one of the following mixin loaders: - 14.4 - 16.0: MixinBootstrap - 8.9 - 12.2: MixinBooter >= 5.0 - 7.10 - 12.2: UniMixins >= 0.1.15"""); + Mixins did not load! Zume requires Mixins in order to work properly. + Please install one of the following mixin loaders: + 14.4 - 16.0: MixinBootstrap + 8.9 - 12.2: MixinBooter >= 5.0 + 7.10 - 12.2: UniMixins >= 0.1.15"""); switch (ZumeMixinPlugin.ZUME_VARIANT) { case ZumeVariant.LEXFORGE -> new LexZume(); diff --git a/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java b/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java index d8475479..3268b0dc 100644 --- a/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java +++ b/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java @@ -39,8 +39,7 @@ else if (CLASS_LOADER.getResource("net/minecraftforge/oredict/OreDictionary.clas "getVersion", MethodType.methodType(String.class) ).invokeExact(); - } catch (Throwable ignored) { - } + } catch (Throwable ignored) { } if (forgeVersion != null) { final int major = Integer.parseInt(forgeVersion.substring(0, forgeVersion.indexOf('.'))); @@ -64,8 +63,7 @@ else if (major > 25) } @Override - public void onLoad(String mixinPackage) { - } + public void onLoad(String mixinPackage) {} @Override public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { @@ -81,8 +79,7 @@ public String getRefMapperConfig() { } @Override - public void acceptTargets(Set myTargets, Set otherTargets) { - } + public void acceptTargets(Set myTargets, Set otherTargets) {} @Override public List getMixins() { @@ -90,11 +87,9 @@ public List getMixins() { } @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - } + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} @Override - public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { - } + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} } diff --git a/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java b/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java index 82b12200..f6a844b6 100644 --- a/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java +++ b/stubs/src/main/java/net/minecraftforge/fml/common/Mod.java @@ -6,7 +6,7 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.TYPE }) +@Target({ElementType.TYPE}) public @interface Mod { // Pre/Modern Forge @@ -14,13 +14,9 @@ // Vintage Forge String modid() default ""; - String name() default ""; - String version() default ""; - String acceptedMinecraftVersions() default ""; - String guiFactory() default ""; } diff --git a/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java index a46e80d9..c1da7466 100644 --- a/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java +++ b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java @@ -10,13 +10,13 @@ @Mixin(EntityRenderer.class) public abstract class EntityRendererMixin { - @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, + @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { return ZumeAPI.cinematicCameraEnabledHook(original); } - @ModifyExpressionValue(method = { "updateCameraAndRender", "updateRenderer" }, + @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;mouseSensitivity:F")) public float zume$updateMouse$mouseSensitivity(float original) { return (float) ZumeAPI.mouseSensitivityHook(original); @@ -24,7 +24,7 @@ public abstract class EntityRendererMixin { @ModifyVariable(method = "orientCamera", at = @At(value = "STORE", ordinal = 0), ordinal = 3) public double zume$orientCamera$thirdPersonDistance(double original) { - return ZumeAPI.thirdPersonCameraHook(original); + return ZumeAPI.thirdPersonCameraHook(original); } - + } diff --git a/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java b/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java index 9d704930..92e6d5d8 100644 --- a/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java +++ b/vintage/src/main/java/dev/nolij/zume/vintage/VintageZume.java @@ -1,9 +1,9 @@ package dev.nolij.zume.vintage; -import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.platform.v1.CameraPerspective; import dev.nolij.zume.api.platform.v1.IZumeImplementation; import dev.nolij.zume.api.platform.v1.ZumeAPI; +import dev.nolij.zume.api.config.v1.ZumeConfigAPI; import dev.nolij.zume.api.util.v1.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraft.launchwrapper.Launch; @@ -28,7 +28,7 @@ @Mod( modid = MOD_ID, name = MOD_NAME, - version = MOD_VERSION, + version = MOD_VERSION, acceptedMinecraftVersions = VINTAGE_VERSION_RANGE, guiFactory = "dev.nolij.zume.vintage.VintageConfigProvider") public class VintageZume implements IZumeImplementation { From 766ca7209576dfff3013fd45dee655d2c089c3bd Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 31 May 2024 18:09:54 -0400 Subject: [PATCH 50/51] * import begone (forever) --- .editorconfig | 192 +----------------- .../dev/nolij/zumegradle/JarCompressing.kt | 3 +- 2 files changed, 3 insertions(+), 192 deletions(-) diff --git a/.editorconfig b/.editorconfig index 9078b44c..46eeb6a6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -85,7 +85,7 @@ ij_java_case_statement_on_separate_line = true ij_java_catch_on_new_line = false ij_java_class_annotation_wrap = split_into_lines ij_java_class_brace_style = end_of_line -ij_java_class_count_to_use_import_on_demand = 5 +ij_java_class_count_to_use_import_on_demand = 10000 ij_java_class_names_in_javadoc = 1 ij_java_deconstruction_list_wrap = normal ij_java_do_not_indent_top_level_class_members = false @@ -291,196 +291,6 @@ ij_java_wrap_comments = false ij_java_wrap_first_method_in_call_chain = false ij_java_wrap_long_lines = false -[{*.gant,*.groovy,*.gy}] -ij_smart_tabs = false -ij_groovy_align_group_field_declarations = false -ij_groovy_align_multiline_array_initializer_expression = false -ij_groovy_align_multiline_assignment = false -ij_groovy_align_multiline_binary_operation = false -ij_groovy_align_multiline_chained_methods = false -ij_groovy_align_multiline_extends_list = false -ij_groovy_align_multiline_for = true -ij_groovy_align_multiline_list_or_map = true -ij_groovy_align_multiline_method_parentheses = false -ij_groovy_align_multiline_parameters = true -ij_groovy_align_multiline_parameters_in_calls = false -ij_groovy_align_multiline_resources = true -ij_groovy_align_multiline_ternary_operation = false -ij_groovy_align_multiline_throws_list = false -ij_groovy_align_named_args_in_map = true -ij_groovy_align_throws_keyword = false -ij_groovy_array_initializer_new_line_after_left_brace = false -ij_groovy_array_initializer_right_brace_on_new_line = false -ij_groovy_array_initializer_wrap = off -ij_groovy_assert_statement_wrap = off -ij_groovy_assignment_wrap = off -ij_groovy_binary_operation_wrap = off -ij_groovy_blank_lines_after_class_header = 0 -ij_groovy_blank_lines_after_imports = 1 -ij_groovy_blank_lines_after_package = 1 -ij_groovy_blank_lines_around_class = 1 -ij_groovy_blank_lines_around_field = 0 -ij_groovy_blank_lines_around_field_in_interface = 0 -ij_groovy_blank_lines_around_method = 1 -ij_groovy_blank_lines_around_method_in_interface = 1 -ij_groovy_blank_lines_before_imports = 1 -ij_groovy_blank_lines_before_method_body = 0 -ij_groovy_blank_lines_before_package = 0 -ij_groovy_block_brace_style = end_of_line -ij_groovy_block_comment_add_space = false -ij_groovy_block_comment_at_first_column = true -ij_groovy_call_parameters_new_line_after_left_paren = false -ij_groovy_call_parameters_right_paren_on_new_line = false -ij_groovy_call_parameters_wrap = off -ij_groovy_catch_on_new_line = false -ij_groovy_class_annotation_wrap = split_into_lines -ij_groovy_class_brace_style = end_of_line -ij_groovy_class_count_to_use_import_on_demand = 5 -ij_groovy_do_while_brace_force = never -ij_groovy_else_on_new_line = false -ij_groovy_enable_groovydoc_formatting = true -ij_groovy_enum_constants_wrap = off -ij_groovy_extends_keyword_wrap = off -ij_groovy_extends_list_wrap = off -ij_groovy_field_annotation_wrap = split_into_lines -ij_groovy_finally_on_new_line = false -ij_groovy_for_brace_force = never -ij_groovy_for_statement_new_line_after_left_paren = false -ij_groovy_for_statement_right_paren_on_new_line = false -ij_groovy_for_statement_wrap = off -ij_groovy_ginq_general_clause_wrap_policy = 2 -ij_groovy_ginq_having_wrap_policy = 1 -ij_groovy_ginq_indent_having_clause = true -ij_groovy_ginq_indent_on_clause = true -ij_groovy_ginq_on_wrap_policy = 1 -ij_groovy_ginq_space_after_keyword = true -ij_groovy_if_brace_force = never -ij_groovy_import_annotation_wrap = 2 -ij_groovy_imports_layout = *,|,javax.**,java.**,|,$* -ij_groovy_indent_case_from_switch = true -ij_groovy_indent_label_blocks = true -ij_groovy_insert_inner_class_imports = false -ij_groovy_keep_blank_lines_before_right_brace = 2 -ij_groovy_keep_blank_lines_in_code = 2 -ij_groovy_keep_blank_lines_in_declarations = 2 -ij_groovy_keep_control_statement_in_one_line = true -ij_groovy_keep_first_column_comment = true -ij_groovy_keep_multiple_expressions_in_one_line = false -ij_groovy_keep_simple_blocks_in_one_line = false -ij_groovy_keep_simple_classes_in_one_line = true -ij_groovy_keep_simple_lambdas_in_one_line = true -ij_groovy_keep_simple_methods_in_one_line = true -ij_groovy_label_indent_absolute = false -ij_groovy_label_indent_size = 0 -ij_groovy_lambda_brace_style = end_of_line -ij_groovy_layout_static_imports_separately = true -ij_groovy_line_comment_add_space = false -ij_groovy_line_comment_add_space_on_reformat = false -ij_groovy_line_comment_at_first_column = true -ij_groovy_method_annotation_wrap = split_into_lines -ij_groovy_method_brace_style = end_of_line -ij_groovy_method_call_chain_wrap = off -ij_groovy_method_parameters_new_line_after_left_paren = false -ij_groovy_method_parameters_right_paren_on_new_line = false -ij_groovy_method_parameters_wrap = off -ij_groovy_modifier_list_wrap = false -ij_groovy_names_count_to_use_import_on_demand = 3 -ij_groovy_packages_to_use_import_on_demand = java.awt.*,javax.swing.* -ij_groovy_parameter_annotation_wrap = off -ij_groovy_parentheses_expression_new_line_after_left_paren = false -ij_groovy_parentheses_expression_right_paren_on_new_line = false -ij_groovy_prefer_parameters_wrap = false -ij_groovy_resource_list_new_line_after_left_paren = false -ij_groovy_resource_list_right_paren_on_new_line = false -ij_groovy_resource_list_wrap = off -ij_groovy_space_after_assert_separator = true -ij_groovy_space_after_colon = true -ij_groovy_space_after_comma = true -ij_groovy_space_after_comma_in_type_arguments = true -ij_groovy_space_after_for_semicolon = true -ij_groovy_space_after_quest = true -ij_groovy_space_after_type_cast = true -ij_groovy_space_before_annotation_parameter_list = false -ij_groovy_space_before_array_initializer_left_brace = false -ij_groovy_space_before_assert_separator = false -ij_groovy_space_before_catch_keyword = true -ij_groovy_space_before_catch_left_brace = true -ij_groovy_space_before_catch_parentheses = true -ij_groovy_space_before_class_left_brace = true -ij_groovy_space_before_closure_left_brace = true -ij_groovy_space_before_colon = true -ij_groovy_space_before_comma = false -ij_groovy_space_before_do_left_brace = true -ij_groovy_space_before_else_keyword = true -ij_groovy_space_before_else_left_brace = true -ij_groovy_space_before_finally_keyword = true -ij_groovy_space_before_finally_left_brace = true -ij_groovy_space_before_for_left_brace = true -ij_groovy_space_before_for_parentheses = true -ij_groovy_space_before_for_semicolon = false -ij_groovy_space_before_if_left_brace = true -ij_groovy_space_before_if_parentheses = true -ij_groovy_space_before_method_call_parentheses = false -ij_groovy_space_before_method_left_brace = true -ij_groovy_space_before_method_parentheses = false -ij_groovy_space_before_quest = true -ij_groovy_space_before_record_parentheses = false -ij_groovy_space_before_switch_left_brace = true -ij_groovy_space_before_switch_parentheses = true -ij_groovy_space_before_synchronized_left_brace = true -ij_groovy_space_before_synchronized_parentheses = true -ij_groovy_space_before_try_left_brace = true -ij_groovy_space_before_try_parentheses = true -ij_groovy_space_before_while_keyword = true -ij_groovy_space_before_while_left_brace = true -ij_groovy_space_before_while_parentheses = true -ij_groovy_space_in_named_argument = true -ij_groovy_space_in_named_argument_before_colon = false -ij_groovy_space_within_empty_array_initializer_braces = false -ij_groovy_space_within_empty_method_call_parentheses = false -ij_groovy_spaces_around_additive_operators = true -ij_groovy_spaces_around_assignment_operators = true -ij_groovy_spaces_around_bitwise_operators = true -ij_groovy_spaces_around_equality_operators = true -ij_groovy_spaces_around_lambda_arrow = true -ij_groovy_spaces_around_logical_operators = true -ij_groovy_spaces_around_multiplicative_operators = true -ij_groovy_spaces_around_regex_operators = true -ij_groovy_spaces_around_relational_operators = true -ij_groovy_spaces_around_shift_operators = true -ij_groovy_spaces_within_annotation_parentheses = false -ij_groovy_spaces_within_array_initializer_braces = false -ij_groovy_spaces_within_braces = true -ij_groovy_spaces_within_brackets = false -ij_groovy_spaces_within_cast_parentheses = false -ij_groovy_spaces_within_catch_parentheses = false -ij_groovy_spaces_within_for_parentheses = false -ij_groovy_spaces_within_gstring_injection_braces = false -ij_groovy_spaces_within_if_parentheses = false -ij_groovy_spaces_within_list_or_map = false -ij_groovy_spaces_within_method_call_parentheses = false -ij_groovy_spaces_within_method_parentheses = false -ij_groovy_spaces_within_parentheses = false -ij_groovy_spaces_within_switch_parentheses = false -ij_groovy_spaces_within_synchronized_parentheses = false -ij_groovy_spaces_within_try_parentheses = false -ij_groovy_spaces_within_tuple_expression = false -ij_groovy_spaces_within_while_parentheses = false -ij_groovy_special_else_if_treatment = true -ij_groovy_ternary_operation_wrap = off -ij_groovy_throws_keyword_wrap = off -ij_groovy_throws_list_wrap = off -ij_groovy_use_flying_geese_braces = false -ij_groovy_use_fq_class_names = false -ij_groovy_use_fq_class_names_in_javadoc = true -ij_groovy_use_relative_indents = false -ij_groovy_use_single_class_imports = true -ij_groovy_variable_annotation_wrap = off -ij_groovy_while_brace_force = never -ij_groovy_while_on_new_line = false -ij_groovy_wrap_chain_calls_after_dot = false -ij_groovy_wrap_long_lines = false - [{*.har,*.jsb2,*.jsb3,*.json,*.png.mcmeta,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config,mcmod.info,pack.mcmeta}] ij_smart_tabs = false ij_json_array_wrapping = split_into_lines diff --git a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt index ccc33ff1..2f6c8b09 100644 --- a/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt +++ b/buildSrc/src/main/kotlin/dev/nolij/zumegradle/JarCompressing.kt @@ -22,11 +22,12 @@ import proguard.ConfigurationParser import proguard.ProGuard import xyz.wagyourtail.unimined.api.minecraft.MinecraftConfig import java.io.File -import java.util.* +import java.util.Properties import java.util.jar.JarEntry import java.util.jar.JarFile import java.util.jar.JarOutputStream import java.util.zip.Deflater +import kotlin.collections.HashSet enum class DeflateAlgorithm(val id: Int?) { NONE(null), From d33a4a00a0d36b348758fc8b4563d072fe1f8897 Mon Sep 17 00:00:00 2001 From: Rhys <98863820+rhysdh540@users.noreply.github.com> Date: Fri, 31 May 2024 18:29:12 -0400 Subject: [PATCH 51/51] keep build config even when cleaning --- api/build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 0d24ba63..14ae6b7c 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -22,6 +22,10 @@ dependencies { compileOnly("org.apache.logging.log4j:log4j-core:${"log4j_version"()}") } +tasks.clean { + finalizedBy(tasks.generateBuildConfig) +} + tasks.processResources { from("src/main/resources/assets/zume/lang/") { include("*.lang")