From 63256bf4f838af7eec766e4d5bd6db095da77698 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Sun, 4 Aug 2024 13:30:14 +1000 Subject: [PATCH] Linear XP Scaling for AA and EIO Machines --- dependencies.gradle | 7 ++++ gradle.properties | 6 ++-- .../java/com/nomiceu/nomilabs/LabsValues.java | 1 + .../nomiceu/nomilabs/config/LabsConfig.java | 10 ++++++ .../nomiceu/nomilabs/core/LabsLateMixin.java | 4 ++- .../TileEntityXPSolidifierMixin.java | 32 +++++++++++++++++++ .../nomilabs/mixin/enderio/XPUtilMixin.java | 32 +++++++++++++++++++ .../resources/assets/nomilabs/lang/en_us.lang | 1 + .../mixins.nomilabs.actuallyadditions.json | 12 +++++++ .../resources/mixins.nomilabs.enderio.json | 12 +++++++ 10 files changed, 114 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/actuallyadditions/TileEntityXPSolidifierMixin.java create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/enderio/XPUtilMixin.java create mode 100644 src/main/resources/mixins.nomilabs.actuallyadditions.json create mode 100644 src/main/resources/mixins.nomilabs.enderio.json diff --git a/dependencies.gradle b/dependencies.gradle index a39d6cd..3c175cd 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -144,6 +144,9 @@ dependencies { // Controlling (from CurseForge) compileOnly rfg.deobf("curse.maven:controlling-250398:5165715") // Version 3.0.12.3 + // Actually Additions (from CurseForge) + compileOnly rfg.deobf("curse.maven:actually-additions-228404:3117927") // Version r152 + // Default World Generator Port (from CurseForge) compileOnly rfg.deobf("curse.maven:default-world-generator-port-241140:2499252") // Version 2.3 @@ -250,6 +253,10 @@ dependencies { runtimeOnly "curse.maven:top-addons-247111:2887479" // Version 1.13.0 } + if (project.enable_aa.toBoolean()) { + runtimeOnly "curse.maven:actually-additions-228404:3117927" // Version r152 + } + if (project.enable_ender_storage.toBoolean()) { // Ender Storage, runtime only, integrated in remappers (from CurseForge) runtimeOnly "curse.maven:ender-storage-245174:2755787" // Version 2.4.6.137 diff --git a/gradle.properties b/gradle.properties index 3ae1b60..e3524d0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -217,8 +217,7 @@ enable_storage_drawers = false # Requires `enable_storage_drawers` to be set to true. enable_framed_compact = false -# Whether to enable Ender IO and its deps in runtime. Enables Custom Capacitors. -# If this is set to false, custom capacitors are disabled. +# Whether to enable Ender IO and its deps in runtime. Enables Custom Capacitors & allows specifying Linear XP Scaling for EIO Machines. enable_ender_io = false # Whether to enable Chisel and its deps in runtime. Enables Chisel Blocks in Naq Reactors. @@ -283,6 +282,9 @@ enable_default_world_gen_port = false # Whether to enable TOP Addons in runtime. Fixes Error Messages with Architecture Craft 3.108. enable_top_addons = false +# Whether to enable Actually Additions in runtime. Allows specifying Linear XP Scaling for AA Machines. +enable_aa = false + # Whether to enable Ender Storage in runtime. Enables remappers to remap items in ender storage. # If this is set to false, the remappers will not apply there. enable_ender_storage = false diff --git a/src/main/java/com/nomiceu/nomilabs/LabsValues.java b/src/main/java/com/nomiceu/nomilabs/LabsValues.java index 18c42af..653dfbe 100644 --- a/src/main/java/com/nomiceu/nomilabs/LabsValues.java +++ b/src/main/java/com/nomiceu/nomilabs/LabsValues.java @@ -30,6 +30,7 @@ public class LabsValues { public static final String STORAGE_DRAWERS_MODID = "storagedrawers"; public static final String FRAMED_COMPACT_MODID = "framedcompactdrawers"; public static final String ENDER_IO_MODID = "enderio"; + public static final String AA_MODID = "actuallyadditions"; public static final String JEI_MODID = "jei"; public static final String ROCKETRY_MODID = "advancedrocketry"; public static final String ARCHITECTURE_MODID = "architecturecraft"; diff --git a/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java b/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java index 3e23d72..da062d7 100644 --- a/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java +++ b/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java @@ -372,6 +372,16 @@ public static class Advanced { @Config.LangKey("config.nomilabs.advanced.disable_xp_scaling") public boolean disableXpScaling = false; + @Config.Comment({ "Amount of XP Per Level, for Linear XP Scaling.", + "Used for Linear XP Scaling in Actually Additions and EIO Machines.", + "MUST be used in conjunction with UT's Linear XP Scaling Config, else weird issues may happen!", + "Enter a value of 0 for default.", + "[default: 0]" }) + @Config.LangKey("config.nomilabs.advanced.aa_eio_linear_xp") + @Config.RequiresMcRestart + @Config.RangeInt(min = 0) + public int aaEioLinearXp = 0; + @Config.Comment({ "Whether to disable the Narrator.", "Fixes Crashes in Arm Macs, in some very specific environments.", "If your game is crashing, try enabling this!", diff --git a/src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java b/src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java index 2a98e33..12df7c3 100644 --- a/src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java +++ b/src/main/java/com/nomiceu/nomilabs/core/LabsLateMixin.java @@ -44,7 +44,9 @@ public class LabsLateMixin implements ILateMixinLoader { new AbstractMap.SimpleImmutableEntry<>(LabsValues.TOP_ADDONS_MODID, LabsConfig.modIntegration.enableTopAddonsIntegration), new AbstractMap.SimpleImmutableEntry<>(LabsValues.TOP_MODID, true), - new AbstractMap.SimpleImmutableEntry<>(LabsValues.AE2_MODID, true)) + new AbstractMap.SimpleImmutableEntry<>(LabsValues.AE2_MODID, true), + new AbstractMap.SimpleImmutableEntry<>(LabsValues.ENDER_IO_MODID, true), + new AbstractMap.SimpleImmutableEntry<>(LabsValues.AA_MODID, true)) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); @Override diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/actuallyadditions/TileEntityXPSolidifierMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/actuallyadditions/TileEntityXPSolidifierMixin.java new file mode 100644 index 0000000..e8996c6 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/actuallyadditions/TileEntityXPSolidifierMixin.java @@ -0,0 +1,32 @@ +package com.nomiceu.nomilabs.mixin.actuallyadditions; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.nomiceu.nomilabs.config.LabsConfig; + +import de.ellpeck.actuallyadditions.mod.tile.TileEntityXPSolidifier; + +@Mixin(value = TileEntityXPSolidifier.class, remap = false) +public abstract class TileEntityXPSolidifierMixin { + + @Inject(method = "getExperienceForLevel", at = @At("HEAD"), cancellable = true) + private static void getLinearXpAmountLevel(int level, CallbackInfoReturnable cir) { + if (LabsConfig.advanced.aaEioLinearXp != 0 && level >= 0) + cir.setReturnValue(LabsConfig.advanced.aaEioLinearXp * level); + } + + @Inject(method = "getLevelForExperience", at = @At("HEAD"), cancellable = true) + private static void getLinearXPAmountXp(int experience, CallbackInfoReturnable cir) { + if (LabsConfig.advanced.aaEioLinearXp != 0 && experience >= 0) + cir.setReturnValue(experience / LabsConfig.advanced.aaEioLinearXp); + } + + @Inject(method = "getXpBarCapacity", at = @At("HEAD"), cancellable = true) + private static void getLinearXPAmount(int level, CallbackInfoReturnable cir) { + if (LabsConfig.advanced.aaEioLinearXp != 0 && level >= 0) + cir.setReturnValue(LabsConfig.advanced.aaEioLinearXp); + } +} diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/enderio/XPUtilMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/enderio/XPUtilMixin.java new file mode 100644 index 0000000..5a9ad8f --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/enderio/XPUtilMixin.java @@ -0,0 +1,32 @@ +package com.nomiceu.nomilabs.mixin.enderio; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.nomiceu.nomilabs.config.LabsConfig; + +import crazypants.enderio.base.xp.XpUtil; + +@Mixin(value = XpUtil.class, remap = false) +public class XPUtilMixin { + + @Inject(method = "calculateXPfromLevel", at = @At("HEAD"), cancellable = true) + private static void calculateXpFromLevelLinear(int level, CallbackInfoReturnable cir) { + if (LabsConfig.advanced.aaEioLinearXp != 0 && level >= 0) + cir.setReturnValue(((long) LabsConfig.advanced.aaEioLinearXp * level)); + } + + @Inject(method = "getLevelFromExp", at = @At("HEAD"), cancellable = true) + private static void getLevelFromXpLinear(long exp, CallbackInfoReturnable cir) { + if (LabsConfig.advanced.aaEioLinearXp != 0 && exp >= 0) + cir.setReturnValue((int) (exp / LabsConfig.advanced.aaEioLinearXp)); + } + + @Inject(method = "getXpBarCapacity", at = @At("HEAD"), cancellable = true) + private static void getLinearXPAmount(int level, CallbackInfoReturnable cir) { + if (LabsConfig.advanced.aaEioLinearXp != 0 && level >= 0) + cir.setReturnValue(LabsConfig.advanced.aaEioLinearXp); + } +} diff --git a/src/main/resources/assets/nomilabs/lang/en_us.lang b/src/main/resources/assets/nomilabs/lang/en_us.lang index 384dbe8..c0d56ff 100644 --- a/src/main/resources/assets/nomilabs/lang/en_us.lang +++ b/src/main/resources/assets/nomilabs/lang/en_us.lang @@ -77,6 +77,7 @@ config.nomilabs.advanced=Advanced Settings config.nomilabs.advanced.tooltip=Advanced Settings config.nomilabs.advanced.allow_other_modes=Allow Other Modes config.nomilabs.advanced.disable_xp_scaling=Disable Anvil XP Scaling +config.nomilabs.advanced.aa_eio_linear_xp=Actually Additions & EIO Linear XP config.nomilabs.advanced.disable_narrator=Disable Narrator config.nomilabs.advanced.enable_nomi_ceu_data_fixes=Enable Nomi-CEu Specific Data Fixes config.nomilabs.advanced.ignore_items=ITEM Missing Registry Ignore List diff --git a/src/main/resources/mixins.nomilabs.actuallyadditions.json b/src/main/resources/mixins.nomilabs.actuallyadditions.json new file mode 100644 index 0000000..5ef10fb --- /dev/null +++ b/src/main/resources/mixins.nomilabs.actuallyadditions.json @@ -0,0 +1,12 @@ +{ + "package": "com.nomiceu.nomilabs.mixin.actuallyadditions", + "refmap": "mixins.nomilabs.refmap.json", + "target": "@env(DEFAULT)", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "TileEntityXPSolidifierMixin" + ], + "client": [], + "server": [] +} diff --git a/src/main/resources/mixins.nomilabs.enderio.json b/src/main/resources/mixins.nomilabs.enderio.json new file mode 100644 index 0000000..fbde7eb --- /dev/null +++ b/src/main/resources/mixins.nomilabs.enderio.json @@ -0,0 +1,12 @@ +{ + "package": "com.nomiceu.nomilabs.mixin.enderio", + "refmap": "mixins.nomilabs.refmap.json", + "target": "@env(DEFAULT)", + "minVersion": "0.8", + "compatibilityLevel": "JAVA_8", + "mixins": [ + "XPUtilMixin" + ], + "client": [], + "server": [] +}