From 6fa323e506f6632ee803224555ed7a69e92a7fec Mon Sep 17 00:00:00 2001 From: ev chang Date: Wed, 19 Jun 2024 09:09:23 +0700 Subject: [PATCH] add migration from patcher --- .../patcher/config/OldPatcherConfig.java | 7 +++++++ .../mixin/EffectRendererMixin.java | 2 +- .../overflowparticles/OverflowParticles.kt | 9 +++++++++ .../overflowparticles/config/ModConfig.kt | 10 ++++++++++ .../overflowparticles/config/Settings.kt | 20 ++----------------- 5 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 src/dummy/java/club/sk1er/patcher/config/OldPatcherConfig.java diff --git a/src/dummy/java/club/sk1er/patcher/config/OldPatcherConfig.java b/src/dummy/java/club/sk1er/patcher/config/OldPatcherConfig.java new file mode 100644 index 0000000..735b168 --- /dev/null +++ b/src/dummy/java/club/sk1er/patcher/config/OldPatcherConfig.java @@ -0,0 +1,7 @@ +package club.sk1er.patcher.config; + +public class OldPatcherConfig { + public static boolean cleanView; + public static boolean staticParticleColor = false; + public static int maxParticleLimit = 4000; +} diff --git a/src/main/java/org/polyfrost/overflowparticles/mixin/EffectRendererMixin.java b/src/main/java/org/polyfrost/overflowparticles/mixin/EffectRendererMixin.java index 4a0fd99..dbfd35d 100644 --- a/src/main/java/org/polyfrost/overflowparticles/mixin/EffectRendererMixin.java +++ b/src/main/java/org/polyfrost/overflowparticles/mixin/EffectRendererMixin.java @@ -103,7 +103,7 @@ private void limit(EntityFX effect, CallbackInfo ci) { } @ModifyConstant(method = "addEffect", constant = @Constant(intValue = 4000)) - private int patcher$changeMaxParticleLimit(int original) { + private int changeMaxParticleLimit(int original) { return MainConfig.INSTANCE.getSettings().getMaxParticleLimit(); } diff --git a/src/main/kotlin/org/polyfrost/overflowparticles/OverflowParticles.kt b/src/main/kotlin/org/polyfrost/overflowparticles/OverflowParticles.kt index 1f5f42c..4db485c 100644 --- a/src/main/kotlin/org/polyfrost/overflowparticles/OverflowParticles.kt +++ b/src/main/kotlin/org/polyfrost/overflowparticles/OverflowParticles.kt @@ -29,11 +29,20 @@ object OverflowParticles { val unfair = listOf(28, 37) + var isPolyPatcher = false + private set + @Mod.EventHandler fun onInit(event: FMLInitializationEvent) { ModConfig MinecraftForge.EVENT_BUS.register(IconRenderer) EventManager.INSTANCE.register(IconRenderer) + isPolyPatcher = try { + Class.forName("club.sk1er.patcher.config.OldPatcherConfig") + true + } catch (e: ClassNotFoundException) { + false + } } fun fillConfigs() { diff --git a/src/main/kotlin/org/polyfrost/overflowparticles/config/ModConfig.kt b/src/main/kotlin/org/polyfrost/overflowparticles/config/ModConfig.kt index 4f99338..a3b4649 100644 --- a/src/main/kotlin/org/polyfrost/overflowparticles/config/ModConfig.kt +++ b/src/main/kotlin/org/polyfrost/overflowparticles/config/ModConfig.kt @@ -3,6 +3,7 @@ package org.polyfrost.overflowparticles.config import cc.polyfrost.oneconfig.config.Config import cc.polyfrost.oneconfig.config.data.* import cc.polyfrost.oneconfig.internal.config.core.ConfigCore +import club.sk1er.patcher.config.OldPatcherConfig import net.minecraft.client.particle.EntityFX import org.polyfrost.overflowparticles.OverflowParticles import java.util.ArrayList @@ -42,6 +43,15 @@ object ModConfig : Config(Mod(OverflowParticles.NAME, ModType.UTIL_QOL), "${Over MainConfig subMods.add(MainConfig.mod) ConfigCore.subMods[this.mod] = subMods + + if (OverflowParticles.isPolyPatcher && !settings.hasMigratedPatcher) { + settings.cleanView = OldPatcherConfig.cleanView + settings.staticParticleColor = OldPatcherConfig.staticParticleColor + settings.maxParticleLimit = OldPatcherConfig.maxParticleLimit + + settings.hasMigratedPatcher = true + save() + } } override fun load() { diff --git a/src/main/kotlin/org/polyfrost/overflowparticles/config/Settings.kt b/src/main/kotlin/org/polyfrost/overflowparticles/config/Settings.kt index 250d56f..5a74f4a 100644 --- a/src/main/kotlin/org/polyfrost/overflowparticles/config/Settings.kt +++ b/src/main/kotlin/org/polyfrost/overflowparticles/config/Settings.kt @@ -1,22 +1,12 @@ package org.polyfrost.overflowparticles.config import cc.polyfrost.oneconfig.config.annotations.Button -import cc.polyfrost.oneconfig.config.annotations.Info import cc.polyfrost.oneconfig.config.annotations.Slider import cc.polyfrost.oneconfig.config.annotations.Switch import cc.polyfrost.oneconfig.config.core.ConfigUtils -import cc.polyfrost.oneconfig.config.data.InfoType class Settings { - @Info( - text = "From Patcher", - type = InfoType.INFO, - size = 2, - subcategory = "Features" - ) - var fp = Runnable { } - @Switch( name = "Clean View", description = "Stop rendering your potion effect particles.", @@ -39,14 +29,6 @@ class Settings { ) var maxParticleLimit = 4000 - @Info( - text = "From Overflow Animations", - type = InfoType.INFO, - size = 2, - subcategory = "Features" - ) - var foa = Runnable { } - @Switch( name = "Particles No-Clip", description = "Allows particles to no clip through blocks by simply not checking for collisions.", @@ -77,6 +59,8 @@ class Settings { loadFrom(Settings()) } + var hasMigratedPatcher = false + fun loadFrom(entry: Settings) { val newFields = ConfigUtils.getClassFields(entry::class.java) val fields = ConfigUtils.getClassFields(this::class.java)