From 60a32c4c203b665a33c8ae9f8400573de225d4b8 Mon Sep 17 00:00:00 2001 From: Nolij Date: Sun, 14 Apr 2024 23:02:04 -0400 Subject: [PATCH 01/15] make this name more consistent with others --- gradle.properties | 2 +- src/main/resources/META-INF/mods.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 3985337a..6ee28f9d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -47,7 +47,7 @@ babric_version = 0.14.24-babric.1 station_api_version = 261e793 # Forge -forge_version_range = [1.14,) +forge_minecraft_range = [1.14,) ## NeoForge neoforge_minecraft_version = 1.20.4 diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index a7b71cbb..495ef8c3 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -18,7 +18,7 @@ ${mod_description} modId="minecraft" type="required" mandatory=true -versionRange="${forge_version_range}" +versionRange="${forge_minecraft_range}" ordering="NONE" side="CLIENT" From 993904c90dbf7b98d204a6088e81a83fe76253bd Mon Sep 17 00:00:00 2001 From: Nolij Date: Sun, 14 Apr 2024 23:03:23 -0400 Subject: [PATCH 02/15] this is cleaner --- build.gradle.kts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 842d96ef..42d93221 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -615,14 +615,13 @@ afterEvaluate { val releaseChangeLog = getChangelog() val file = getFileForPublish().asFile - var content = "# [Zume Test Build ${Zume.version}]() has been released!\n" + var content = "# [Zume Test Build ${Zume.version}]" + + "() has been released!\n" + + "Changes since last build: <${compareLink}>" - content += - if (buildChangeLog.trim().isEmpty()) - "Changes since last build: <${compareLink}>" - else - "Changes since last build: <${compareLink}> ```md\n${buildChangeLog}\n```\n" - content += "Changes since last release: ```md\n${releaseChangeLog}\n```" + if (buildChangeLog.trim().isEmpty()) + content += " ```md\n${buildChangeLog}\n```" + content += "\nChanges since last release: ```md\n${releaseChangeLog}\n```" val webhook = DiscordAPI.Webhook( content, From 5e7d2c8a20eb7191c0b7a68bcb0bc7278ad2b9c0 Mon Sep 17 00:00:00 2001 From: Nolij Date: Mon, 15 Apr 2024 18:08:03 -0400 Subject: [PATCH 03/15] inverse + simplify condition for appending build change log --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 42d93221..bd8656e6 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -619,7 +619,7 @@ afterEvaluate { "() has been released!\n" + "Changes since last build: <${compareLink}>" - if (buildChangeLog.trim().isEmpty()) + if (buildChangeLog.isNotBlank()) content += " ```md\n${buildChangeLog}\n```" content += "\nChanges since last release: ```md\n${releaseChangeLog}\n```" From 419a50379eee0a2fe44107c6e31fad73bc649b92 Mon Sep 17 00:00:00 2001 From: Nolij Date: Fri, 19 Apr 2024 21:42:59 -0400 Subject: [PATCH 04/15] large refactor --- {common => api}/build.gradle.kts | 5 +- .../nolij/zume/api/config/v0/ZumeConfig.java | 20 +++ .../zume/api/config/v0/ZumeConfigAPI.java | 106 +++++++++++++ .../api/platform/v0/CameraPerspective.java | 9 ++ .../api/platform/v0}/IZumeImplementation.java | 2 +- .../nolij/zume/api/platform/v0/ZumeAPI.java | 143 ++++++++++++++++++ .../nolij/zume/api/util/v0}/EasingHelper.java | 2 +- .../zume/api/util/v0}/MethodHandleHelper.java | 2 +- .../nolij/zume/impl}/CameraPerspective.java | 2 +- .../dev/nolij/zume/impl}/EasedDouble.java | 4 +- .../dev/nolij/zume/impl}/HostPlatform.java | 2 +- .../nolij/zume/impl/IZumeImplementation.java | 13 ++ .../main/java/dev/nolij/zume/impl}/Zume.java | 130 ++-------------- .../dev/nolij/zume/impl/ZumeMixinPlugin.java | 96 ++++++++++++ .../dev/nolij/zume/impl}/ZumeVariant.java | 2 +- .../nolij/zume/impl/config}/FileWatcher.java | 4 +- .../nolij/zume/impl/config}/IFileWatcher.java | 2 +- .../zume/impl/config/ZumeConfigImpl.java | 49 ++---- .../resources/assets/zume/lang/en_CA.lang | 0 .../resources/assets/zume/lang/en_US.lang | 0 .../resources/assets/zume/lang/en_ca.json | 0 .../resources/assets/zume/lang/en_us.json | 0 {common => api}/src/main/resources/icon.png | Bin {common => api}/src/main/resources/icon.xcf | Bin .../src/main/resources/icon_large.png | Bin .../zume/archaic/ArchaicConfigProvider.java | 9 +- .../dev/nolij/zume/archaic/ArchaicZume.java | 28 ++-- .../archaic/mixin/EntityRendererMixin.java | 16 +- .../main/resources/zume-archaic.mixins.json | 2 +- build.gradle.kts | 23 +-- .../nolij/zume/common/ZumeMixinPlugin.java | 48 ------ gradle.properties | 6 +- .../dev/nolij/zume/legacy/LegacyZume.java | 13 +- .../zume/legacy/mixin/GameOptionsMixin.java | 4 +- .../zume/legacy/mixin/GameRendererMixin.java | 14 +- .../zume/legacy/mixin/KeyBindingMixin.java | 4 +- .../legacy/mixin/MinecraftClientMixin.java | 4 +- .../main/resources/zume-legacy.mixins.json | 2 +- lexforge/build.gradle.kts | 2 +- .../java/dev/nolij/zume/lexforge/LexZume.java | 29 ++-- .../zume/lexforge/LexZumeConfigScreen.java | 4 +- .../zume/lexforge/mixin/CameraMixin.java | 4 +- .../lexforge/mixin/MouseHandlerMixin.java | 6 +- .../main/resources/zume-lexforge.mixins.json | 2 +- lexforge16/build.gradle.kts | 2 +- .../dev/nolij/zume/lexforge16/LexZume16.java | 27 ++-- .../lexforge16/LexZume16ConfigScreen.java | 4 +- .../zume/lexforge16/mixin/CameraMixin.java | 4 +- .../lexforge16/mixin/MouseHandlerMixin.java | 6 +- .../resources/zume-lexforge16.mixins.json | 2 +- lexforge18/build.gradle.kts | 2 +- .../dev/nolij/zume/lexforge18/LexZume18.java | 27 ++-- .../lexforge18/LexZume18ConfigScreen.java | 4 +- .../zume/lexforge18/mixin/CameraMixin.java | 4 +- .../lexforge18/mixin/MouseHandlerMixin.java | 6 +- .../resources/zume-lexforge18.mixins.json | 2 +- .../dev/nolij/zume/modern/ModernZume.java | 15 +- .../integration/ZumeModMenuIntegration.java | 12 +- .../nolij/zume/modern/mixin/CameraMixin.java | 4 +- .../zume/modern/mixin/GameRendererMixin.java | 8 +- .../nolij/zume/modern/mixin/MouseMixin.java | 12 +- .../main/resources/zume-modern.mixins.json | 2 +- neoforge/build.gradle.kts | 2 +- .../java/dev/nolij/zume/neoforge/NeoZume.java | 31 ++-- .../zume/neoforge/NeoZumeConfigScreen.java | 4 +- .../nolij/zume/primitive/PrimitiveZume.java | 14 +- .../primitive/event/KeyBindingRegistrar.java | 4 +- .../primitive/mixin/GameRendererMixin.java | 16 +- .../zume/primitive/mixin/MinecraftMixin.java | 4 +- .../main/resources/zume-primitive.mixins.json | 2 +- settings.gradle.kts | 2 +- .../nolij/zume/FabricZumeBootstrapper.java | 34 ++++- .../zume/FabricZumePreLaunchEntrypoint.java | 28 ---- .../dev/nolij/zume/ForgeZumeBootstrapper.java | 21 +-- src/main/resources/fabric.mod.json | 2 +- .../zume/vintage/VintageConfigProvider.java | 9 +- .../dev/nolij/zume/vintage/VintageZume.java | 32 ++-- .../vintage/mixin/EntityRendererMixin.java | 8 +- .../main/resources/zume-vintage.mixins.json | 2 +- 79 files changed, 702 insertions(+), 469 deletions(-) rename {common => api}/build.gradle.kts (91%) create mode 100644 api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfig.java create mode 100644 api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfigAPI.java create mode 100644 api/src/main/java/dev/nolij/zume/api/platform/v0/CameraPerspective.java rename {common/src/main/java/dev/nolij/zume/common => api/src/main/java/dev/nolij/zume/api/platform/v0}/IZumeImplementation.java (84%) create mode 100644 api/src/main/java/dev/nolij/zume/api/platform/v0/ZumeAPI.java rename {common/src/main/java/dev/nolij/zume/common/easing => api/src/main/java/dev/nolij/zume/api/util/v0}/EasingHelper.java (98%) rename {common/src/main/java/dev/nolij/zume/common/util => api/src/main/java/dev/nolij/zume/api/util/v0}/MethodHandleHelper.java (98%) rename {common/src/main/java/dev/nolij/zume/common => api/src/main/java/dev/nolij/zume/impl}/CameraPerspective.java (74%) rename {common/src/main/java/dev/nolij/zume/common/easing => api/src/main/java/dev/nolij/zume/impl}/EasedDouble.java (95%) rename {common/src/main/java/dev/nolij/zume/common => api/src/main/java/dev/nolij/zume/impl}/HostPlatform.java (69%) create mode 100644 api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java rename {common/src/main/java/dev/nolij/zume/common => api/src/main/java/dev/nolij/zume/impl}/Zume.java (57%) create mode 100644 api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java rename {common/src/main/java/dev/nolij/zume/common => api/src/main/java/dev/nolij/zume/impl}/ZumeVariant.java (93%) rename {common/src/main/java/dev/nolij/zume/common/util => api/src/main/java/dev/nolij/zume/impl/config}/FileWatcher.java (97%) rename {common/src/main/java/dev/nolij/zume/common/util => api/src/main/java/dev/nolij/zume/impl/config}/IFileWatcher.java (76%) rename common/src/main/java/dev/nolij/zume/common/config/ZumeConfig.java => api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java (86%) rename {common => api}/src/main/resources/assets/zume/lang/en_CA.lang (100%) rename {common => api}/src/main/resources/assets/zume/lang/en_US.lang (100%) rename {common => api}/src/main/resources/assets/zume/lang/en_ca.json (100%) rename {common => api}/src/main/resources/assets/zume/lang/en_us.json (100%) rename {common => api}/src/main/resources/icon.png (100%) rename {common => api}/src/main/resources/icon.xcf (100%) rename {common => api}/src/main/resources/icon_large.png (100%) delete mode 100644 common/src/main/java/dev/nolij/zume/common/ZumeMixinPlugin.java delete mode 100644 src/main/java/dev/nolij/zume/FabricZumePreLaunchEntrypoint.java diff --git a/common/build.gradle.kts b/api/build.gradle.kts similarity index 91% rename from common/build.gradle.kts rename to api/build.gradle.kts index ba48690c..2e9a61a2 100644 --- a/common/build.gradle.kts +++ b/api/build.gradle.kts @@ -7,12 +7,13 @@ operator fun String.invoke(): String { } buildConfig { - className("Constants") - packageName("dev.nolij.zume.common") + className("ZumeConstants") + packageName("dev.nolij.zume.impl") useJavaOutput() // the below errors shown by IntelliJ can be safely ignored; Jabel works around this + buildConfigField("MOD_ID", "mod_id"()) buildConfigField("MOD_VERSION", Zume.version) buildConfigField("MOD_NAME", "mod_name"()) buildConfigField("ARCHAIC_VERSION_RANGE", "archaic_minecraft_range"()) diff --git a/api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfig.java b/api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfig.java new file mode 100644 index 00000000..5c4a5430 --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfig.java @@ -0,0 +1,20 @@ +package dev.nolij.zume.api.config.v0; + +public class ZumeConfig { + + public boolean isCinematicZoomEnabled; + public double mouseSensitivityFloor; + public short zoomSpeed; + public boolean isZoomScrollingEnabled; + public short zoomSmoothnessMilliseconds; + public double animationEasingExponent; + public double zoomEasingExponent; + public double defaultZoom; + public boolean isFirstPersonToggleModeEnabled; + public boolean isThirdPersonToggleModeEnabled; + public double minimumFOV; + public double maximumThirdPersonZoomBlocks; + public double minimumThirdPersonZoomBlocks; + public boolean isDisabled; + +} diff --git a/api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfigAPI.java b/api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfigAPI.java new file mode 100644 index 00000000..a700a11b --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/api/config/v0/ZumeConfigAPI.java @@ -0,0 +1,106 @@ +package dev.nolij.zume.api.config.v0; + +import dev.nolij.zume.impl.Zume; +import dev.nolij.zume.impl.config.ZumeConfigImpl; + +public final class ZumeConfigAPI { + + public static boolean isCinematicZoomEnabled() { + return Zume.config.enableCinematicZoom; + } + + public static double getMouseSensitivityFloor() { + return Zume.config.mouseSensitivityFloor; + } + + public static short getZoomSpeed() { + return Zume.config.zoomSpeed; + } + + public static boolean isZoomScrollingEnabled() { + return Zume.config.enableZoomScrolling; + } + + public static short getZoomSmoothnessMilliseconds() { + return Zume.config.zoomSmoothnessMs; + } + + public static double getAnimationEasingExponent() { + return Zume.config.animationEasingExponent; + } + + public static double getZoomEasingExponent() { + return Zume.config.zoomEasingExponent; + } + + public static double getDefaultZoom() { + return Zume.config.defaultZoom; + } + + public static boolean isFirstPersonToggleModeEnabled() { + return Zume.config.toggleMode; + } + + public static boolean isThirdPersonToggleModeEnabled() { + return Zume.config.thirdPersonToggleMode; + } + + public static double getMinimumFOV() { + return Zume.config.minFOV; + } + + public static double getMaximumThirdPersonZoomBlocks() { + return Zume.config.maxThirdPersonZoomDistance; + } + + public static double getMinimumThirdPersonZoomBlocks() { + return Zume.config.minThirdPersonZoomDistance; + } + + public static boolean isDisabled() { + return Zume.config.disable; + } + + public static ZumeConfig getSnapshot() { + final ZumeConfig snapshot = new ZumeConfig(); + + snapshot.isCinematicZoomEnabled = isCinematicZoomEnabled(); + snapshot.mouseSensitivityFloor = getMouseSensitivityFloor(); + snapshot.zoomSpeed = getZoomSpeed(); + snapshot.isZoomScrollingEnabled = isZoomScrollingEnabled(); + snapshot.zoomSmoothnessMilliseconds = getZoomSmoothnessMilliseconds(); + snapshot.animationEasingExponent = getAnimationEasingExponent(); + snapshot.zoomEasingExponent = getZoomEasingExponent(); + snapshot.defaultZoom = getDefaultZoom(); + snapshot.isFirstPersonToggleModeEnabled = isFirstPersonToggleModeEnabled(); + snapshot.isThirdPersonToggleModeEnabled = isThirdPersonToggleModeEnabled(); + snapshot.minimumFOV = getMinimumFOV(); + snapshot.maximumThirdPersonZoomBlocks = getMaximumThirdPersonZoomBlocks(); + snapshot.minimumThirdPersonZoomBlocks = getMinimumThirdPersonZoomBlocks(); + snapshot.isDisabled = isDisabled(); + + return snapshot; + } + + public static void replaceConfig(ZumeConfig replacement) throws InterruptedException { + final ZumeConfigImpl config = new ZumeConfigImpl(); + + config.enableCinematicZoom = replacement.isCinematicZoomEnabled; + config.mouseSensitivityFloor = replacement.mouseSensitivityFloor; + config.zoomSpeed = replacement.zoomSpeed; + config.enableZoomScrolling = replacement.isZoomScrollingEnabled; + config.zoomSmoothnessMs = replacement.zoomSmoothnessMilliseconds; + config.animationEasingExponent = replacement.animationEasingExponent; + config.zoomEasingExponent = replacement.zoomEasingExponent; + config.defaultZoom = replacement.defaultZoom; + config.toggleMode = replacement.isFirstPersonToggleModeEnabled; + config.thirdPersonToggleMode = replacement.isThirdPersonToggleModeEnabled; + config.minFOV = replacement.minimumFOV; + config.maxThirdPersonZoomDistance = replacement.maximumThirdPersonZoomBlocks; + config.minThirdPersonZoomDistance = replacement.minimumThirdPersonZoomBlocks; + config.disable = replacement.isDisabled; + + ZumeConfigImpl.replace(config); + } + +} diff --git a/api/src/main/java/dev/nolij/zume/api/platform/v0/CameraPerspective.java b/api/src/main/java/dev/nolij/zume/api/platform/v0/CameraPerspective.java new file mode 100644 index 00000000..51700b01 --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/api/platform/v0/CameraPerspective.java @@ -0,0 +1,9 @@ +package dev.nolij.zume.api.platform.v0; + +public enum CameraPerspective { + + FIRST_PERSON, + THIRD_PERSON, + THIRD_PERSON_FLIPPED, + +} diff --git a/common/src/main/java/dev/nolij/zume/common/IZumeImplementation.java b/api/src/main/java/dev/nolij/zume/api/platform/v0/IZumeImplementation.java similarity index 84% rename from common/src/main/java/dev/nolij/zume/common/IZumeImplementation.java rename to api/src/main/java/dev/nolij/zume/api/platform/v0/IZumeImplementation.java index fb7898b9..03aee0e1 100644 --- a/common/src/main/java/dev/nolij/zume/common/IZumeImplementation.java +++ b/api/src/main/java/dev/nolij/zume/api/platform/v0/IZumeImplementation.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common; +package dev.nolij.zume.api.platform.v0; public interface IZumeImplementation { diff --git a/api/src/main/java/dev/nolij/zume/api/platform/v0/ZumeAPI.java b/api/src/main/java/dev/nolij/zume/api/platform/v0/ZumeAPI.java new file mode 100644 index 00000000..6cf82095 --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/api/platform/v0/ZumeAPI.java @@ -0,0 +1,143 @@ +package dev.nolij.zume.api.platform.v0; + +import dev.nolij.zume.impl.CameraPerspective; +import dev.nolij.zume.impl.Zume; +import org.apache.logging.log4j.Logger; + +import java.nio.file.Path; + +public final class ZumeAPI { + + public static Logger getLogger() { + return Zume.LOGGER; + } + + /** + * Attempts to open Zume's config file in the system's text editor. + */ + public static void openConfigFile() { + Zume.openConfigFile(); + } + + /** + * Invoke this in the initializer of your Zume implementation. + * + * @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(IZumeImplementation implementation, Path instanceConfigPath) { + Zume.init(new dev.nolij.zume.impl.IZumeImplementation() { + @Override + public boolean isZoomPressed() { + return implementation.isZoomPressed(); + } + + @Override + public boolean isZoomInPressed() { + return implementation.isZoomInPressed(); + } + + @Override + public boolean isZoomOutPressed() { + return implementation.isZoomOutPressed(); + } + + @Override + public CameraPerspective getCameraPerspective() { + return CameraPerspective.values()[implementation.getCameraPerspective().ordinal()]; + } + + @Override + public void onZoomActivate() { + implementation.onZoomActivate(); + } + }, instanceConfigPath); + } + + //region Query Methods + /** + * Returns `true` if Zoom is activated. + */ + public static boolean isActive() { + return Zume.isEnabled(); + } + + /** + * Returns `true` if FOV should be hooked. + */ + public static boolean isFOVHookActive() { + return Zume.shouldHookFOV(); + } + + /** + * Returns `true` if mouse scrolling should be hooked. + */ + public static boolean isMouseScrollHookActive() { + return Zume.shouldCancelScroll(); + } + //endregion + + //region Hooks + /** + * 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() { + Zume.render(); + } + + /** + * 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} + */ + public static double fovHook(double fov) { + return Zume.transformFOV(fov); + } + + /** + * 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 + * @return The new third-person camera distance + */ + public static double thirdPersonCameraHook(double distance) { + return Zume.transformThirdPersonDistance(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} + */ + public static double mouseSensitivityHook(double mouseSensitivity) { + return Zume.transformMouseSensitivity(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} + */ + public static boolean cinematicCameraEnabledHook(boolean cinematicCameraEnabled) { + return Zume.transformCinematicCamera(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} + */ + public static boolean mouseScrollHook(int scrollDelta) { + return Zume.interceptScroll(scrollDelta); + } + //endregion + +} diff --git a/common/src/main/java/dev/nolij/zume/common/easing/EasingHelper.java b/api/src/main/java/dev/nolij/zume/api/util/v0/EasingHelper.java similarity index 98% rename from common/src/main/java/dev/nolij/zume/common/easing/EasingHelper.java rename to api/src/main/java/dev/nolij/zume/api/util/v0/EasingHelper.java index b33d5847..bffdea47 100644 --- a/common/src/main/java/dev/nolij/zume/common/easing/EasingHelper.java +++ b/api/src/main/java/dev/nolij/zume/api/util/v0/EasingHelper.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common.easing; +package dev.nolij.zume.api.util.v0; public final class EasingHelper { diff --git a/common/src/main/java/dev/nolij/zume/common/util/MethodHandleHelper.java b/api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java similarity index 98% rename from common/src/main/java/dev/nolij/zume/common/util/MethodHandleHelper.java rename to api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java index 0235281b..3ec7b637 100644 --- a/common/src/main/java/dev/nolij/zume/common/util/MethodHandleHelper.java +++ b/api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common.util; +package dev.nolij.zume.api.util.v0; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; diff --git a/common/src/main/java/dev/nolij/zume/common/CameraPerspective.java b/api/src/main/java/dev/nolij/zume/impl/CameraPerspective.java similarity index 74% rename from common/src/main/java/dev/nolij/zume/common/CameraPerspective.java rename to api/src/main/java/dev/nolij/zume/impl/CameraPerspective.java index b9b109d2..84c2a086 100644 --- a/common/src/main/java/dev/nolij/zume/common/CameraPerspective.java +++ b/api/src/main/java/dev/nolij/zume/impl/CameraPerspective.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common; +package dev.nolij.zume.impl; public enum CameraPerspective { diff --git a/common/src/main/java/dev/nolij/zume/common/easing/EasedDouble.java b/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java similarity index 95% rename from common/src/main/java/dev/nolij/zume/common/easing/EasedDouble.java rename to api/src/main/java/dev/nolij/zume/impl/EasedDouble.java index 25f58f30..ccbff16b 100644 --- a/common/src/main/java/dev/nolij/zume/common/easing/EasedDouble.java +++ b/api/src/main/java/dev/nolij/zume/impl/EasedDouble.java @@ -1,4 +1,6 @@ -package dev.nolij.zume.common.easing; +package dev.nolij.zume.impl; + +import dev.nolij.zume.api.util.v0.EasingHelper; public class EasedDouble { diff --git a/common/src/main/java/dev/nolij/zume/common/HostPlatform.java b/api/src/main/java/dev/nolij/zume/impl/HostPlatform.java similarity index 69% rename from common/src/main/java/dev/nolij/zume/common/HostPlatform.java rename to api/src/main/java/dev/nolij/zume/impl/HostPlatform.java index 4323f747..3b9285ba 100644 --- a/common/src/main/java/dev/nolij/zume/common/HostPlatform.java +++ b/api/src/main/java/dev/nolij/zume/impl/HostPlatform.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common; +package dev.nolij.zume.impl; public enum HostPlatform { diff --git a/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java b/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java new file mode 100644 index 00000000..146ba551 --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/impl/IZumeImplementation.java @@ -0,0 +1,13 @@ +package dev.nolij.zume.impl; + +public interface IZumeImplementation { + + boolean isZoomPressed(); + boolean isZoomInPressed(); + boolean isZoomOutPressed(); + + CameraPerspective getCameraPerspective(); + + void onZoomActivate(); + +} diff --git a/common/src/main/java/dev/nolij/zume/common/Zume.java b/api/src/main/java/dev/nolij/zume/impl/Zume.java similarity index 57% rename from common/src/main/java/dev/nolij/zume/common/Zume.java rename to api/src/main/java/dev/nolij/zume/impl/Zume.java index 803979f8..feb29b12 100644 --- a/common/src/main/java/dev/nolij/zume/common/Zume.java +++ b/api/src/main/java/dev/nolij/zume/impl/Zume.java @@ -1,74 +1,24 @@ -package dev.nolij.zume.common; +package dev.nolij.zume.impl; -import dev.nolij.zume.common.config.ZumeConfig; -import dev.nolij.zume.common.easing.EasedDouble; -import dev.nolij.zume.common.easing.EasingHelper; -import dev.nolij.zume.common.util.MethodHandleHelper; +import dev.nolij.zume.impl.config.ZumeConfigImpl; +import dev.nolij.zume.api.util.v0.EasingHelper; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.awt.*; import java.io.File; import java.io.IOException; -import java.lang.invoke.MethodType; import java.nio.file.Path; +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + public class Zume { //region Constants - private static final ClassLoader CLASS_LOADER = Zume.class.getClassLoader(); - - public static final String MOD_ID = "zume"; public static final Logger LOGGER = LogManager.getLogger(MOD_ID); public static final String CONFIG_FILE_NAME = MOD_ID + ".json5"; //endregion - //region Variant Detection - public static final String ZUME_VARIANT; - - static { - if (MethodHandleHelper.getClassOrNull("dev.su5ed.sinytra.connector.service.ConnectorLoaderService") == null && - CLASS_LOADER.getResource("net/fabricmc/fabric/api/client/keybinding/v1/KeyBindingHelper.class") != null) - ZUME_VARIANT = ZumeVariant.MODERN; - else if (CLASS_LOADER.getResource("net/legacyfabric/fabric/api/client/keybinding/v1/KeyBindingHelper.class") != null) - ZUME_VARIANT = ZumeVariant.LEGACY; - else if (CLASS_LOADER.getResource("net/modificationstation/stationapi/api/client/event/option/KeyBindingRegisterEvent.class") != null) - ZUME_VARIANT = ZumeVariant.PRIMITIVE; - else if ( - CLASS_LOADER.getResource("cpw/mods/fml/client/registry/KeyBindingRegistry.class") == null && - CLASS_LOADER.getResource("cpw/mods/fml/client/registry/ClientRegistry.class") != null) - ZUME_VARIANT = ZumeVariant.ARCHAIC_FORGE; - else if (CLASS_LOADER.getResource("net/minecraftforge/oredict/OreDictionary.class") != null) - ZUME_VARIANT = ZumeVariant.VINTAGE_FORGE; - else { - String forgeVersion = null; - - try { - //noinspection DataFlowIssue - forgeVersion = (String) MethodHandleHelper.getMethodOrNull( - MethodHandleHelper.getClassOrNull("net.minecraftforge.versions.forge.ForgeVersion"), - "getVersion", - MethodType.methodType(String.class) - ).invokeExact(); - } catch (Throwable ignored) { } - - if (forgeVersion != null) { - final int major = Integer.parseInt(forgeVersion.substring(0, forgeVersion.indexOf('.'))); - if (major > 40) - ZUME_VARIANT = ZumeVariant.LEXFORGE; - else if (major > 36) - ZUME_VARIANT = ZumeVariant.LEXFORGE18; - else if (major > 25) - ZUME_VARIANT = ZumeVariant.LEXFORGE16; - else - ZUME_VARIANT = null; - } else { - ZUME_VARIANT = null; - } - } - } - //endregion - //region Platform Detection public static final HostPlatform HOST_PLATFORM; @@ -98,7 +48,7 @@ private static double clamp(final double value) { //region Public Members public static IZumeImplementation implementation; - public static ZumeConfig config; + public static ZumeConfigImpl config; public static boolean disabled = false; //endregion @@ -112,24 +62,13 @@ private static double clamp(final double value) { //endregion //region Initialization Methods - /** - * Trigger variant detection if class isn't already loaded (it shouldn't be the first time this is called). - */ - static void calculateZumeVariant() {} - - /** - * Invoke this in the initializer of your Zume implementation. - * - * @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 init(final IZumeImplementation implementation, final Path instanceConfigPath) { if (Zume.implementation != null) throw new AssertionError("Zume already initialized!"); Zume.implementation = implementation; - ZumeConfig.init(instanceConfigPath, CONFIG_FILE_NAME, config -> { + ZumeConfigImpl.init(instanceConfigPath, CONFIG_FILE_NAME, config -> { Zume.config = config; zoom.update(config.zoomSmoothnessMs, config.animationEasingExponent); }); @@ -184,11 +123,8 @@ private static void onZoomDeactivate() { //endregion //region API Methods - /** - * Attempts to open Zume's config file in the system's text editor. - */ public static void openConfigFile() { - final File configFile = ZumeConfig.getConfigFile(); + final File configFile = ZumeConfigImpl.getConfigFile(); try { try { Desktop.getDesktop().open(configFile); @@ -210,23 +146,10 @@ public static void openConfigFile() { } } - /** - * ONLY INVOKE THIS METHOD WHEN {@linkplain Zume#shouldHookFOV()} RETURNS `true`. This check was explicitly excluded - * for efficiency and for mixin compatibility. The {@linkplain IZumeImplementation} is responsible for this check. - * - * @param original The unmodified FOV value - * {@return The new FOV transformed by Zume} - */ public static double transformFOV(final double original) { return EasingHelper.out(config.minFOV, original, getZoom(), config.zoomEasingExponent); } - /** - * This method assumes the perspective is third-person. If it is not, you will encounter bugs. - * - * @param original The vanilla third-person camera distance - * @return The new third-person camera distance - */ public static double transformThirdPersonDistance(final double original) { if (shouldUseFirstPersonZoom() || !shouldHook()) return original; @@ -234,12 +157,6 @@ public static double transformThirdPersonDistance(final double original) { return original * 0.25D * EasingHelper.out(config.minThirdPersonZoomDistance, config.maxThirdPersonZoomDistance, getZoom(), config.zoomEasingExponent); } - /** - * The return value of this method can be safely used without checking whether Zume is active. - * - * @param original The unmodified cinematic camera state - * {@return The new cinematic camera state, transformed by Zume} - */ public static boolean transformCinematicCamera(final boolean original) { if (Zume.config.enableCinematicZoom && isEnabled()) return true; @@ -247,12 +164,6 @@ public static boolean transformCinematicCamera(final boolean original) { return original; } - /** - * The return value of this method can be safely used without checking whether Zume is active. - * - * @param original The unmodified mouse sensitivity - * {@return The new mouse sensitivity, transformed by Zume} - */ public static double transformMouseSensitivity(final double original) { if (!isEnabled() || !shouldUseFirstPersonZoom()) return original; @@ -264,12 +175,6 @@ public static boolean shouldCancelScroll() { return Zume.config.enableZoomScrolling && isEnabled(); } - /** - * 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} - */ public static boolean interceptScroll(final int scrollDelta) { if (!shouldCancelScroll() || scrollDelta == 0) return false; @@ -284,9 +189,6 @@ private static boolean getToggleMode() { : config.thirdPersonToggleMode; } - /** - * Returns `true` if Zume is active. - */ public static boolean isEnabled() { if (disabled || implementation == null) return false; @@ -294,21 +196,14 @@ public static boolean isEnabled() { return zooming; } - /** - * Returns `true` if there is an active Zoom animation. Important distinction between this method and - * {@linkplain Zume#isEnabled()}: This method will return `true` when - * {@linkplain Zume#isEnabled()} returns `false` if the zoom out animation is still playing. Use this method to - * determine whether the user's FOV and camera values should be hooked. For other scenarios, use - * {@linkplain Zume#isEnabled()}. - */ - public static boolean shouldHook() { + private static boolean shouldHook() { if (disabled || implementation == null) return false; return isEnabled() || zoom.isEasing(); } - public static boolean shouldUseFirstPersonZoom() { + private static boolean shouldUseFirstPersonZoom() { return config.maxThirdPersonZoomDistance == 0 || implementation.getCameraPerspective() == CameraPerspective.FIRST_PERSON; } @@ -317,11 +212,6 @@ public static boolean shouldHookFOV() { return shouldHook() && shouldUseFirstPersonZoom(); } - /** - * This should be invoked once at the beginning of every frame. It will handle Keybindings and Scrolling if the - * {@linkplain IZumeImplementation} is implemented properly, and if {@linkplain Zume#scrollDelta} is maintained - * via use of {@linkplain Zume#interceptScroll(int)}. - */ public static void render() { if (disabled || implementation == null) return; diff --git a/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java b/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java new file mode 100644 index 00000000..47d9f142 --- /dev/null +++ b/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java @@ -0,0 +1,96 @@ +package dev.nolij.zume.impl; + +import dev.nolij.zume.api.util.v0.MethodHandleHelper; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import java.lang.invoke.MethodType; +import java.util.List; +import java.util.Set; + +public class ZumeMixinPlugin implements IMixinConfigPlugin { + + private static final ClassLoader CLASS_LOADER = ZumeMixinPlugin.class.getClassLoader(); + + public static final String ZUME_VARIANT; + private static final String implementationMixinPackage; + + static { + if (MethodHandleHelper.getClassOrNull("dev.su5ed.sinytra.connector.service.ConnectorLoaderService") == null && + CLASS_LOADER.getResource("net/fabricmc/fabric/api/client/keybinding/v1/KeyBindingHelper.class") != null) + ZUME_VARIANT = ZumeVariant.MODERN; + else if (CLASS_LOADER.getResource("net/legacyfabric/fabric/api/client/keybinding/v1/KeyBindingHelper.class") != null) + ZUME_VARIANT = ZumeVariant.LEGACY; + else if (CLASS_LOADER.getResource("net/modificationstation/stationapi/api/client/event/option/KeyBindingRegisterEvent.class") != null) + ZUME_VARIANT = ZumeVariant.PRIMITIVE; + else if ( + CLASS_LOADER.getResource("cpw/mods/fml/client/registry/KeyBindingRegistry.class") == null && + CLASS_LOADER.getResource("cpw/mods/fml/client/registry/ClientRegistry.class") != null) + ZUME_VARIANT = ZumeVariant.ARCHAIC_FORGE; + else if (CLASS_LOADER.getResource("net/minecraftforge/oredict/OreDictionary.class") != null) + ZUME_VARIANT = ZumeVariant.VINTAGE_FORGE; + else { + String forgeVersion = null; + + try { + //noinspection DataFlowIssue + forgeVersion = (String) MethodHandleHelper.getMethodOrNull( + MethodHandleHelper.getClassOrNull("net.minecraftforge.versions.forge.ForgeVersion"), + "getVersion", + MethodType.methodType(String.class) + ).invokeExact(); + } catch (Throwable ignored) { } + + if (forgeVersion != null) { + final int major = Integer.parseInt(forgeVersion.substring(0, forgeVersion.indexOf('.'))); + if (major > 40) + ZUME_VARIANT = ZumeVariant.LEXFORGE; + else if (major > 36) + ZUME_VARIANT = ZumeVariant.LEXFORGE18; + else if (major > 25) + ZUME_VARIANT = ZumeVariant.LEXFORGE16; + else + ZUME_VARIANT = null; + } else { + ZUME_VARIANT = null; + } + } + + if (ZUME_VARIANT != null) + implementationMixinPackage = "dev.nolij.zume." + ZUME_VARIANT + ".mixin."; + else + implementationMixinPackage = null; + } + + @Override + public void onLoad(String mixinPackage) {} + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (implementationMixinPackage == null) + return false; + + return mixinClassName.startsWith(implementationMixinPackage); + } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) {} + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} + +} diff --git a/common/src/main/java/dev/nolij/zume/common/ZumeVariant.java b/api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java similarity index 93% rename from common/src/main/java/dev/nolij/zume/common/ZumeVariant.java rename to api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java index 4263d458..ccdd609e 100644 --- a/common/src/main/java/dev/nolij/zume/common/ZumeVariant.java +++ b/api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common; +package dev.nolij.zume.impl; public final class ZumeVariant { diff --git a/common/src/main/java/dev/nolij/zume/common/util/FileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java similarity index 97% rename from common/src/main/java/dev/nolij/zume/common/util/FileWatcher.java rename to api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java index ccbe2d2c..14ab1069 100644 --- a/common/src/main/java/dev/nolij/zume/common/util/FileWatcher.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/FileWatcher.java @@ -1,9 +1,9 @@ // Based off of https://gist.githubusercontent.com/danielflower/f54c2fe42d32356301c68860a4ab21ed/raw/d09c312b4e40b17cdce310992da89dc06aabb98a/FileWatcher.java // Original License (all modifications are still distributed under this project's license): https://gist.github.com/danielflower/f54c2fe42d32356301c68860a4ab21ed?permalink_comment_id=2352260#gistcomment-2352260 -package dev.nolij.zume.common.util; +package dev.nolij.zume.impl.config; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.impl.Zume; import java.io.IOException; import java.nio.file.*; diff --git a/common/src/main/java/dev/nolij/zume/common/util/IFileWatcher.java b/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java similarity index 76% rename from common/src/main/java/dev/nolij/zume/common/util/IFileWatcher.java rename to api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java index 9a741a22..06b8e5f0 100644 --- a/common/src/main/java/dev/nolij/zume/common/util/IFileWatcher.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/IFileWatcher.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.common.util; +package dev.nolij.zume.impl.config; public interface IFileWatcher { diff --git a/common/src/main/java/dev/nolij/zume/common/config/ZumeConfig.java b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java similarity index 86% rename from common/src/main/java/dev/nolij/zume/common/config/ZumeConfig.java rename to api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java index aa7c67e1..6de09be8 100644 --- a/common/src/main/java/dev/nolij/zume/common/config/ZumeConfig.java +++ b/api/src/main/java/dev/nolij/zume/impl/config/ZumeConfigImpl.java @@ -1,19 +1,17 @@ -package dev.nolij.zume.common.config; +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.zume.common.Zume; -import dev.nolij.zume.common.util.FileWatcher; -import dev.nolij.zume.common.util.IFileWatcher; +import dev.nolij.zume.impl.Zume; import java.io.*; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; -public class ZumeConfig implements Cloneable { +public class ZumeConfigImpl { @Comment(""" \nEnable Cinematic Camera while zooming. @@ -103,7 +101,7 @@ public class ZumeConfig implements Cloneable { @FunctionalInterface public interface ConfigConsumer { - void invoke(ZumeConfig config); + void invoke(ZumeConfigImpl config); } private static final int MAX_RETRIES = 5; @@ -112,14 +110,14 @@ public interface ConfigConsumer { .allowBareRootObject() .build(); - private static ZumeConfig readFromFile(final File configFile) { + private static ZumeConfigImpl readFromFile(final File configFile) { if (configFile == null || !configFile.exists()) return null; int i = 0; while (true) { try { - return JANKSON.fromJson(JANKSON.load(configFile), ZumeConfig.class); + return JANKSON.fromJson(JANKSON.load(configFile), ZumeConfigImpl.class); } catch (SyntaxError e) { if (++i < MAX_RETRIES) { try { @@ -130,7 +128,7 @@ private static ZumeConfig readFromFile(final File configFile) { return null; } } - Zume.LOGGER.error("Error parsing config after " + i + " retries: ", e); + Zume.LOGGER.error("Error parsing config after {} retries: ", i, e); return null; } catch (IOException e) { Zume.LOGGER.error("Error reading config: ", e); @@ -139,11 +137,11 @@ private static ZumeConfig readFromFile(final File configFile) { } } - private static ZumeConfig readConfigFile() { - ZumeConfig result = readFromFile(getConfigFile()); + private static ZumeConfigImpl readConfigFile() { + ZumeConfigImpl result = readFromFile(getConfigFile()); if (result == null) - result = new ZumeConfig(); + result = new ZumeConfigImpl(); return result; } @@ -164,16 +162,7 @@ private void writeToFile(final File configFile) { private static File instanceFile = null; private static File globalFile = null; - @Override - public ZumeConfig clone() { - try { - return (ZumeConfig) super.clone(); - } catch (CloneNotSupportedException e) { - throw new AssertionError(e); - } - } - - public static void replace(final ZumeConfig newConfig) throws InterruptedException { + public static void replace(final ZumeConfigImpl newConfig) throws InterruptedException { try { instanceWatcher.lock(); try { @@ -189,12 +178,6 @@ public static void replace(final ZumeConfig newConfig) throws InterruptedExcepti } } - public void modify(ConfigConsumer modifier) throws InterruptedException { - final ZumeConfig newConfig = this.clone(); - modifier.invoke(newConfig); - replace(newConfig); - } - private static final String CONFIG_PATH_OVERRIDE = System.getProperty("zume.configPathOverride"); private static final Path GLOBAL_CONFIG_PATH; @@ -231,7 +214,7 @@ public static File getConfigFile() { public static void reloadConfig() { Zume.LOGGER.info("Reloading config..."); - final ZumeConfig newConfig = readConfigFile(); + final ZumeConfigImpl newConfig = readConfigFile(); consumer.invoke(newConfig); } @@ -246,7 +229,7 @@ public static void init(final Path instanceConfigPath, final String fileName, fi globalFile = GLOBAL_CONFIG_PATH.resolve(fileName).toFile(); } - ZumeConfig config = readConfigFile(); + ZumeConfigImpl config = readConfigFile(); // write new options and comment updates to disk config.writeToFile(getConfigFile()); @@ -271,11 +254,11 @@ public void unlock() {} instanceWatcher = nullWatcher; globalWatcher = nullWatcher; } else if (CONFIG_PATH_OVERRIDE == null) { - instanceWatcher = FileWatcher.onFileChange(instanceFile.toPath(), ZumeConfig::reloadConfig); - globalWatcher = FileWatcher.onFileChange(globalFile.toPath(), ZumeConfig::reloadConfig); + instanceWatcher = FileWatcher.onFileChange(instanceFile.toPath(), ZumeConfigImpl::reloadConfig); + globalWatcher = FileWatcher.onFileChange(globalFile.toPath(), ZumeConfigImpl::reloadConfig); } else { instanceWatcher = nullWatcher; - globalWatcher = FileWatcher.onFileChange(getConfigFile().toPath(), ZumeConfig::reloadConfig); + globalWatcher = FileWatcher.onFileChange(getConfigFile().toPath(), ZumeConfigImpl::reloadConfig); } } catch (IOException e) { throw new RuntimeException(e); diff --git a/common/src/main/resources/assets/zume/lang/en_CA.lang b/api/src/main/resources/assets/zume/lang/en_CA.lang similarity index 100% rename from common/src/main/resources/assets/zume/lang/en_CA.lang rename to api/src/main/resources/assets/zume/lang/en_CA.lang diff --git a/common/src/main/resources/assets/zume/lang/en_US.lang b/api/src/main/resources/assets/zume/lang/en_US.lang similarity index 100% rename from common/src/main/resources/assets/zume/lang/en_US.lang rename to api/src/main/resources/assets/zume/lang/en_US.lang diff --git a/common/src/main/resources/assets/zume/lang/en_ca.json b/api/src/main/resources/assets/zume/lang/en_ca.json similarity index 100% rename from common/src/main/resources/assets/zume/lang/en_ca.json rename to api/src/main/resources/assets/zume/lang/en_ca.json diff --git a/common/src/main/resources/assets/zume/lang/en_us.json b/api/src/main/resources/assets/zume/lang/en_us.json similarity index 100% rename from common/src/main/resources/assets/zume/lang/en_us.json rename to api/src/main/resources/assets/zume/lang/en_us.json diff --git a/common/src/main/resources/icon.png b/api/src/main/resources/icon.png similarity index 100% rename from common/src/main/resources/icon.png rename to api/src/main/resources/icon.png diff --git a/common/src/main/resources/icon.xcf b/api/src/main/resources/icon.xcf similarity index 100% rename from common/src/main/resources/icon.xcf rename to api/src/main/resources/icon.xcf diff --git a/common/src/main/resources/icon_large.png b/api/src/main/resources/icon_large.png similarity index 100% rename from common/src/main/resources/icon_large.png rename to api/src/main/resources/icon_large.png 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 af43144e..d8652ae0 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicConfigProvider.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicConfigProvider.java @@ -2,21 +2,24 @@ import cpw.mods.fml.client.IModGuiFactory; import cpw.mods.fml.client.config.GuiConfig; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import java.util.Collections; import java.util.Set; +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +@SuppressWarnings("unused") public class ArchaicConfigProvider implements IModGuiFactory { public static class ArchaicZumeConfigGUI extends GuiConfig { public ArchaicZumeConfigGUI(GuiScreen parentScreen) { - super(parentScreen, Collections.emptyList(), Zume.MOD_ID, false, false, "config"); + super(parentScreen, Collections.emptyList(), MOD_ID, false, false, "config"); - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); } @Override 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 9bb9c188..f3ef0d1c 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java @@ -3,11 +3,11 @@ 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.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import dev.nolij.zume.archaic.mixin.EntityRendererAccessor; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.Constants; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.event.FMLPreInitializationEvent; @@ -17,11 +17,13 @@ import net.minecraftforge.client.event.MouseEvent; import net.minecraftforge.common.MinecraftForge; +import static dev.nolij.zume.impl.ZumeConstants.*; + @Mod( - modid = Zume.MOD_ID, - name = Constants.MOD_NAME, - version = Constants.MOD_VERSION, - acceptedMinecraftVersions = Constants.ARCHAIC_VERSION_RANGE, + modid = MOD_ID, + name = MOD_NAME, + version = MOD_VERSION, + acceptedMinecraftVersions = ARCHAIC_VERSION_RANGE, guiFactory = "dev.nolij.zume.archaic.ArchaicConfigProvider", dependencies = "required-after:unimixins@[0.1.15,)") public class ArchaicZume implements IZumeImplementation { @@ -31,10 +33,10 @@ public void preInit(FMLPreInitializationEvent event) { if (!FMLLaunchHandler.side().isClient()) return; - Zume.LOGGER.info("Loading Archaic Zume..."); + ZumeAPI.getLogger().info("Loading Archaic Zume..."); - Zume.init(this, Launch.minecraftHome.toPath().resolve("config")); - if (Zume.disabled) + ZumeAPI.registerImplementation(this, Launch.minecraftHome.toPath().resolve("config")); + if (ZumeConfigAPI.isDisabled()) return; for (final ZumeKeyBind keyBind : ZumeKeyBind.values()) { @@ -66,7 +68,7 @@ public CameraPerspective getCameraPerspective() { @Override public void onZoomActivate() { - if (Zume.config.enableCinematicZoom && !Minecraft.getMinecraft().gameSettings.smoothCamera) { + if (ZumeConfigAPI.isCinematicZoomEnabled() && !Minecraft.getMinecraft().gameSettings.smoothCamera) { final EntityRendererAccessor entityRenderer = (EntityRendererAccessor) Minecraft.getMinecraft().entityRenderer; entityRenderer.setMouseFilterXAxis(new MouseFilter()); entityRenderer.setMouseFilterYAxis(new MouseFilter()); @@ -81,7 +83,7 @@ public void onZoomActivate() { @SubscribeEvent(priority = EventPriority.HIGHEST) public void mouseEvent(MouseEvent mouseEvent) { final int scrollAmount = mouseEvent.dwheel; - if (Zume.interceptScroll(scrollAmount)) { + if (ZumeAPI.mouseScrollHook(scrollAmount)) { mouseEvent.setCanceled(true); } } diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java b/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java index eeeb09da..2d93d78f 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java @@ -2,7 +2,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.renderer.EntityRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -14,13 +14,13 @@ public class EntityRendererMixin { @Inject(method = "updateCameraAndRender", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { - Zume.render(); + ZumeAPI.renderHook(); } @ModifyReturnValue(method = "getFOVModifier", at = @At("TAIL")) public float zume$getFOV$TAIL(float original) { - if (Zume.shouldHookFOV()) - return (float) Zume.transformFOV(original); + if (ZumeAPI.isFOVHookActive()) + return (float) ZumeAPI.fovHook(original); return original; } @@ -28,25 +28,25 @@ public class EntityRendererMixin { @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { - return Zume.transformCinematicCamera(original); + return ZumeAPI.cinematicCameraEnabledHook(original); } @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) Zume.transformMouseSensitivity(original); + return (float) ZumeAPI.mouseSensitivityHook(original); } @ModifyExpressionValue(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistance:F")) public float zume$orientCamera$thirdPersonDistance(float original) { - return (float) Zume.transformThirdPersonDistance(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } @ModifyExpressionValue(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/client/renderer/EntityRenderer;thirdPersonDistanceTemp:F")) public float zume$orientCamera$thirdPersonDistanceTemp(float original) { - return (float) Zume.transformThirdPersonDistance(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/archaic/src/main/resources/zume-archaic.mixins.json b/archaic/src/main/resources/zume-archaic.mixins.json index acd280eb..9ac6f3f4 100644 --- a/archaic/src/main/resources/zume-archaic.mixins.json +++ b/archaic/src/main/resources/zume-archaic.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.archaic.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/build.gradle.kts b/build.gradle.kts index bd8656e6..762ba24e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -98,7 +98,7 @@ rootProject.group = "maven_group"() rootProject.version = Zume.version base { - archivesName = "archives_base_name"() + archivesName = "mod_id"() } val fabricImpls = arrayOf( @@ -191,7 +191,7 @@ subprojects { version = Zume.version base { - archivesName = "${"archives_base_name"()}-${subProject.name}" + archivesName = "${"mod_id"()}-${subProject.name}" } tasks.withType { @@ -212,11 +212,7 @@ subprojects { dependencies { "shade"("blue.endless:jankson:${"jankson_version"()}") { isTransitive = false } - "shade"(project(":common")) { isTransitive = false } - } - - tasks.processResources { - from("common/src/main/resources") + "shade"(project(":api")) { isTransitive = false } } afterEvaluate { @@ -224,7 +220,7 @@ subprojects { group = "build" from("../LICENSE") { - rename { "${it}_${"archives_base_name"()}" } + rename { "${it}_${"mod_id"()}" } } val remapJar = tasks.withType() @@ -305,17 +301,14 @@ dependencies { compileOnly(project(":stubs")) - "shade"(project(":common")) { isTransitive = false } + implementation(project(":api")) + "shade"(project(":api")) { isTransitive = false } uniminedImpls.forEach { implementation(project(":${it}")) { isTransitive = false } } } -tasks.processResources { - from("common/src/main/resources") -} - tasks.jar { enabled = false } @@ -323,7 +316,7 @@ tasks.jar { tasks.shadowJar { val shadowJar = this from("LICENSE") { - rename { "${it}_${"archives_base_name"()}" } + rename { "${it}_${"mod_id"()}" } } exclude("*.xcf") @@ -453,7 +446,7 @@ val compressJar = tasks.register("compressJar") { afterEvaluate { publishing { publications { - create("archives_base_name"()) { + create("mod_id"()) { artifact(tasks.shadowJar) uniminedImpls.forEach { implName -> artifact(project(":${implName}").tasks.named("platformJar")) diff --git a/common/src/main/java/dev/nolij/zume/common/ZumeMixinPlugin.java b/common/src/main/java/dev/nolij/zume/common/ZumeMixinPlugin.java deleted file mode 100644 index 9c5186d8..00000000 --- a/common/src/main/java/dev/nolij/zume/common/ZumeMixinPlugin.java +++ /dev/null @@ -1,48 +0,0 @@ -package dev.nolij.zume.common; - -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -import java.util.List; -import java.util.Set; - -public class ZumeMixinPlugin implements IMixinConfigPlugin { - - private String implementationMixinPackage = null; - - @Override - public void onLoad(String mixinPackage) { - Zume.calculateZumeVariant(); - if (Zume.ZUME_VARIANT != null) - implementationMixinPackage = "dev.nolij.zume." + Zume.ZUME_VARIANT + ".mixin."; - } - - @Override - public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { - if (implementationMixinPackage == null) - return false; - - return mixinClassName.startsWith(implementationMixinPackage); - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public void acceptTargets(Set myTargets, Set otherTargets) {} - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} - - @Override - public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {} - -} diff --git a/gradle.properties b/gradle.properties index 6ee28f9d..f11f5a7d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,9 +6,9 @@ org.gradle.caching = true org.gradle.configuration-cache = false # Mod Properties -mod_version = 0.18 maven_group = dev.nolij -archives_base_name = zume +mod_id = zume +mod_version = 0.19 mod_name = Zume mod_description = An over-engineered Zoom mod by Nolij nolij = Nolij (@xdMatthewbx#1337) @@ -22,7 +22,7 @@ strip_source_files = true # Fabric # https://modmuss50.me/fabric.html -fabric_version = 0.15.9 +fabric_version = 0.15.10 ## Modern Fabric # https://modmuss50.me/fabric.html 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 3ac94ec0..f31377a4 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java @@ -1,8 +1,9 @@ package dev.nolij.zume.legacy; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import dev.nolij.zume.legacy.mixin.GameRendererAccessor; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; @@ -17,9 +18,9 @@ public void onInitializeClient() { if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) return; - Zume.LOGGER.info("Loading Legacy Zume..."); + ZumeAPI.getLogger().info("Loading Legacy Zume..."); - Zume.init(this, FabricLoader.getInstance().getConfigDir()); + ZumeAPI.registerImplementation(this, FabricLoader.getInstance().getConfigDir()); } @Override @@ -58,7 +59,7 @@ public CameraPerspective getCameraPerspective() { @Override public void onZoomActivate() { if (USE_CINEMATIC_CAMERA_WORKAROUND && - Zume.config.enableCinematicZoom && !MinecraftClient.getInstance().options.smoothCameraEnabled) { + ZumeConfigAPI.isCinematicZoomEnabled() && !MinecraftClient.getInstance().options.smoothCameraEnabled) { final GameRendererAccessor gameRenderer = (GameRendererAccessor) MinecraftClient.getInstance().gameRenderer; gameRenderer.setCursorXSmoother(new SmoothUtil()); gameRenderer.setCursorYSmoother(new SmoothUtil()); diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java index 0e0f1ebc..7978414d 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.legacy.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import dev.nolij.zume.legacy.ZumeKeyBind; import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.minecraft.client.option.GameOptions; @@ -18,7 +18,7 @@ public class GameOptionsMixin { @Inject(method = "load", at = @At("HEAD")) public void zume$load$HEAD(CallbackInfo ci) { - if (Zume.disabled) return; + if (ZumeConfigAPI.isDisabled()) return; if (!keybindsRegistered) { keybindsRegistered = true; diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java index 2ee67ee7..b53478bf 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java @@ -2,7 +2,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.render.GameRenderer; import org.spongepowered.asm.mixin.Dynamic; import org.spongepowered.asm.mixin.Mixin; @@ -20,13 +20,13 @@ public class GameRendererMixin { "method_9775(FJ)V" // vintage }, at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { - Zume.render(); + ZumeAPI.renderHook(); } @ModifyReturnValue(method = "getFov", at = @At("TAIL")) public float zume$getFOV$TAIL(float original) { - if (Zume.shouldHookFOV()) - return (float) Zume.transformFOV(original); + if (ZumeAPI.isFOVHookActive()) + return (float) ZumeAPI.fovHook(original); return original; } @@ -37,7 +37,7 @@ public class GameRendererMixin { "method_9775(FJ)V" // vintage }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;smoothCameraEnabled:Z")) public boolean zume$smoothCameraEnabled(boolean original) { - return Zume.transformCinematicCamera(original); + return ZumeAPI.cinematicCameraEnabledHook(original); } @Dynamic @@ -46,12 +46,12 @@ public class GameRendererMixin { "method_9775(FJ)V" // vintage }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;sensitivity:F")) public float zume$mouseSensitivity(float original) { - return (float) Zume.transformMouseSensitivity(original); + return (float) ZumeAPI.mouseSensitivityHook(original); } @ModifyVariable(method = "transformCamera", at = @At(value = "STORE", ordinal = 0), ordinal = 3) public double zume$transformCamera$thirdPersonDistance(double original) { - return Zume.transformThirdPersonDistance(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java index 04a5ea75..645e1f25 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.legacy.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import net.minecraft.client.option.KeyBinding; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -22,7 +22,7 @@ public class KeyBindingMixin { @Inject(method = "", at = @At("TAIL")) private static void static$TAIL(CallbackInfo ci) { - if (Zume.disabled) return; + if (ZumeConfigAPI.isDisabled()) return; categories.add("category.zume"); if (field_15867 != null) diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java index 242508c1..dc601359 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java @@ -1,7 +1,7 @@ package dev.nolij.zume.legacy.mixin; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.player.PlayerInventory; import org.spongepowered.asm.mixin.Dynamic; @@ -17,7 +17,7 @@ public class MinecraftClientMixin { "method_12141()V" // vintage }, at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;scrollInHotbar(I)V")) public boolean onMouseScroll$scrollInHotbar(PlayerInventory instance, int scrollAmount) { - return !Zume.interceptScroll(scrollAmount); + return !ZumeAPI.mouseScrollHook(scrollAmount); } } diff --git a/legacy/src/main/resources/zume-legacy.mixins.json b/legacy/src/main/resources/zume-legacy.mixins.json index ca091c64..7cb5b80e 100644 --- a/legacy/src/main/resources/zume-legacy.mixins.json +++ b/legacy/src/main/resources/zume-legacy.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.legacy.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/lexforge/build.gradle.kts b/lexforge/build.gradle.kts index e5678565..8408b3cb 100644 --- a/lexforge/build.gradle.kts +++ b/lexforge/build.gradle.kts @@ -3,7 +3,7 @@ operator fun String.invoke(): String { } unimined.minecraft { - combineWith(project(":common").sourceSets.main.get()) + combineWith(project(":api").sourceSets.main.get()) version("lexforge_minecraft_version"()) 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 58c929f0..32859774 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,10 @@ package dev.nolij.zume.lexforge; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.util.MethodHandleHelper; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; +import dev.nolij.zume.api.util.v0.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraftforge.client.event.InputEvent; import net.minecraftforge.client.event.RegisterKeyMappingsEvent; @@ -18,22 +19,22 @@ import org.jetbrains.annotations.NotNull; import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Method; -@Mod(Zume.MOD_ID) +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +@Mod(MOD_ID) public class LexZume implements IZumeImplementation { public LexZume() { if (!FMLEnvironment.dist.isClient()) return; - Zume.LOGGER.info("Loading LexZume..."); + ZumeAPI.getLogger().info("Loading LexZume..."); LexZumeConfigScreen.register(); - Zume.init(this, FMLPaths.CONFIGDIR.get()); - if (Zume.disabled) + ZumeAPI.registerImplementation(this, FMLPaths.CONFIGDIR.get()); + if (ZumeConfigAPI.isDisabled()) return; FMLJavaModLoadingContext.get().getModEventBus().addListener(this::registerKeyBindings); @@ -70,13 +71,13 @@ private void registerKeyBindings(RegisterKeyMappingsEvent event) { private void render(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { - Zume.render(); + ZumeAPI.renderHook(); } } private void calculateFOV(ViewportEvent.ComputeFov event) { - if (Zume.shouldHookFOV()) { - event.setFOV(Zume.transformFOV(event.getFOV())); + if (ZumeAPI.isFOVHookActive()) { + event.setFOV(ZumeAPI.fovHook(event.getFOV())); } } @@ -94,7 +95,7 @@ private void onMouseScroll(InputEvent.MouseScrollingEvent event) { } catch (Throwable e) { throw new AssertionError(e); } - if (Zume.interceptScroll(scrollAmount)) { + if (ZumeAPI.mouseScrollHook(scrollAmount)) { event.setCanceled(true); } } diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZumeConfigScreen.java b/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZumeConfigScreen.java index b3f350fe..88ccd1f4 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZumeConfigScreen.java +++ b/lexforge/src/main/java/dev/nolij/zume/lexforge/LexZumeConfigScreen.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -15,7 +15,7 @@ static void register() { () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, parent) -> new Screen(Component.nullToEmpty(null)) { @Override public void tick() { - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); Minecraft.getInstance().setScreen(parent); } })); diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java b/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java index 86950930..e7f5bf33 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Camera; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -11,7 +11,7 @@ public 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 Zume.transformThirdPersonDistance(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java b/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java index 97edf4f7..7604981f 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MouseHandler; import net.minecraft.client.OptionInstance; import net.minecraft.client.Options; @@ -13,13 +13,13 @@ public class MouseHandlerMixin { @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(Options instance) { - return Zume.transformCinematicCamera(instance.smoothCamera); + return ZumeAPI.cinematicCameraEnabledHook(instance.smoothCamera); } @SuppressWarnings("unchecked") @Redirect(method = "turnPlayer", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/OptionInstance;get()Ljava/lang/Object;", ordinal = 0)) public T zume$updateMouse$getMouseSensitivity$getValue(OptionInstance instance) { - return (T) (Object) Zume.transformMouseSensitivity(instance.get()); + return (T) (Object) ZumeAPI.mouseSensitivityHook(instance.get()); } } diff --git a/lexforge/src/main/resources/zume-lexforge.mixins.json b/lexforge/src/main/resources/zume-lexforge.mixins.json index 9269e01d..b9f1139f 100644 --- a/lexforge/src/main/resources/zume-lexforge.mixins.json +++ b/lexforge/src/main/resources/zume-lexforge.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.lexforge.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/lexforge16/build.gradle.kts b/lexforge16/build.gradle.kts index 7d62fc15..d0c86ef1 100644 --- a/lexforge16/build.gradle.kts +++ b/lexforge16/build.gradle.kts @@ -3,7 +3,7 @@ operator fun String.invoke(): String { } unimined.minecraft { - combineWith(project(":common").sourceSets.main.get()) + combineWith(project(":api").sourceSets.main.get()) version("lexforge16_minecraft_version"()) 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 63b74dc8..6d43b808 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,11 @@ package dev.nolij.zume.lexforge16; import cpw.mods.modlauncher.api.INameMappingService; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.util.MethodHandleHelper; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; +import dev.nolij.zume.api.util.v0.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.Options; import net.minecraftforge.client.event.EntityViewRenderEvent; @@ -21,19 +22,21 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -@Mod(Zume.MOD_ID) +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +@Mod(MOD_ID) public class LexZume16 implements IZumeImplementation { public LexZume16() { if (!FMLEnvironment.dist.isClient()) return; - Zume.LOGGER.info("Loading LexZume16..."); + ZumeAPI.getLogger().info("Loading LexZume16..."); LexZume16ConfigScreen.register(); - Zume.init(this, FMLPaths.CONFIGDIR.get()); - if (Zume.disabled) + ZumeAPI.registerImplementation(this, FMLPaths.CONFIGDIR.get()); + if (ZumeConfigAPI.isDisabled()) return; for (final ZumeKeyBind keyBind : ZumeKeyBind.values()) { @@ -85,19 +88,19 @@ public CameraPerspective getCameraPerspective() { private void render(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { - Zume.render(); + ZumeAPI.renderHook(); } } private void calculateFOV(EntityViewRenderEvent.FOVModifier event) { - if (Zume.shouldHookFOV()) { - event.setFOV(Zume.transformFOV(event.getFOV())); + if (ZumeAPI.isFOVHookActive()) { + event.setFOV(ZumeAPI.fovHook(event.getFOV())); } } private void onMouseScroll(InputEvent.MouseScrollEvent event) { final int scrollAmount = (int) event.getScrollDelta(); - if (Zume.interceptScroll(scrollAmount)) { + if (ZumeAPI.mouseScrollHook(scrollAmount)) { event.setCanceled(true); } } diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16ConfigScreen.java b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16ConfigScreen.java index b43f8e22..992d7ae3 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16ConfigScreen.java +++ b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/LexZume16ConfigScreen.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge16; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.TextComponent; @@ -23,7 +23,7 @@ private ConfigScreen(Screen parent) { super(new TextComponent("")); this.parent = parent; - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); } @Override diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java index 01973970..63ffad4c 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge16.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Camera; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -11,7 +11,7 @@ public 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 Zume.transformThirdPersonDistance(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java index f802f608..610d3fa5 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge16.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MouseHandler; import net.minecraft.client.Options; import org.spongepowered.asm.mixin.Mixin; @@ -12,12 +12,12 @@ public class MouseHandlerMixin { @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(Options instance) { - return Zume.transformCinematicCamera(instance.smoothCamera); + return ZumeAPI.cinematicCameraEnabledHook(instance.smoothCamera); } @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;sensitivity:D", ordinal = 0)) public double zume$updateMouse$getMouseSensitivity$getValue(Options instance) { - return Zume.transformMouseSensitivity(instance.sensitivity); + return ZumeAPI.mouseSensitivityHook(instance.sensitivity); } } diff --git a/lexforge16/src/main/resources/zume-lexforge16.mixins.json b/lexforge16/src/main/resources/zume-lexforge16.mixins.json index 47b1438f..391feda5 100644 --- a/lexforge16/src/main/resources/zume-lexforge16.mixins.json +++ b/lexforge16/src/main/resources/zume-lexforge16.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.lexforge16.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/lexforge18/build.gradle.kts b/lexforge18/build.gradle.kts index 262b6e62..d9eab392 100644 --- a/lexforge18/build.gradle.kts +++ b/lexforge18/build.gradle.kts @@ -3,7 +3,7 @@ operator fun String.invoke(): String { } unimined.minecraft { - combineWith(project(":common").sourceSets.main.get()) + combineWith(project(":api").sourceSets.main.get()) version("lexforge18_minecraft_version"()) 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 6cf15ba3..f2e3256d 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,10 @@ package dev.nolij.zume.lexforge18; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.util.MethodHandleHelper; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; +import dev.nolij.zume.api.util.v0.MethodHandleHelper; import net.minecraft.client.Minecraft; import net.minecraftforge.client.ClientRegistry; import net.minecraftforge.client.event.EntityViewRenderEvent; @@ -18,7 +19,9 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; -@Mod(Zume.MOD_ID) +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +@Mod(MOD_ID) public class LexZume18 implements IZumeImplementation { private static final Class FOV_EVENT_CLASS = MethodHandleHelper.getClassOrNull( @@ -41,12 +44,12 @@ public LexZume18() { if (!FMLEnvironment.dist.isClient()) return; - Zume.LOGGER.info("Loading LexZume18..."); + ZumeAPI.getLogger().info("Loading LexZume18..."); LexZume18ConfigScreen.register(); - Zume.init(this, FMLPaths.CONFIGDIR.get()); - if (Zume.disabled) + ZumeAPI.registerImplementation(this, FMLPaths.CONFIGDIR.get()); + if (ZumeConfigAPI.isDisabled()) return; for (final ZumeKeyBind keyBind : ZumeKeyBind.values()) { @@ -80,14 +83,14 @@ public CameraPerspective getCameraPerspective() { private void render(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { - Zume.render(); + ZumeAPI.renderHook(); } } private void calculateFOV(EntityViewRenderEvent event) { - if (event.getClass() == FOV_EVENT_CLASS && Zume.shouldHookFOV()) { + if (event.getClass() == FOV_EVENT_CLASS && ZumeAPI.isFOVHookActive()) { try { - SET_FOV.invokeExact(event, Zume.transformFOV((double) GET_FOV.invokeExact(event))); + SET_FOV.invokeExact(event, ZumeAPI.fovHook((double) GET_FOV.invokeExact(event))); } catch (Throwable e) { throw new AssertionError(e); } @@ -96,7 +99,7 @@ private void calculateFOV(EntityViewRenderEvent event) { private void onMouseScroll(InputEvent.MouseScrollEvent event) { final int scrollAmount = (int) event.getScrollDelta(); - if (Zume.interceptScroll(scrollAmount)) { + if (ZumeAPI.mouseScrollHook(scrollAmount)) { event.setCanceled(true); } } diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18ConfigScreen.java b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18ConfigScreen.java index e34fc750..61626c7b 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18ConfigScreen.java +++ b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/LexZume18ConfigScreen.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge18; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.TextComponent; @@ -15,7 +15,7 @@ static void register() { () -> new ConfigGuiHandler.ConfigGuiFactory((minecraft, parent) -> new Screen(new TextComponent("")) { @Override public void tick() { - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); Minecraft.getInstance().setScreen(parent); } })); diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java index 4b548a10..efe1db4a 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge18.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Camera; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -11,7 +11,7 @@ public 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 Zume.transformThirdPersonDistance(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java index 2eb93fc6..6631351d 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.lexforge18.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MouseHandler; import net.minecraft.client.Options; import org.spongepowered.asm.mixin.Mixin; @@ -12,12 +12,12 @@ public class MouseHandlerMixin { @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(Options instance) { - return Zume.transformCinematicCamera(instance.smoothCamera); + return ZumeAPI.cinematicCameraEnabledHook(instance.smoothCamera); } @Redirect(method = "turnPlayer", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Options;sensitivity:D", ordinal = 0)) public double zume$updateMouse$getMouseSensitivity$getValue(Options instance) { - return Zume.transformMouseSensitivity(instance.sensitivity); + return ZumeAPI.mouseSensitivityHook(instance.sensitivity); } } diff --git a/lexforge18/src/main/resources/zume-lexforge18.mixins.json b/lexforge18/src/main/resources/zume-lexforge18.mixins.json index c0e10511..b80e45ec 100644 --- a/lexforge18/src/main/resources/zume-lexforge18.mixins.json +++ b/lexforge18/src/main/resources/zume-lexforge18.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.lexforge18.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], 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 1f27f003..4ae358cd 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,10 @@ package dev.nolij.zume.modern; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.util.MethodHandleHelper; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; +import dev.nolij.zume.api.util.v0.MethodHandleHelper; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; @@ -21,10 +22,10 @@ public void onInitializeClient() { if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) return; - Zume.LOGGER.info("Loading Modern Zume..."); + ZumeAPI.getLogger().info("Loading Modern Zume..."); - Zume.init(this, FabricLoader.getInstance().getConfigDir()); - if (Zume.disabled) return; + ZumeAPI.registerImplementation(this, FabricLoader.getInstance().getConfigDir()); + if (ZumeConfigAPI.isDisabled()) return; for (final ZumeKeyBind keyBind : ZumeKeyBind.values()) { KeyBindingHelper.registerKeyBinding(keyBind.value); diff --git a/modern/src/main/java/dev/nolij/zume/modern/integration/ZumeModMenuIntegration.java b/modern/src/main/java/dev/nolij/zume/modern/integration/ZumeModMenuIntegration.java index 324af0fe..f86f20e1 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/integration/ZumeModMenuIntegration.java +++ b/modern/src/main/java/dev/nolij/zume/modern/integration/ZumeModMenuIntegration.java @@ -1,8 +1,8 @@ package dev.nolij.zume.modern.integration; import com.terraformersmc.modmenu.api.ConfigScreenFactory; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.util.MethodHandleHelper; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.util.v0.MethodHandleHelper; import io.github.prospector.modmenu.api.ModMenuApi; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.screen.Screen; @@ -12,6 +12,8 @@ import java.lang.invoke.MethodType; import java.util.function.Function; +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + public class ZumeModMenuIntegration implements ModMenuApi { private static final MethodHandle LITERALTEXT_INIT = MethodHandleHelper.getConstructorOrNull( @@ -29,7 +31,7 @@ private ModernZumeConfigScreen(Text arg, Screen parent) { @Override public void init() { - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); MinecraftClient.getInstance().setScreen(parent); } @@ -41,7 +43,7 @@ public void render(int mouseX, int mouseY, float delta) { @Override public String getModId() { - return Zume.MOD_ID; + return MOD_ID; } @Override @@ -50,7 +52,7 @@ public String getModId() { try { return new ModernZumeConfigScreen((Text) LITERALTEXT_INIT.invokeExact(""), parent); } catch (Throwable e) { - Zume.LOGGER.error("Error opening config screen: ", e); + ZumeAPI.getLogger().error("Error opening config screen: ", e); return null; } }; diff --git a/modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java b/modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java index 7dbe3aca..2107e139 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java +++ b/modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java @@ -1,6 +1,6 @@ package dev.nolij.zume.modern.mixin; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.render.Camera; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -11,7 +11,7 @@ public 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) { - return Zume.transformThirdPersonDistance(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java b/modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java index 3bc82170..81f96260 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java +++ b/modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java @@ -1,7 +1,7 @@ package dev.nolij.zume.modern.mixin; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.render.GameRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -13,13 +13,13 @@ public class GameRendererMixin { @Inject(method = "render", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { - Zume.render(); + ZumeAPI.renderHook(); } @ModifyReturnValue(method = "getFov", at = @At("TAIL")) public double zume$getFov$TAIL(double original) { - if (Zume.shouldHookFOV()) - return Zume.transformFOV(original); + if (ZumeAPI.isFOVHookActive()) + return ZumeAPI.fovHook(original); return original; } diff --git a/modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java b/modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java index 98e51184..f86d3fe4 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java +++ b/modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java @@ -2,7 +2,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Mouse; import net.minecraft.entity.player.PlayerInventory; import org.spongepowered.asm.mixin.Dynamic; @@ -19,7 +19,7 @@ public class MouseMixin { "method_1606(D)V" // 20.5+ compat }, at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;smoothCameraEnabled:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { - return Zume.transformCinematicCamera(original); + return ZumeAPI.cinematicCameraEnabledHook(original); } @SuppressWarnings("unchecked") @@ -30,19 +30,19 @@ public class MouseMixin { "method_1606(D)V" // 20.5+ compat }, at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/SimpleOption;getValue()Ljava/lang/Object;", ordinal = 0), require = 0) public T zume$updateMouse$getMouseSensitivity$getValue(T original) { - return (T) (Object) Zume.transformMouseSensitivity((Double) original); + return (T) (Object) ZumeAPI.mouseSensitivityHook((Double) original); } @Dynamic @Group(name = "zume$getMouseSensitivity", min = 1, max = 1) @ModifyExpressionValue(method = "updateMouse", at = @At(value = "FIELD", target = "Lnet/minecraft/class_315;field_1843:D", remap = false), require = 0) public double zume$updateMouse$mouseSensitivity(double original) { - return Zume.transformMouseSensitivity(original); + return ZumeAPI.mouseSensitivityHook(original); } @ModifyExpressionValue(method = "onMouseScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerEntity;isSpectator()Z")) public boolean onMouseScroll$isSpectator(boolean original) { - if (Zume.shouldCancelScroll()) + if (ZumeAPI.isMouseScrollHookActive()) return false; return original; @@ -50,7 +50,7 @@ public class MouseMixin { @WrapWithCondition(method = "onMouseScroll", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerInventory;scrollInHotbar(D)V")) public boolean onMouseScroll$scrollInHotbar(PlayerInventory instance, double scrollAmount) { - return !Zume.interceptScroll((int) scrollAmount); + return !ZumeAPI.mouseScrollHook((int) scrollAmount); } } diff --git a/modern/src/main/resources/zume-modern.mixins.json b/modern/src/main/resources/zume-modern.mixins.json index 9a319480..95145daf 100644 --- a/modern/src/main/resources/zume-modern.mixins.json +++ b/modern/src/main/resources/zume-modern.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.modern.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index 6ef1a004..e947c799 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -28,5 +28,5 @@ dependencies { "minecraftLibraries"("blue.endless:jankson:${"jankson_version"()}") - "minecraftLibraries"(project(":common")) + "minecraftLibraries"(project(":api")) } \ 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 33604b1e..b8f0a1be 100644 --- a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java @@ -1,8 +1,9 @@ package dev.nolij.zume.neoforge; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import net.minecraft.client.Minecraft; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; @@ -13,19 +14,21 @@ import net.neoforged.neoforge.common.NeoForge; import net.neoforged.neoforge.event.TickEvent; -@Mod(Zume.MOD_ID) +import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; + +@Mod(MOD_ID) public class NeoZume implements IZumeImplementation { public NeoZume(IEventBus modEventBus) { if (!FMLEnvironment.dist.isClient()) return; - Zume.LOGGER.info("Loading NeoZume..."); + ZumeAPI.getLogger().info("Loading NeoZume..."); NeoZumeConfigScreen.register(); - Zume.init(this, FMLPaths.CONFIGDIR.get()); - if (Zume.disabled) + ZumeAPI.registerImplementation(this, FMLPaths.CONFIGDIR.get()); + if (ZumeConfigAPI.isDisabled()) return; modEventBus.addListener(this::registerKeyBindings); @@ -64,30 +67,30 @@ private void registerKeyBindings(RegisterKeyMappingsEvent event) { private void render(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { - Zume.render(); + ZumeAPI.renderHook(); } } private void calculateFOV(ViewportEvent.ComputeFov event) { - if (Zume.shouldHookFOV()) { - event.setFOV(Zume.transformFOV(event.getFOV())); + if (ZumeAPI.isFOVHookActive()) { + event.setFOV(ZumeAPI.fovHook(event.getFOV())); } } private void calculateTurnPlayerValues(CalculatePlayerTurnEvent event) { - event.setMouseSensitivity(Zume.transformMouseSensitivity(event.getMouseSensitivity())); - event.setCinematicCameraEnabled(Zume.transformCinematicCamera(event.getCinematicCameraEnabled())); + event.setMouseSensitivity(ZumeAPI.mouseSensitivityHook(event.getMouseSensitivity())); + event.setCinematicCameraEnabled(ZumeAPI.cinematicCameraEnabledHook(event.getCinematicCameraEnabled())); } private void onMouseScroll(InputEvent.MouseScrollingEvent event) { final int scrollAmount = (int) event.getScrollDeltaY(); - if (Zume.interceptScroll(scrollAmount)) { + if (ZumeAPI.mouseScrollHook(scrollAmount)) { event.setCanceled(true); } } private void calculateDetachedCameraDistance(CalculateDetachedCameraDistanceEvent event) { - event.setDistance(Zume.transformThirdPersonDistance(event.getDistance())); + event.setDistance(ZumeAPI.thirdPersonCameraHook(event.getDistance())); } } diff --git a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java index ec1c7b17..fbc19def 100644 --- a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java @@ -1,6 +1,6 @@ package dev.nolij.zume.neoforge; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; @@ -15,7 +15,7 @@ static void register() { () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, parent) -> new Screen(Component.empty()) { @Override public void init() { - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); Minecraft.getInstance().setScreen(parent); } })); 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 d3455537..20085de6 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java @@ -1,8 +1,9 @@ package dev.nolij.zume.primitive; -import dev.nolij.zume.common.CameraPerspective; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import dev.nolij.zume.primitive.mixin.GameRendererAccessor; import dev.nolij.zume.primitive.mixin.MinecraftAccessor; import net.fabricmc.api.ClientModInitializer; @@ -17,9 +18,9 @@ public void onInitializeClient() { if (FabricLoader.getInstance().getEnvironmentType() != EnvType.CLIENT) return; - Zume.LOGGER.info("Loading Primitive Zume..."); + ZumeAPI.getLogger().info("Loading Primitive Zume..."); - Zume.init(this, FabricLoader.getInstance().getConfigDir()); + ZumeAPI.registerImplementation(this, FabricLoader.getInstance().getConfigDir()); } @Override @@ -39,13 +40,14 @@ public boolean isZoomOutPressed() { @Override public CameraPerspective getCameraPerspective() { + //noinspection UnreachableCode return MinecraftAccessor.getInstance().options.thirdPerson ? CameraPerspective.THIRD_PERSON : CameraPerspective.FIRST_PERSON; } @Override public void onZoomActivate() { //noinspection ConstantValue - if (Zume.config.enableCinematicZoom && !MinecraftAccessor.getInstance().options.cinematicMode) { + if (ZumeConfigAPI.isCinematicZoomEnabled() && !MinecraftAccessor.getInstance().options.cinematicMode) { final GameRendererAccessor gameRenderer = (GameRendererAccessor) MinecraftAccessor.getInstance().field_2818; gameRenderer.setCinematicYawSmoother(new SmoothUtil()); gameRenderer.setCinematicPitchSmoother(new SmoothUtil()); diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/event/KeyBindingRegistrar.java b/primitive/src/main/java/dev/nolij/zume/primitive/event/KeyBindingRegistrar.java index 9ddb60a2..c0940052 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/event/KeyBindingRegistrar.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/event/KeyBindingRegistrar.java @@ -1,6 +1,6 @@ package dev.nolij.zume.primitive.event; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import dev.nolij.zume.primitive.ZumeKeyBind; import net.mine_diver.unsafeevents.listener.EventListener; import net.minecraft.client.option.KeyBinding; @@ -12,7 +12,7 @@ public class KeyBindingRegistrar { @EventListener public void registerKeyBindings(KeyBindingRegisterEvent event) { - if (Zume.disabled) return; + if (ZumeConfigAPI.isDisabled()) return; final List binds = event.keyBindings; diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java b/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java index 073b2aec..dcf68cef 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java @@ -2,7 +2,7 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.class_555; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -14,35 +14,35 @@ public class GameRendererMixin { @Inject(method = "method_1844", at = @At("HEAD")) public void zume$render$HEAD(CallbackInfo ci) { - Zume.render(); + ZumeAPI.renderHook(); } @ModifyReturnValue(method = "method_1848", at = @At("TAIL")) public float zume$getFov$TAIL(float original) { - if (Zume.shouldHookFOV()) - return (float) Zume.transformFOV(original); + if (ZumeAPI.isFOVHookActive()) + return (float) ZumeAPI.fovHook(original); return original; } @ModifyExpressionValue(method = "method_1844", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;cinematicMode:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { - return Zume.transformCinematicCamera(original); + return ZumeAPI.cinematicCameraEnabledHook(original); } @ModifyExpressionValue(method = "method_1844", at = @At(value = "FIELD", target = "Lnet/minecraft/client/option/GameOptions;mouseSensitivity:F")) public float zume$updateMouse$mouseSensitivity(float original) { - return (float) Zume.transformMouseSensitivity(original); + return (float) ZumeAPI.mouseSensitivityHook(original); } @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) Zume.transformThirdPersonDistance(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) Zume.transformThirdPersonDistance(original); + return (float) ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java b/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java index f9d53806..6c46f69d 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java @@ -1,7 +1,7 @@ package dev.nolij.zume.primitive.mixin; import com.llamalad7.mixinextras.injector.WrapWithCondition; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.PlayerInventory; import org.spongepowered.asm.mixin.Mixin; @@ -12,7 +12,7 @@ public 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) { - return !Zume.interceptScroll(scrollAmount); + return !ZumeAPI.mouseScrollHook(scrollAmount); } } diff --git a/primitive/src/main/resources/zume-primitive.mixins.json b/primitive/src/main/resources/zume-primitive.mixins.json index 1598c05b..ebfbb4ec 100644 --- a/primitive/src/main/resources/zume-primitive.mixins.json +++ b/primitive/src/main/resources/zume-primitive.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.primitive.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/settings.gradle.kts b/settings.gradle.kts index 79e2ea35..5ace47d4 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -32,7 +32,7 @@ plugins { rootProject.name = "zume" include("stubs") -include("common") +include("api") include("modern") include("legacy") include("primitive") diff --git a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java index 80ec35f8..453ea053 100644 --- a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java @@ -1,17 +1,43 @@ package dev.nolij.zume; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.ZumeVariant; +import dev.nolij.zume.impl.Zume; +import dev.nolij.zume.impl.ZumeMixinPlugin; +import dev.nolij.zume.impl.ZumeVariant; 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; +import net.fabricmc.loader.impl.gui.FabricStatusTree; -public class FabricZumeBootstrapper implements ClientModInitializer { +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)"""; + + @Override + public void onPreLaunch() { + if (ZumeMixinPlugin.ZUME_VARIANT != null) + return; + + Zume.LOGGER.error(MISSING_DEPENDENCY_MESSAGE); + FabricGuiEntry.displayError("Incompatible mods found!", null, tree -> { + var tab = tree.addTab("Error"); + tab.node.addMessage(MISSING_DEPENDENCY_MESSAGE, FabricStatusTree.FabricTreeWarningLevel.ERROR); + tree.tabs.removeIf(x -> x != tab); + }, true); + } @Override public void onInitializeClient() { - switch (Zume.ZUME_VARIANT) { + if (ZumeMixinPlugin.ZUME_VARIANT == null) + return; + + switch (ZumeMixinPlugin.ZUME_VARIANT) { case ZumeVariant.MODERN -> new ModernZume().onInitializeClient(); case ZumeVariant.LEGACY -> new LegacyZume().onInitializeClient(); case ZumeVariant.PRIMITIVE -> new PrimitiveZume().onInitializeClient(); diff --git a/src/main/java/dev/nolij/zume/FabricZumePreLaunchEntrypoint.java b/src/main/java/dev/nolij/zume/FabricZumePreLaunchEntrypoint.java deleted file mode 100644 index 7996a2d8..00000000 --- a/src/main/java/dev/nolij/zume/FabricZumePreLaunchEntrypoint.java +++ /dev/null @@ -1,28 +0,0 @@ -package dev.nolij.zume; - -import dev.nolij.zume.common.Zume; -import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint; -import net.fabricmc.loader.impl.gui.FabricGuiEntry; -import net.fabricmc.loader.impl.gui.FabricStatusTree; - -public class FabricZumePreLaunchEntrypoint implements 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)"""; - - @Override - public void onPreLaunch() { - if (Zume.ZUME_VARIANT == null) { - Zume.LOGGER.error(MISSING_DEPENDENCY_MESSAGE); - FabricGuiEntry.displayError("Incompatible mods found!", null, tree -> { - var tab = tree.addTab("Error"); - tab.node.addMessage(MISSING_DEPENDENCY_MESSAGE, FabricStatusTree.FabricTreeWarningLevel.ERROR); - tree.tabs.removeIf(x -> x != tab); - }, true); - } - } - -} diff --git a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java index 8f378b82..154b01e4 100644 --- a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java @@ -1,25 +1,26 @@ package dev.nolij.zume; -import dev.nolij.zume.common.Constants; -import dev.nolij.zume.common.Zume; -import dev.nolij.zume.common.ZumeVariant; +import dev.nolij.zume.impl.ZumeMixinPlugin; +import dev.nolij.zume.impl.ZumeVariant; import dev.nolij.zume.lexforge.LexZume; import dev.nolij.zume.lexforge18.LexZume18; import dev.nolij.zume.lexforge16.LexZume16; import dev.nolij.zume.vintage.VintageZume; import net.minecraftforge.fml.common.Mod; +import static dev.nolij.zume.impl.ZumeConstants.*; + @Mod( - value = Zume.MOD_ID, - modid = Zume.MOD_ID, - name = Constants.MOD_NAME, - version = Constants.MOD_VERSION, - acceptedMinecraftVersions = Constants.VINTAGE_VERSION_RANGE, + value = MOD_ID, + modid = MOD_ID, + name = MOD_NAME, + version = MOD_VERSION, + acceptedMinecraftVersions = VINTAGE_VERSION_RANGE, guiFactory = "dev.nolij.zume.vintage.VintageConfigProvider") public class ForgeZumeBootstrapper { public ForgeZumeBootstrapper() { - if (Zume.ZUME_VARIANT == null) + 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: @@ -27,7 +28,7 @@ public ForgeZumeBootstrapper() { 8.9 - 12.2: MixinBooter >= 5.0 7.10 - 12.2: UniMixins >= 0.1.15"""); - switch (Zume.ZUME_VARIANT) { + switch (ZumeMixinPlugin.ZUME_VARIANT) { case ZumeVariant.LEXFORGE -> new LexZume(); case ZumeVariant.LEXFORGE18 -> new LexZume18(); case ZumeVariant.LEXFORGE16 -> new LexZume16(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index c4a32c04..635fd586 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -20,7 +20,7 @@ "dev.nolij.zume.FabricZumeBootstrapper" ], "preLaunch": [ - "dev.nolij.zume.FabricZumePreLaunchEntrypoint" + "dev.nolij.zume.FabricZumeBootstrapper" ], "modmenu": [ "dev.nolij.zume.modern.integration.ZumeModMenuIntegration" 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 e22a3f98..e8a556eb 100644 --- a/vintage/src/main/java/dev/nolij/zume/vintage/VintageConfigProvider.java +++ b/vintage/src/main/java/dev/nolij/zume/vintage/VintageConfigProvider.java @@ -1,6 +1,6 @@ package dev.nolij.zume.vintage; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraftforge.fml.client.IModGuiFactory; @@ -9,14 +9,17 @@ 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(), Zume.MOD_ID, false, false, "config"); + super(parentScreen, Collections.emptyList(), MOD_ID, false, false, "config"); - Zume.openConfigFile(); + ZumeAPI.openConfigFile(); } @Override 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 cc34a3fd..65268995 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.common.CameraPerspective; -import dev.nolij.zume.common.Constants; -import dev.nolij.zume.common.IZumeImplementation; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.CameraPerspective; +import dev.nolij.zume.api.platform.v0.IZumeImplementation; +import dev.nolij.zume.api.platform.v0.ZumeAPI; +import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import net.minecraft.client.Minecraft; import net.minecraft.launchwrapper.Launch; import net.minecraftforge.client.event.EntityViewRenderEvent; @@ -18,11 +18,13 @@ import java.io.File; +import static dev.nolij.zume.impl.ZumeConstants.*; + @Mod( - modid = Zume.MOD_ID, - name = Constants.MOD_NAME, - version = Constants.MOD_VERSION, - acceptedMinecraftVersions = Constants.VINTAGE_VERSION_RANGE, + modid = MOD_ID, + name = MOD_NAME, + version = MOD_VERSION, + acceptedMinecraftVersions = VINTAGE_VERSION_RANGE, guiFactory = "dev.nolij.zume.vintage.VintageConfigProvider") public class VintageZume implements IZumeImplementation { @@ -30,10 +32,10 @@ public VintageZume() { if (!FMLLaunchHandler.side().isClient()) return; - Zume.LOGGER.info("Loading Vintage Zume..."); + ZumeAPI.getLogger().info("Loading Vintage Zume..."); - Zume.init(this, new File(Launch.minecraftHome, "config").toPath()); - if (Zume.disabled) + ZumeAPI.registerImplementation(this, new File(Launch.minecraftHome, "config").toPath()); + if (ZumeConfigAPI.isDisabled()) return; for (final ZumeKeyBind keyBind : ZumeKeyBind.values()) { @@ -66,21 +68,21 @@ public CameraPerspective getCameraPerspective() { @SubscribeEvent public void render(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { - Zume.render(); + ZumeAPI.renderHook(); } } @SubscribeEvent(priority = EventPriority.LOWEST) public void calculateFOV(EntityViewRenderEvent.FOVModifier event) { - if (Zume.shouldHookFOV()) { - event.setFOV((float) Zume.transformFOV(event.getFOV())); + if (ZumeAPI.isFOVHookActive()) { + event.setFOV((float) ZumeAPI.fovHook(event.getFOV())); } } @SubscribeEvent(priority = EventPriority.HIGHEST) public void mouseEvent(MouseEvent mouseEvent) { final int scrollAmount = mouseEvent.getDwheel(); - if (Zume.interceptScroll(scrollAmount)) { + if (ZumeAPI.mouseScrollHook(scrollAmount)) { mouseEvent.setCanceled(true); } } diff --git a/vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java b/vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java index f652db32..eecfe7e3 100644 --- a/vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java +++ b/vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java @@ -1,7 +1,7 @@ package dev.nolij.zume.vintage.mixin; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; -import dev.nolij.zume.common.Zume; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.renderer.EntityRenderer; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -13,18 +13,18 @@ public class EntityRendererMixin { @ModifyExpressionValue(method = {"updateCameraAndRender", "updateRenderer"}, at = @At(value = "FIELD", target = "Lnet/minecraft/client/settings/GameSettings;smoothCamera:Z")) public boolean zume$updateMouse$smoothCameraEnabled(boolean original) { - return Zume.transformCinematicCamera(original); + return ZumeAPI.cinematicCameraEnabledHook(original); } @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) Zume.transformMouseSensitivity(original); + return (float) ZumeAPI.mouseSensitivityHook(original); } @ModifyVariable(method = "orientCamera", at = @At(value = "STORE", ordinal = 0), ordinal = 3) public double zume$orientCamera$thirdPersonDistance(double original) { - return Zume.transformThirdPersonDistance(original); + return ZumeAPI.thirdPersonCameraHook(original); } } diff --git a/vintage/src/main/resources/zume-vintage.mixins.json b/vintage/src/main/resources/zume-vintage.mixins.json index 98290d32..e397235c 100644 --- a/vintage/src/main/resources/zume-vintage.mixins.json +++ b/vintage/src/main/resources/zume-vintage.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.vintage.mixin", - "plugin": "dev.nolij.zume.common.ZumeMixinPlugin", + "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], From 8d3ffb3339ce68039f8f84fe019b100f0da5d6ee Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 22:59:06 -0400 Subject: [PATCH 05/15] allow providing alternative classloader --- .../zume/api/util/v0/MethodHandleHelper.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java b/api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java index 3ec7b637..fc94c247 100644 --- a/api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java +++ b/api/src/main/java/dev/nolij/zume/api/util/v0/MethodHandleHelper.java @@ -25,6 +25,14 @@ public static Class getClassOrNull(String className) { } } + public static Class getClassOrNull(ClassLoader classLoader, String className) { + try { + return Class.forName(className, true, classLoader); + } catch (ClassNotFoundException ignored) { + return null; + } + } + public static Class getClassOrNull(String... classNames) { for (final String className : classNames) { try { @@ -35,6 +43,16 @@ public static Class getClassOrNull(String... classNames) { return null; } + public static Class getClassOrNull(ClassLoader classLoader, String... classNames) { + for (final String className : classNames) { + try { + return Class.forName(className, true, classLoader); + } catch (ClassNotFoundException ignored) { } + } + + return null; + } + public static MethodHandle getMethodOrNull(Class clazz, String methodName, Class... parameterTypes) { if (clazz == null) return null; From 2088ccd7f858d96dd0072635e3e410102381ca70 Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 22:59:15 -0400 Subject: [PATCH 06/15] cleanup --- .../src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java | 1 + src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 20085de6..cb8add27 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java @@ -25,6 +25,7 @@ public void onInitializeClient() { @Override public boolean isZoomPressed() { + //noinspection UnreachableCode return MinecraftAccessor.getInstance().currentScreen == null && ZumeKeyBind.ZOOM.isPressed(); } diff --git a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java index 453ea053..75d7c692 100644 --- a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java @@ -36,7 +36,7 @@ public void onPreLaunch() { public void onInitializeClient() { if (ZumeMixinPlugin.ZUME_VARIANT == null) return; - + switch (ZumeMixinPlugin.ZUME_VARIANT) { case ZumeVariant.MODERN -> new ModernZume().onInitializeClient(); case ZumeVariant.LEGACY -> new LegacyZume().onInitializeClient(); From 98794aa4129dd3dc307a6fe706d7680d9bc86a92 Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 22:59:25 -0400 Subject: [PATCH 07/15] enable stacktrace for CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a820fae2..9c80916e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,7 +15,7 @@ jobs: with: cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - name: :build - run: ./gradlew build + run: ./gradlew build --stacktrace - name: Upload artifacts uses: actions/upload-artifact@v3 with: From dd98e61f4e0207d63c3e792572e76f1ea0f73b58 Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 22:59:44 -0400 Subject: [PATCH 08/15] 20.5 is out now --- build.gradle.kts | 2 -- 1 file changed, 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 762ba24e..94d0deb2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -557,8 +557,6 @@ afterEvaluate { snapshots = HashSet() } - snapshots.add("1.20.5-Snapshot") - minecraftVersions.addAll(snapshots) } From a3e9cd6c58595f5d21df0187ed6c23682ce3a0ea Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 23:00:27 -0400 Subject: [PATCH 09/15] java 21 support --- build.gradle.kts | 6 +++--- settings.gradle.kts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 94d0deb2..123e1c98 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -151,16 +151,16 @@ allprojects { tasks.withType { if (name !in arrayOf("compileMcLauncherJava", "compilePatchedMcJava")) { options.encoding = "UTF-8" - sourceCompatibility = "17" + sourceCompatibility = "21" options.release = 8 javaCompiler = javaToolchains.compilerFor { - languageVersion = JavaLanguageVersion.of(17) + languageVersion = JavaLanguageVersion.of(21) } } } dependencies { - val jabelDependency = "com.github.bsideup.jabel:jabel-javac-plugin:${"jabel_version"()}" + val jabelDependency = "com.pkware.jabel:jabel-javac-plugin:${"jabel_version"()}" annotationProcessor(jabelDependency) compileOnly(jabelDependency) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 5ace47d4..18c036ef 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -22,7 +22,7 @@ buildscript { plugins { id("org.gradle.toolchains.foojay-resolver-convention") version("0.7.0") - id("xyz.wagyourtail.unimined") version("1.2.0-SNAPSHOT") apply(false) + id("xyz.wagyourtail.unimined") version("1.2.3") apply(false) id("com.github.gmazzo.buildconfig") version("5.2.0") apply(false) id("com.github.johnrengelman.shadow") version("8.1.1") apply(false) id("me.modmuss50.mod-publish-plugin") version("0.4.5") apply(false) From 15c01d7ab81b3b4970682af2320fbc62c32f4d8c Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 23:02:40 -0400 Subject: [PATCH 10/15] fix NeoForge 20.5+ --- gradle.properties | 7 +-- neoforge/build.gradle.kts | 6 ++- .../java/dev/nolij/zume/neoforge/NeoZume.java | 50 +++++++++++++++++-- .../zume/neoforge/NeoZumeConfigScreen.java | 25 +++++----- .../neoforge/NeoZumeConfigScreenFactory.java | 15 ++++++ 5 files changed, 83 insertions(+), 20 deletions(-) create mode 100644 neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreenFactory.java diff --git a/gradle.properties b/gradle.properties index f11f5a7d..35d84c55 100644 --- a/gradle.properties +++ b/gradle.properties @@ -50,9 +50,10 @@ station_api_version = 261e793 forge_minecraft_range = [1.14,) ## NeoForge -neoforge_minecraft_version = 1.20.4 +# https://projects.neoforged.net/neoforged/neoforge +neoforge_minecraft_version = 1.20.5 neoforge_minecraft_range = [1.20.4,) -neoforge_version = 195 +neoforge_version = 0-beta neoforge_neoforge_range = [20.4.195,) neoforge_parchment_version = 2024.02.25 @@ -94,7 +95,7 @@ mixinbooter_version = 9.1 # Misc Dependencies # https://central.sonatype.com/artifact/com.github.bsideup.jabel/jabel-javac-plugin -jabel_version = 1.0.0 +jabel_version = 1.0.1-1 # https://central.sonatype.com/artifact/blue.endless/jankson/overview jankson_version = 1.2.3 # https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core diff --git a/neoforge/build.gradle.kts b/neoforge/build.gradle.kts index e947c799..b6092a07 100644 --- a/neoforge/build.gradle.kts +++ b/neoforge/build.gradle.kts @@ -15,9 +15,13 @@ unimined.minecraft { loader("neoforge_version"()) } + source { + sourceGenerator.jvmArgs = listOf("-Xmx4G") + } + mappings { mojmap() - parchment(mcVersion = "neoforge_minecraft_version"(), version = "neoforge_parchment_version"()) +// parchment(mcVersion = "neoforge_minecraft_version"(), version = "neoforge_parchment_version"()) } defaultRemapJar = true 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 b8f0a1be..2ebb2cbc 100644 --- a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZume.java @@ -4,28 +4,72 @@ import dev.nolij.zume.api.platform.v0.IZumeImplementation; import dev.nolij.zume.api.platform.v0.ZumeAPI; import dev.nolij.zume.api.config.v0.ZumeConfigAPI; +import dev.nolij.zume.api.util.v0.MethodHandleHelper; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; import net.neoforged.bus.api.EventPriority; import net.neoforged.bus.api.IEventBus; +import net.neoforged.fml.ModContainer; 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 net.neoforged.neoforge.event.TickEvent; +import java.lang.invoke.MethodHandle; +import java.lang.reflect.InvocationTargetException; +import java.util.function.BiFunction; +import java.util.function.Supplier; + import static dev.nolij.zume.impl.ZumeConstants.MOD_ID; @Mod(MOD_ID) public class NeoZume implements IZumeImplementation { - public NeoZume(IEventBus modEventBus) { + private static final Class CONFIG_SCREEN_EXT_INTERFACE = MethodHandleHelper.getClassOrNull( + NeoZume.class.getClassLoader(), "net.neoforged.neoforge.client.gui.IConfigScreenFactory"); + private static final Class CONFIG_SCREEN_EXT_RECORD = MethodHandleHelper.getClassOrNull( + NeoZume.class.getClassLoader(), "net.neoforged.neoforge.client.ConfigScreenHandler$ConfigScreenFactory"); + private static final Class CONFIG_SCREEN_EXT = MethodHandleHelper.firstNonNull( + CONFIG_SCREEN_EXT_INTERFACE, + CONFIG_SCREEN_EXT_RECORD + ); + private static final MethodHandle REGISTER_EXT_POINT = MethodHandleHelper.getMethodOrNull( + ModContainer.class, + "registerExtensionPoint", + Class.class, Supplier.class + ); + + public NeoZume(IEventBus modEventBus, ModContainer modContainer) { if (!FMLEnvironment.dist.isClient()) return; ZumeAPI.getLogger().info("Loading NeoZume..."); - NeoZumeConfigScreen.register(); + try { + REGISTER_EXT_POINT.invokeExact(modContainer, CONFIG_SCREEN_EXT, (Supplier) () -> { + try { + if (CONFIG_SCREEN_EXT_RECORD == null) { + return NeoZumeConfigScreenFactory.class.getDeclaredConstructor().newInstance(); + } else { + return CONFIG_SCREEN_EXT_RECORD + .getDeclaredConstructor(BiFunction.class) + .newInstance((BiFunction) (minecraft, parent) -> + new NeoZumeConfigScreen(parent)); + } + } catch (InstantiationException | IllegalAccessException | + InvocationTargetException | NoSuchMethodException e) { + throw new AssertionError(e); + } + }); + } catch (Throwable e) { + throw new AssertionError(e); + } ZumeAPI.registerImplementation(this, FMLPaths.CONFIGDIR.get()); if (ZumeConfigAPI.isDisabled()) diff --git a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java index fbc19def..31429b42 100644 --- a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreen.java @@ -4,21 +4,20 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.gui.screens.Screen; import net.minecraft.network.chat.Component; -import net.neoforged.fml.ModLoadingContext; -import net.neoforged.neoforge.client.ConfigScreenHandler; -final class NeoZumeConfigScreen { +final class NeoZumeConfigScreen extends Screen { - static void register() { - ModLoadingContext.get().registerExtensionPoint( - ConfigScreenHandler.ConfigScreenFactory.class, - () -> new ConfigScreenHandler.ConfigScreenFactory((minecraft, parent) -> new Screen(Component.empty()) { - @Override - public void init() { - ZumeAPI.openConfigFile(); - Minecraft.getInstance().setScreen(parent); - } - })); + private final Screen parent; + + public NeoZumeConfigScreen(Screen parent) { + super(Component.empty()); + this.parent = parent; + } + + @Override + public void init() { + ZumeAPI.openConfigFile(); + Minecraft.getInstance().setScreen(parent); } } diff --git a/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreenFactory.java b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreenFactory.java new file mode 100644 index 00000000..d51d6afa --- /dev/null +++ b/neoforge/src/main/java/dev/nolij/zume/neoforge/NeoZumeConfigScreenFactory.java @@ -0,0 +1,15 @@ +package dev.nolij.zume.neoforge; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.screens.Screen; +import net.neoforged.neoforge.client.gui.IConfigScreenFactory; +import org.jetbrains.annotations.NotNull; + +public class NeoZumeConfigScreenFactory implements IConfigScreenFactory { + + @Override + public @NotNull Screen createScreen(@NotNull Minecraft minecraft, @NotNull Screen parent) { + return new NeoZumeConfigScreen(parent); + } + +} From f03bd11f9338cbaf169960d5df7e032711215dbf Mon Sep 17 00:00:00 2001 From: Nolij Date: Wed, 24 Apr 2024 23:02:46 -0400 Subject: [PATCH 11/15] update CHANGELOG.md --- CHANGELOG.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 281c75ca..f3c5063c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,3 @@ -- added support for NeoForge 20.5+ -- made missing dependencies error on Fabric more user-friendly -- improved mod compatibility by using events on LexForge for mc17-mc18.2 -- added explicit incompatibility with outdated versions of Embeddium++ which were causing obscure crashes +- fixed crash on NeoForge 20.5+ +- many internal refactors - further improvements to overall system stability and other minor adjustments have been made to enhance the user experience \ No newline at end of file From 16c6a46d2937e577b53e9646ce8bd57661e99a85 Mon Sep 17 00:00:00 2001 From: Nolij Date: Thu, 25 Apr 2024 20:15:05 -0400 Subject: [PATCH 12/15] repackage all mixins in preparation to merge mixin configs and refmaps --- .../java/dev/nolij/zume/impl/ZumeMixinPlugin.java | 2 +- .../java/dev/nolij/zume/archaic/ArchaicZume.java | 2 +- .../archaic}/EntityRendererAccessor.java | 2 +- .../mixin => mixin/archaic}/EntityRendererMixin.java | 2 +- archaic/src/main/resources/zume-archaic.mixins.json | 6 +++--- .../main/java/dev/nolij/zume/legacy/LegacyZume.java | 2 +- .../mixin => mixin/legacy}/GameOptionsMixin.java | 2 +- .../mixin => mixin/legacy}/GameRendererAccessor.java | 2 +- .../mixin => mixin/legacy}/GameRendererMixin.java | 2 +- .../mixin => mixin/legacy}/KeyBindingMixin.java | 2 +- .../mixin => mixin/legacy}/MinecraftClientMixin.java | 2 +- legacy/src/main/resources/zume-legacy.mixins.json | 12 ++++++------ .../mixin => mixin/lexforge}/CameraMixin.java | 2 +- .../mixin => mixin/lexforge}/MouseHandlerMixin.java | 2 +- .../src/main/resources/zume-lexforge.mixins.json | 6 +++--- .../nolij/zume/mixin/lexforge16}/CameraMixin.java | 2 +- .../lexforge16}/MouseHandlerMixin.java | 2 +- .../src/main/resources/zume-lexforge16.mixins.json | 6 +++--- .../nolij/zume/mixin/lexforge18}/CameraMixin.java | 2 +- .../lexforge18}/MouseHandlerMixin.java | 2 +- .../src/main/resources/zume-lexforge18.mixins.json | 6 +++--- .../{modern/mixin => mixin/modern}/CameraMixin.java | 2 +- .../mixin => mixin/modern}/GameRendererMixin.java | 2 +- .../{modern/mixin => mixin/modern}/MouseMixin.java | 2 +- modern/src/main/resources/zume-modern.mixins.json | 8 ++++---- .../primitive}/GameRendererAccessor.java | 2 +- .../mixin => mixin/primitive}/GameRendererMixin.java | 2 +- .../mixin => mixin/primitive}/MinecraftAccessor.java | 2 +- .../mixin => mixin/primitive}/MinecraftMixin.java | 2 +- .../java/dev/nolij/zume/primitive/PrimitiveZume.java | 4 ++-- .../src/main/resources/zume-primitive.mixins.json | 10 +++++----- .../mixin => mixin/vintage}/EntityRendererMixin.java | 2 +- vintage/src/main/resources/zume-vintage.mixins.json | 4 ++-- 33 files changed, 55 insertions(+), 55 deletions(-) rename archaic/src/main/java/dev/nolij/zume/{archaic/mixin => mixin/archaic}/EntityRendererAccessor.java (95%) rename archaic/src/main/java/dev/nolij/zume/{archaic/mixin => mixin/archaic}/EntityRendererMixin.java (98%) rename legacy/src/main/java/dev/nolij/zume/{legacy/mixin => mixin/legacy}/GameOptionsMixin.java (96%) rename legacy/src/main/java/dev/nolij/zume/{legacy/mixin => mixin/legacy}/GameRendererAccessor.java (95%) rename legacy/src/main/java/dev/nolij/zume/{legacy/mixin => mixin/legacy}/GameRendererMixin.java (98%) rename legacy/src/main/java/dev/nolij/zume/{legacy/mixin => mixin/legacy}/KeyBindingMixin.java (96%) rename legacy/src/main/java/dev/nolij/zume/{legacy/mixin => mixin/legacy}/MinecraftClientMixin.java (95%) rename lexforge/src/main/java/dev/nolij/zume/{lexforge/mixin => mixin/lexforge}/CameraMixin.java (93%) rename lexforge/src/main/java/dev/nolij/zume/{lexforge/mixin => mixin/lexforge}/MouseHandlerMixin.java (96%) rename {lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin => lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16}/CameraMixin.java (92%) rename lexforge16/src/main/java/dev/nolij/zume/{lexforge16/mixin => mixin/lexforge16}/MouseHandlerMixin.java (95%) rename {lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin => lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18}/CameraMixin.java (92%) rename lexforge18/src/main/java/dev/nolij/zume/{lexforge18/mixin => mixin/lexforge18}/MouseHandlerMixin.java (95%) rename modern/src/main/java/dev/nolij/zume/{modern/mixin => mixin/modern}/CameraMixin.java (93%) rename modern/src/main/java/dev/nolij/zume/{modern/mixin => mixin/modern}/GameRendererMixin.java (95%) rename modern/src/main/java/dev/nolij/zume/{modern/mixin => mixin/modern}/MouseMixin.java (98%) rename primitive/src/main/java/dev/nolij/zume/{primitive/mixin => mixin/primitive}/GameRendererAccessor.java (90%) rename primitive/src/main/java/dev/nolij/zume/{primitive/mixin => mixin/primitive}/GameRendererMixin.java (97%) rename primitive/src/main/java/dev/nolij/zume/{primitive/mixin => mixin/primitive}/MinecraftAccessor.java (87%) rename primitive/src/main/java/dev/nolij/zume/{primitive/mixin => mixin/primitive}/MinecraftMixin.java (94%) rename vintage/src/main/java/dev/nolij/zume/{vintage/mixin => mixin/vintage}/EntityRendererMixin.java (97%) diff --git a/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java b/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java index 47d9f142..86cb87a4 100644 --- a/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java +++ b/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java @@ -58,7 +58,7 @@ else if (major > 25) } if (ZUME_VARIANT != null) - implementationMixinPackage = "dev.nolij.zume." + ZUME_VARIANT + ".mixin."; + implementationMixinPackage = "dev.nolij.zume.mixin." + ZUME_VARIANT + "."; else implementationMixinPackage = null; } 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 f3ef0d1c..312c1673 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java +++ b/archaic/src/main/java/dev/nolij/zume/archaic/ArchaicZume.java @@ -7,7 +7,7 @@ import dev.nolij.zume.api.platform.v0.IZumeImplementation; import dev.nolij.zume.api.platform.v0.ZumeAPI; import dev.nolij.zume.api.config.v0.ZumeConfigAPI; -import dev.nolij.zume.archaic.mixin.EntityRendererAccessor; +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; diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererAccessor.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java similarity index 95% rename from archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererAccessor.java rename to archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java index b3986097..3792c800 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererAccessor.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererAccessor.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.archaic.mixin; +package dev.nolij.zume.mixin.archaic; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.util.MouseFilter; diff --git a/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java similarity index 98% rename from archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java rename to archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java index 2d93d78f..e0d3c483 100644 --- a/archaic/src/main/java/dev/nolij/zume/archaic/mixin/EntityRendererMixin.java +++ b/archaic/src/main/java/dev/nolij/zume/mixin/archaic/EntityRendererMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.archaic.mixin; +package dev.nolij.zume.mixin.archaic; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; diff --git a/archaic/src/main/resources/zume-archaic.mixins.json b/archaic/src/main/resources/zume-archaic.mixins.json index 9ac6f3f4..3a781b76 100644 --- a/archaic/src/main/resources/zume-archaic.mixins.json +++ b/archaic/src/main/resources/zume-archaic.mixins.json @@ -1,14 +1,14 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.archaic.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "EntityRendererAccessor", - "EntityRendererMixin" + "archaic.EntityRendererAccessor", + "archaic.EntityRendererMixin" ], "injectors": { "defaultRequire": 1 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 f31377a4..1214ad7b 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java +++ b/legacy/src/main/java/dev/nolij/zume/legacy/LegacyZume.java @@ -4,7 +4,7 @@ import dev.nolij.zume.api.platform.v0.IZumeImplementation; import dev.nolij.zume.api.platform.v0.ZumeAPI; import dev.nolij.zume.api.config.v0.ZumeConfigAPI; -import dev.nolij.zume.legacy.mixin.GameRendererAccessor; +import dev.nolij.zume.mixin.legacy.GameRendererAccessor; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameOptionsMixin.java similarity index 96% rename from legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java rename to legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameOptionsMixin.java index 7978414d..d1964dce 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameOptionsMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameOptionsMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.legacy.mixin; +package dev.nolij.zume.mixin.legacy; import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import dev.nolij.zume.legacy.ZumeKeyBind; diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererAccessor.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java similarity index 95% rename from legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererAccessor.java rename to legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java index 5e839292..462f6d8f 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererAccessor.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererAccessor.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.legacy.mixin; +package dev.nolij.zume.mixin.legacy; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.util.SmoothUtil; diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java similarity index 98% rename from legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java rename to legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java index b53478bf..706b8b82 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/GameRendererMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/GameRendererMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.legacy.mixin; +package dev.nolij.zume.mixin.legacy; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java similarity index 96% rename from legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java rename to legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java index 645e1f25..5494338c 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/KeyBindingMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/KeyBindingMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.legacy.mixin; +package dev.nolij.zume.mixin.legacy; import dev.nolij.zume.api.config.v0.ZumeConfigAPI; import net.minecraft.client.option.KeyBinding; diff --git a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/MinecraftClientMixin.java similarity index 95% rename from legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java rename to legacy/src/main/java/dev/nolij/zume/mixin/legacy/MinecraftClientMixin.java index dc601359..5e2f704a 100644 --- a/legacy/src/main/java/dev/nolij/zume/legacy/mixin/MinecraftClientMixin.java +++ b/legacy/src/main/java/dev/nolij/zume/mixin/legacy/MinecraftClientMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.legacy.mixin; +package dev.nolij.zume.mixin.legacy; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import dev.nolij.zume.api.platform.v0.ZumeAPI; diff --git a/legacy/src/main/resources/zume-legacy.mixins.json b/legacy/src/main/resources/zume-legacy.mixins.json index 7cb5b80e..419ff27c 100644 --- a/legacy/src/main/resources/zume-legacy.mixins.json +++ b/legacy/src/main/resources/zume-legacy.mixins.json @@ -1,17 +1,17 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.legacy.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "MinecraftClientMixin", - "GameOptionsMixin", - "GameRendererAccessor", - "GameRendererMixin", - "KeyBindingMixin" + "legacy.MinecraftClientMixin", + "legacy.GameOptionsMixin", + "legacy.GameRendererAccessor", + "legacy.GameRendererMixin", + "legacy.KeyBindingMixin" ], "injectors": { "defaultRequire": 1 diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java similarity index 93% rename from lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java rename to lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java index e7f5bf33..dc7ed09e 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/CameraMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/CameraMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.lexforge.mixin; +package dev.nolij.zume.mixin.lexforge; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Camera; diff --git a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java similarity index 96% rename from lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java rename to lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java index 7604981f..2558944e 100644 --- a/lexforge/src/main/java/dev/nolij/zume/lexforge/mixin/MouseHandlerMixin.java +++ b/lexforge/src/main/java/dev/nolij/zume/mixin/lexforge/MouseHandlerMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.lexforge.mixin; +package dev.nolij.zume.mixin.lexforge; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MouseHandler; diff --git a/lexforge/src/main/resources/zume-lexforge.mixins.json b/lexforge/src/main/resources/zume-lexforge.mixins.json index b9f1139f..900a072c 100644 --- a/lexforge/src/main/resources/zume-lexforge.mixins.json +++ b/lexforge/src/main/resources/zume-lexforge.mixins.json @@ -1,14 +1,14 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.lexforge.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "CameraMixin", - "MouseHandlerMixin" + "lexforge.CameraMixin", + "lexforge.MouseHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java similarity index 92% rename from lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java rename to lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java index efe1db4a..d0c1d694 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/CameraMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/CameraMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.lexforge18.mixin; +package dev.nolij.zume.mixin.lexforge16; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Camera; diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java similarity index 95% rename from lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java rename to lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java index 610d3fa5..0ffdab2a 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/MouseHandlerMixin.java +++ b/lexforge16/src/main/java/dev/nolij/zume/mixin/lexforge16/MouseHandlerMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.lexforge16.mixin; +package dev.nolij.zume.mixin.lexforge16; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MouseHandler; diff --git a/lexforge16/src/main/resources/zume-lexforge16.mixins.json b/lexforge16/src/main/resources/zume-lexforge16.mixins.json index 391feda5..4afb676d 100644 --- a/lexforge16/src/main/resources/zume-lexforge16.mixins.json +++ b/lexforge16/src/main/resources/zume-lexforge16.mixins.json @@ -1,14 +1,14 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.lexforge16.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "CameraMixin", - "MouseHandlerMixin" + "lexforge16.CameraMixin", + "lexforge16.MouseHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java similarity index 92% rename from lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java rename to lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java index 63ffad4c..1b09ea0c 100644 --- a/lexforge16/src/main/java/dev/nolij/zume/lexforge16/mixin/CameraMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/CameraMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.lexforge16.mixin; +package dev.nolij.zume.mixin.lexforge18; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.Camera; diff --git a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java similarity index 95% rename from lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java rename to lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java index 6631351d..8125f4a6 100644 --- a/lexforge18/src/main/java/dev/nolij/zume/lexforge18/mixin/MouseHandlerMixin.java +++ b/lexforge18/src/main/java/dev/nolij/zume/mixin/lexforge18/MouseHandlerMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.lexforge18.mixin; +package dev.nolij.zume.mixin.lexforge18; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.MouseHandler; diff --git a/lexforge18/src/main/resources/zume-lexforge18.mixins.json b/lexforge18/src/main/resources/zume-lexforge18.mixins.json index b80e45ec..8b63e5e3 100644 --- a/lexforge18/src/main/resources/zume-lexforge18.mixins.json +++ b/lexforge18/src/main/resources/zume-lexforge18.mixins.json @@ -1,14 +1,14 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.lexforge18.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "CameraMixin", - "MouseHandlerMixin" + "lexforge18.CameraMixin", + "lexforge18.MouseHandlerMixin" ], "injectors": { "defaultRequire": 1 diff --git a/modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java similarity index 93% rename from modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java rename to modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java index 2107e139..378b20f4 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/mixin/CameraMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/CameraMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.modern.mixin; +package dev.nolij.zume.mixin.modern; import dev.nolij.zume.api.platform.v0.ZumeAPI; import net.minecraft.client.render.Camera; diff --git a/modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java similarity index 95% rename from modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java rename to modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java index 81f96260..eca44759 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/mixin/GameRendererMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/GameRendererMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.modern.mixin; +package dev.nolij.zume.mixin.modern; import com.llamalad7.mixinextras.injector.ModifyReturnValue; import dev.nolij.zume.api.platform.v0.ZumeAPI; diff --git a/modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java similarity index 98% rename from modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java rename to modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java index f86d3fe4..a203452f 100644 --- a/modern/src/main/java/dev/nolij/zume/modern/mixin/MouseMixin.java +++ b/modern/src/main/java/dev/nolij/zume/mixin/modern/MouseMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.modern.mixin; +package dev.nolij.zume.mixin.modern; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; diff --git a/modern/src/main/resources/zume-modern.mixins.json b/modern/src/main/resources/zume-modern.mixins.json index 95145daf..17e97b97 100644 --- a/modern/src/main/resources/zume-modern.mixins.json +++ b/modern/src/main/resources/zume-modern.mixins.json @@ -1,15 +1,15 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.modern.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "CameraMixin", - "GameRendererMixin", - "MouseMixin" + "modern.CameraMixin", + "modern.GameRendererMixin", + "modern.MouseMixin" ], "injectors": { "defaultRequire": 1 diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererAccessor.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java similarity index 90% rename from primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererAccessor.java rename to primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java index 64ba8ad6..caf9094a 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererAccessor.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererAccessor.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.primitive.mixin; +package dev.nolij.zume.mixin.primitive; import net.minecraft.class_555; import net.minecraft.client.util.SmoothUtil; diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java similarity index 97% rename from primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java rename to primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java index dcf68cef..7df7c8e8 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/GameRendererMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/GameRendererMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.primitive.mixin; +package dev.nolij.zume.mixin.primitive; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.ModifyReturnValue; diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftAccessor.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftAccessor.java similarity index 87% rename from primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftAccessor.java rename to primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftAccessor.java index aec4b00c..62832f59 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftAccessor.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftAccessor.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.primitive.mixin; +package dev.nolij.zume.mixin.primitive; import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; diff --git a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java similarity index 94% rename from primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java rename to primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java index 6c46f69d..ae827d93 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/mixin/MinecraftMixin.java +++ b/primitive/src/main/java/dev/nolij/zume/mixin/primitive/MinecraftMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.primitive.mixin; +package dev.nolij.zume.mixin.primitive; import com.llamalad7.mixinextras.injector.WrapWithCondition; import dev.nolij.zume.api.platform.v0.ZumeAPI; 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 cb8add27..1f2286ad 100644 --- a/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java +++ b/primitive/src/main/java/dev/nolij/zume/primitive/PrimitiveZume.java @@ -4,8 +4,8 @@ import dev.nolij.zume.api.platform.v0.IZumeImplementation; import dev.nolij.zume.api.platform.v0.ZumeAPI; import dev.nolij.zume.api.config.v0.ZumeConfigAPI; -import dev.nolij.zume.primitive.mixin.GameRendererAccessor; -import dev.nolij.zume.primitive.mixin.MinecraftAccessor; +import dev.nolij.zume.mixin.primitive.GameRendererAccessor; +import dev.nolij.zume.mixin.primitive.MinecraftAccessor; import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.EnvType; import net.fabricmc.loader.api.FabricLoader; diff --git a/primitive/src/main/resources/zume-primitive.mixins.json b/primitive/src/main/resources/zume-primitive.mixins.json index ebfbb4ec..8248afc4 100644 --- a/primitive/src/main/resources/zume-primitive.mixins.json +++ b/primitive/src/main/resources/zume-primitive.mixins.json @@ -1,16 +1,16 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.primitive.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "GameRendererAccessor", - "GameRendererMixin", - "MinecraftAccessor", - "MinecraftMixin" + "primitive.GameRendererAccessor", + "primitive.GameRendererMixin", + "primitive.MinecraftAccessor", + "primitive.MinecraftMixin" ], "injectors": { "defaultRequire": 1 diff --git a/vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java similarity index 97% rename from vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java rename to vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java index eecfe7e3..0b062fc7 100644 --- a/vintage/src/main/java/dev/nolij/zume/vintage/mixin/EntityRendererMixin.java +++ b/vintage/src/main/java/dev/nolij/zume/mixin/vintage/EntityRendererMixin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.vintage.mixin; +package dev.nolij.zume.mixin.vintage; import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import dev.nolij.zume.api.platform.v0.ZumeAPI; diff --git a/vintage/src/main/resources/zume-vintage.mixins.json b/vintage/src/main/resources/zume-vintage.mixins.json index e397235c..651766b1 100644 --- a/vintage/src/main/resources/zume-vintage.mixins.json +++ b/vintage/src/main/resources/zume-vintage.mixins.json @@ -1,13 +1,13 @@ { "required": true, "minVersion": "0.8", - "package": "dev.nolij.zume.vintage.mixin", + "package": "dev.nolij.zume.mixin", "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], "client": [ - "EntityRendererMixin" + "vintage.EntityRendererMixin" ], "injectors": { "defaultRequire": 1 From 4d05381ef0326ca039a6cbb3628a8b3c6fa11137 Mon Sep 17 00:00:00 2001 From: Nolij Date: Thu, 25 Apr 2024 21:09:17 -0400 Subject: [PATCH 13/15] merge all mixin configs and refmaps --- build.gradle.kts | 82 +++++++++++++++++++++++++++++- src/main/resources/fabric.mod.json | 6 +-- 2 files changed, 82 insertions(+), 6 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 123e1c98..063f8062 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,4 +1,6 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +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 kotlinx.serialization.encodeToString @@ -12,6 +14,8 @@ import okhttp3.MultipartBody import okhttp3.Request import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.internal.immutableListOf +import org.apache.tools.zip.ZipEntry +import org.apache.tools.zip.ZipOutputStream import org.objectweb.asm.ClassReader import org.objectweb.asm.ClassWriter import org.objectweb.asm.tree.ClassNode @@ -313,7 +317,83 @@ tasks.jar { enabled = false } +class MixinConfigMergingTransformer : Transformer { + private val JSON = JsonSlurper() + + @Input lateinit var modId: String + @Input lateinit var packageName: String + @Input lateinit var mixinPlugin: String + + override fun getName(): String { + return "MixinConfigMergingTransformer" + } + + override fun canTransformResource(element: FileTreeElement?): Boolean { + return element != null && (element.name.endsWith(".mixins.json") || element.name.endsWith("-refmap.json")) + } + + private var transformed = false + + private var mixins = ArrayList() + private var refMaps = HashMap>() + + override fun transform(context: TransformerContext?) { + if (context == null) + return + + this.transformed = true + + val parsed = JSON.parse(context.`is`) as Map<*, *> + if (parsed.contains("client")) { + @Suppress("UNCHECKED_CAST") + mixins.addAll(parsed["client"] as List) + } else { + @Suppress("UNCHECKED_CAST") + refMaps.putAll(parsed["mappings"] as Map>) + } + } + + override fun hasTransformedResource(): Boolean { + return transformed + } + + 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", + "mixins" to emptyList(), + "client" to mixins, + "injectors" to mapOf( + "defaultRequire" to 1, + ), + "refmap" to "${modId}-refmap.json", + ))).toByteArray()) + + val refMapEntry = ZipEntry("${modId}-refmap.json") + os.putNextEntry(refMapEntry) + os.write(JsonOutput.prettyPrint(JsonOutput.toJson(mapOf( + "mappings" to refMaps, + ))).toByteArray()) + + transformed = false + mixins.clear() + refMaps.clear() + } + +} + tasks.shadowJar { + transform(MixinConfigMergingTransformer::class.java) { + modId = "mod_id"() + packageName = "dev.nolij.zume.mixin" + mixinPlugin = "dev.nolij.zume.impl.ZumeMixinPlugin" + } + val shadowJar = this from("LICENSE") { rename { "${it}_${"mod_id"()}" } @@ -358,7 +438,7 @@ tasks.shadowJar { attributes( "FMLCorePluginContainsFMLMod" to true, "ForceLoadAsMod" to true, - "MixinConfigs" to lexForgeImpls.joinToString(",") { "zume-${it}.mixins.json" }, + "MixinConfigs" to "zume.mixins.json", "TweakClass" to "org.spongepowered.asm.launch.MixinTweaker", ) } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 635fd586..b8f0291d 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -29,11 +29,7 @@ "dev.nolij.zume.primitive.event.KeyBindingRegistrar" ] }, - "mixins": [ - "zume-modern.mixins.json", - "zume-legacy.mixins.json", - "zume-primitive.mixins.json" - ], + "mixins": ["zume.mixins.json"], "depends": { "fabricloader": [">=${fabric_version}", "${babric_version}"] } From efa09b97d6c86c7a2bb05021d5ce01333c5d13db Mon Sep 17 00:00:00 2001 From: Nolij Date: Thu, 25 Apr 2024 21:27:02 -0400 Subject: [PATCH 14/15] move mixin plugin and variant detection to root project --- .../main/java/dev/nolij/zume/impl/ZumeVariant.java | 14 -------------- .../src/main/resources/zume-archaic.mixins.json | 1 - build.gradle.kts | 2 +- legacy/src/main/resources/zume-legacy.mixins.json | 1 - .../src/main/resources/zume-lexforge.mixins.json | 1 - .../src/main/resources/zume-lexforge16.mixins.json | 1 - .../src/main/resources/zume-lexforge18.mixins.json | 1 - modern/src/main/resources/zume-modern.mixins.json | 1 - .../src/main/resources/zume-primitive.mixins.json | 1 - .../dev/nolij/zume/FabricZumeBootstrapper.java | 6 ++---- .../java/dev/nolij/zume/ForgeZumeBootstrapper.java | 2 -- .../main/java/dev/nolij/zume}/ZumeMixinPlugin.java | 6 +++--- src/main/java/dev/nolij/zume/ZumeVariant.java | 14 ++++++++++++++ .../src/main/resources/zume-vintage.mixins.json | 1 - 14 files changed, 20 insertions(+), 32 deletions(-) delete mode 100644 api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java rename {api/src/main/java/dev/nolij/zume/impl => src/main/java/dev/nolij/zume}/ZumeMixinPlugin.java (95%) create mode 100644 src/main/java/dev/nolij/zume/ZumeVariant.java diff --git a/api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java b/api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java deleted file mode 100644 index ccdd609e..00000000 --- a/api/src/main/java/dev/nolij/zume/impl/ZumeVariant.java +++ /dev/null @@ -1,14 +0,0 @@ -package dev.nolij.zume.impl; - -public final class ZumeVariant { - - public static final String MODERN = "modern"; - public static final String PRIMITIVE = "primitive"; - public static final String LEGACY = "legacy"; - public static final String ARCHAIC_FORGE = "archaic"; - public static final String VINTAGE_FORGE = "vintage"; - public static final String LEXFORGE = "lexforge"; - public static final String LEXFORGE18 = "lexforge18"; - public static final String LEXFORGE16 = "lexforge16"; - -} diff --git a/archaic/src/main/resources/zume-archaic.mixins.json b/archaic/src/main/resources/zume-archaic.mixins.json index 3a781b76..b9fa6f1c 100644 --- a/archaic/src/main/resources/zume-archaic.mixins.json +++ b/archaic/src/main/resources/zume-archaic.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/build.gradle.kts b/build.gradle.kts index 063f8062..2bb946e8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -391,7 +391,7 @@ tasks.shadowJar { transform(MixinConfigMergingTransformer::class.java) { modId = "mod_id"() packageName = "dev.nolij.zume.mixin" - mixinPlugin = "dev.nolij.zume.impl.ZumeMixinPlugin" + mixinPlugin = "dev.nolij.zume.ZumeMixinPlugin" } val shadowJar = this diff --git a/legacy/src/main/resources/zume-legacy.mixins.json b/legacy/src/main/resources/zume-legacy.mixins.json index 419ff27c..79d95f66 100644 --- a/legacy/src/main/resources/zume-legacy.mixins.json +++ b/legacy/src/main/resources/zume-legacy.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/lexforge/src/main/resources/zume-lexforge.mixins.json b/lexforge/src/main/resources/zume-lexforge.mixins.json index 900a072c..f8b179bd 100644 --- a/lexforge/src/main/resources/zume-lexforge.mixins.json +++ b/lexforge/src/main/resources/zume-lexforge.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/lexforge16/src/main/resources/zume-lexforge16.mixins.json b/lexforge16/src/main/resources/zume-lexforge16.mixins.json index 4afb676d..ffaace18 100644 --- a/lexforge16/src/main/resources/zume-lexforge16.mixins.json +++ b/lexforge16/src/main/resources/zume-lexforge16.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/lexforge18/src/main/resources/zume-lexforge18.mixins.json b/lexforge18/src/main/resources/zume-lexforge18.mixins.json index 8b63e5e3..ccd53420 100644 --- a/lexforge18/src/main/resources/zume-lexforge18.mixins.json +++ b/lexforge18/src/main/resources/zume-lexforge18.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/modern/src/main/resources/zume-modern.mixins.json b/modern/src/main/resources/zume-modern.mixins.json index 17e97b97..ccffd322 100644 --- a/modern/src/main/resources/zume-modern.mixins.json +++ b/modern/src/main/resources/zume-modern.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/primitive/src/main/resources/zume-primitive.mixins.json b/primitive/src/main/resources/zume-primitive.mixins.json index 8248afc4..12365259 100644 --- a/primitive/src/main/resources/zume-primitive.mixins.json +++ b/primitive/src/main/resources/zume-primitive.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], diff --git a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java index 75d7c692..71a868ae 100644 --- a/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/FabricZumeBootstrapper.java @@ -1,8 +1,6 @@ package dev.nolij.zume; -import dev.nolij.zume.impl.Zume; -import dev.nolij.zume.impl.ZumeMixinPlugin; -import dev.nolij.zume.impl.ZumeVariant; +import dev.nolij.zume.api.platform.v0.ZumeAPI; import dev.nolij.zume.modern.ModernZume; import dev.nolij.zume.primitive.PrimitiveZume; import dev.nolij.zume.legacy.LegacyZume; @@ -24,7 +22,7 @@ public void onPreLaunch() { if (ZumeMixinPlugin.ZUME_VARIANT != null) return; - Zume.LOGGER.error(MISSING_DEPENDENCY_MESSAGE); + ZumeAPI.getLogger().error(MISSING_DEPENDENCY_MESSAGE); FabricGuiEntry.displayError("Incompatible mods found!", null, tree -> { var tab = tree.addTab("Error"); tab.node.addMessage(MISSING_DEPENDENCY_MESSAGE, FabricStatusTree.FabricTreeWarningLevel.ERROR); diff --git a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java index 154b01e4..21ffb958 100644 --- a/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java +++ b/src/main/java/dev/nolij/zume/ForgeZumeBootstrapper.java @@ -1,7 +1,5 @@ package dev.nolij.zume; -import dev.nolij.zume.impl.ZumeMixinPlugin; -import dev.nolij.zume.impl.ZumeVariant; import dev.nolij.zume.lexforge.LexZume; import dev.nolij.zume.lexforge18.LexZume18; import dev.nolij.zume.lexforge16.LexZume16; diff --git a/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java b/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java similarity index 95% rename from api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java rename to src/main/java/dev/nolij/zume/ZumeMixinPlugin.java index 86cb87a4..bd2c545a 100644 --- a/api/src/main/java/dev/nolij/zume/impl/ZumeMixinPlugin.java +++ b/src/main/java/dev/nolij/zume/ZumeMixinPlugin.java @@ -1,4 +1,4 @@ -package dev.nolij.zume.impl; +package dev.nolij.zume; import dev.nolij.zume.api.util.v0.MethodHandleHelper; import org.objectweb.asm.tree.ClassNode; @@ -9,11 +9,11 @@ import java.util.List; import java.util.Set; -public class ZumeMixinPlugin implements IMixinConfigPlugin { +public final class ZumeMixinPlugin implements IMixinConfigPlugin { private static final ClassLoader CLASS_LOADER = ZumeMixinPlugin.class.getClassLoader(); - public static final String ZUME_VARIANT; + static final String ZUME_VARIANT; private static final String implementationMixinPackage; static { diff --git a/src/main/java/dev/nolij/zume/ZumeVariant.java b/src/main/java/dev/nolij/zume/ZumeVariant.java new file mode 100644 index 00000000..c2dce9d7 --- /dev/null +++ b/src/main/java/dev/nolij/zume/ZumeVariant.java @@ -0,0 +1,14 @@ +package dev.nolij.zume; + +final class ZumeVariant { + + static final String MODERN = "modern"; + static final String PRIMITIVE = "primitive"; + static final String LEGACY = "legacy"; + static final String ARCHAIC_FORGE = "archaic"; + static final String VINTAGE_FORGE = "vintage"; + static final String LEXFORGE = "lexforge"; + static final String LEXFORGE18 = "lexforge18"; + static final String LEXFORGE16 = "lexforge16"; + +} diff --git a/vintage/src/main/resources/zume-vintage.mixins.json b/vintage/src/main/resources/zume-vintage.mixins.json index 651766b1..88b1156b 100644 --- a/vintage/src/main/resources/zume-vintage.mixins.json +++ b/vintage/src/main/resources/zume-vintage.mixins.json @@ -2,7 +2,6 @@ "required": true, "minVersion": "0.8", "package": "dev.nolij.zume.mixin", - "plugin": "dev.nolij.zume.impl.ZumeMixinPlugin", "compatibilityLevel": "JAVA_8", "mixins": [ ], From ce04b3251cd63de2ed5d4633eacaefd7186f040c Mon Sep 17 00:00:00 2001 From: Nolij Date: Thu, 25 Apr 2024 21:27:37 -0400 Subject: [PATCH 15/15] remove unnecessary empty field from mixin configs --- archaic/src/main/resources/zume-archaic.mixins.json | 2 -- build.gradle.kts | 1 - legacy/src/main/resources/zume-legacy.mixins.json | 2 -- lexforge/src/main/resources/zume-lexforge.mixins.json | 2 -- lexforge16/src/main/resources/zume-lexforge16.mixins.json | 2 -- lexforge18/src/main/resources/zume-lexforge18.mixins.json | 2 -- modern/src/main/resources/zume-modern.mixins.json | 2 -- primitive/src/main/resources/zume-primitive.mixins.json | 2 -- vintage/src/main/resources/zume-vintage.mixins.json | 2 -- 9 files changed, 17 deletions(-) diff --git a/archaic/src/main/resources/zume-archaic.mixins.json b/archaic/src/main/resources/zume-archaic.mixins.json index b9fa6f1c..082b6aa9 100644 --- a/archaic/src/main/resources/zume-archaic.mixins.json +++ b/archaic/src/main/resources/zume-archaic.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "archaic.EntityRendererAccessor", "archaic.EntityRendererMixin" diff --git a/build.gradle.kts b/build.gradle.kts index 2bb946e8..503ca8a1 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -366,7 +366,6 @@ class MixinConfigMergingTransformer : Transformer { "package" to packageName, "plugin" to mixinPlugin, "compatibilityLevel" to "JAVA_8", - "mixins" to emptyList(), "client" to mixins, "injectors" to mapOf( "defaultRequire" to 1, diff --git a/legacy/src/main/resources/zume-legacy.mixins.json b/legacy/src/main/resources/zume-legacy.mixins.json index 79d95f66..37b5497c 100644 --- a/legacy/src/main/resources/zume-legacy.mixins.json +++ b/legacy/src/main/resources/zume-legacy.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "legacy.MinecraftClientMixin", "legacy.GameOptionsMixin", diff --git a/lexforge/src/main/resources/zume-lexforge.mixins.json b/lexforge/src/main/resources/zume-lexforge.mixins.json index f8b179bd..ba1d9573 100644 --- a/lexforge/src/main/resources/zume-lexforge.mixins.json +++ b/lexforge/src/main/resources/zume-lexforge.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "lexforge.CameraMixin", "lexforge.MouseHandlerMixin" diff --git a/lexforge16/src/main/resources/zume-lexforge16.mixins.json b/lexforge16/src/main/resources/zume-lexforge16.mixins.json index ffaace18..b099ee44 100644 --- a/lexforge16/src/main/resources/zume-lexforge16.mixins.json +++ b/lexforge16/src/main/resources/zume-lexforge16.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "lexforge16.CameraMixin", "lexforge16.MouseHandlerMixin" diff --git a/lexforge18/src/main/resources/zume-lexforge18.mixins.json b/lexforge18/src/main/resources/zume-lexforge18.mixins.json index ccd53420..fd783e00 100644 --- a/lexforge18/src/main/resources/zume-lexforge18.mixins.json +++ b/lexforge18/src/main/resources/zume-lexforge18.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "lexforge18.CameraMixin", "lexforge18.MouseHandlerMixin" diff --git a/modern/src/main/resources/zume-modern.mixins.json b/modern/src/main/resources/zume-modern.mixins.json index ccffd322..0bce8651 100644 --- a/modern/src/main/resources/zume-modern.mixins.json +++ b/modern/src/main/resources/zume-modern.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "modern.CameraMixin", "modern.GameRendererMixin", diff --git a/primitive/src/main/resources/zume-primitive.mixins.json b/primitive/src/main/resources/zume-primitive.mixins.json index 12365259..0d0f5b68 100644 --- a/primitive/src/main/resources/zume-primitive.mixins.json +++ b/primitive/src/main/resources/zume-primitive.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "primitive.GameRendererAccessor", "primitive.GameRendererMixin", diff --git a/vintage/src/main/resources/zume-vintage.mixins.json b/vintage/src/main/resources/zume-vintage.mixins.json index 88b1156b..8a4c099a 100644 --- a/vintage/src/main/resources/zume-vintage.mixins.json +++ b/vintage/src/main/resources/zume-vintage.mixins.json @@ -3,8 +3,6 @@ "minVersion": "0.8", "package": "dev.nolij.zume.mixin", "compatibilityLevel": "JAVA_8", - "mixins": [ - ], "client": [ "vintage.EntityRendererMixin" ],