Skip to content

Commit

Permalink
add migration from patcher
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyvest committed Jun 19, 2024
1 parent 91d5073 commit 6fa323e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down
20 changes: 2 additions & 18 deletions src/main/kotlin/org/polyfrost/overflowparticles/config/Settings.kt
Original file line number Diff line number Diff line change
@@ -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.",
Expand All @@ -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.",
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6fa323e

Please sign in to comment.