diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index e1ba119..d218a6a 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -9,7 +9,7 @@ object versions { object deps { val minecraft = "com.mojang:minecraft:${versions.minecraft}" val yarn = "net.fabricmc:yarn:1.19.2+build.8:v2" - val fabricLoader = "net.fabricmc:fabric-loader:0.14.15" + val fabricLoader = "net.fabricmc:fabric-loader:0.14.22" val wthit = "mcp.mobius.waila:wthit:fabric-5.17.0" @@ -55,6 +55,7 @@ object deps { fun DependencyHandlerScope.modImpl(dep: String, dependencyConfiguration: ExternalModuleDependency.() -> Unit = {}) { "modImplementation"(dep) { if (!dep.startsWith("net.fabricmc.fabric-api")) exclude(group = "net.fabricmc.fabric-api") + exclude("net.fabricmc:fabric-loader") dependencyConfiguration() } } diff --git a/module-base/runtime/src/main/java/lol/bai/megane/runtime/config/MeganeConfig.java b/module-base/runtime/src/main/java/lol/bai/megane/runtime/config/MeganeConfig.java index 799bf9b..403270b 100644 --- a/module-base/runtime/src/main/java/lol/bai/megane/runtime/config/MeganeConfig.java +++ b/module-base/runtime/src/main/java/lol/bai/megane/runtime/config/MeganeConfig.java @@ -24,6 +24,9 @@ public class MeganeConfig { private boolean spawnEgg = true; private boolean playerHead = true; + private boolean pluginConfigMigrated = false; + private final Set migratedBlacklist = new HashSet<>(); + public int getConfigVersion() { return configVersion; } @@ -44,6 +47,14 @@ public boolean getPlayerHead() { return playerHead; } + public boolean isPluginConfigMigrated() { + return pluginConfigMigrated; + } + + public Set getMigratedBlacklist() { + return migratedBlacklist; + } + public void setCatchServerErrors(boolean catchServerErrors) { this.catchServerErrors = catchServerErrors; } @@ -56,6 +67,10 @@ public void setPlayerHead(boolean playerHead) { this.playerHead = playerHead; } + public void setPluginConfigMigrated(boolean pluginConfigMigrated) { + this.pluginConfigMigrated = pluginConfigMigrated; + } + public interface Base { boolean isEnabled(); diff --git a/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinExtraBlacklistConfigAdapter.java b/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinExtraBlacklistConfigAdapter.java index 175468e..2e2a811 100644 --- a/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinExtraBlacklistConfigAdapter.java +++ b/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinExtraBlacklistConfigAdapter.java @@ -21,20 +21,17 @@ @Mixin(ExtraBlacklistConfig.Adapter.class) public abstract class MixinExtraBlacklistConfigAdapter { - @Unique - private boolean megane_migrated = false; - @Shadow @Final private Identifier tagId; @Inject(method = "deserialize(Lcom/google/gson/JsonElement;Ljava/lang/reflect/Type;Lcom/google/gson/JsonDeserializationContext;)Lmcp/mobius/waila/plugin/extra/config/ExtraBlacklistConfig;", at = @At("RETURN"), remap = false) private void migrateBlacklist(JsonElement json, Type typeOfT, JsonDeserializationContext context, CallbackInfoReturnable cir) { - if (megane_migrated) return; + MeganeConfig config = MeganeUtils.config(); + if (config.getMigratedBlacklist().contains(tagId)) return; ExtraBlacklistConfig out = cir.getReturnValue(); AccessorExtraBlacklistConfig access = (AccessorExtraBlacklistConfig) out; - MeganeConfig config = MeganeUtils.config(); if (tagId.equals(new Identifier("waila:extra/energy_blacklist"))) { add(out.blocks, access.getBlockIds(), Registry.BLOCK, config.energy.getBlacklist()); @@ -48,7 +45,8 @@ private void migrateBlacklist(JsonElement json, Type typeOfT, JsonDeserializatio } MeganeUtils.LOGGER.info("[megane] migrated {}", tagId); - megane_migrated = true; + config.getMigratedBlacklist().add(tagId); + MeganeUtils.CONFIG.save(); } @Unique diff --git a/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinPluginConfig.java b/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinPluginConfig.java index e8d2af6..2795517 100644 --- a/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinPluginConfig.java +++ b/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/MixinPluginConfig.java @@ -14,14 +14,11 @@ @Mixin(PluginConfig.class) public abstract class MixinPluginConfig { - @Unique - private static boolean megane_migrated = false; - @Inject(method = "reload", at = @At("RETURN"), remap = false) private static void migrateConfig(CallbackInfo ci) { - if (megane_migrated) return; - MeganeConfig config = MeganeUtils.config(); + if (config.isPluginConfigMigrated()) return; + set(new Identifier("wailax:energy.enabled_block"), config.energy.isEnabled()); set(new Identifier("wailax:fluid.enabled_block"), config.fluid.isEnabled()); set(new Identifier("wailax:item.enabled_block"), config.inventory.isEnabled()); @@ -31,7 +28,8 @@ private static void migrateConfig(CallbackInfo ci) { MeganeUtils.LOGGER.info("[megane] Migrated plugin config"); save(); - megane_migrated = true; + config.setPluginConfigMigrated(true); + MeganeUtils.CONFIG.save(); } @Shadow