From 706b0d7a6c3417f55674107218067be0f29144ad Mon Sep 17 00:00:00 2001 From: deirn Date: Wed, 6 Sep 2023 00:46:39 +0700 Subject: [PATCH] fix mixin error with wthit 5.19 --- buildSrc/src/main/kotlin/Dependencies.kt | 2 +- .../mixin/AccessorExtraBlacklistConfig.java | 22 --------- .../MixinExtraBlacklistConfigAdapter.java | 46 +++++++++---------- .../src/main/resources/fabric.mod.json | 2 +- .../main/resources/megane-runtime.mixins.json | 1 - src/main/resources/fabric.mod.json | 2 +- 6 files changed, 26 insertions(+), 49 deletions(-) delete mode 100644 module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/AccessorExtraBlacklistConfig.java diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt index d218a6a..80a5896 100644 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ b/buildSrc/src/main/kotlin/Dependencies.kt @@ -11,7 +11,7 @@ object deps { val yarn = "net.fabricmc:yarn:1.19.2+build.8:v2" val fabricLoader = "net.fabricmc:fabric-loader:0.14.22" - val wthit = "mcp.mobius.waila:wthit:fabric-5.17.0" + val wthit = "mcp.mobius.waila:wthit:fabric-5.19.0" val ae2 = "appeng:appliedenergistics2-fabric:12.9.6" val alloyForge = "maven.modrinth:jhl28YkY:2.0.20+1.19" diff --git a/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/AccessorExtraBlacklistConfig.java b/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/AccessorExtraBlacklistConfig.java deleted file mode 100644 index e45f419..0000000 --- a/module-base/runtime/src/main/java/lol/bai/megane/runtime/mixin/AccessorExtraBlacklistConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package lol.bai.megane.runtime.mixin; - -import java.util.LinkedHashSet; - -import mcp.mobius.waila.plugin.extra.config.ExtraBlacklistConfig; -import net.minecraft.util.Identifier; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Mixin(ExtraBlacklistConfig.class) -public interface AccessorExtraBlacklistConfig { - - @Accessor - LinkedHashSet getBlockIds(); - - @Accessor - LinkedHashSet getBlockEntityTypeIds(); - - @Accessor - LinkedHashSet getEntityTypeIds(); - -} 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 2e2a811..2e70a58 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 @@ -9,51 +9,51 @@ import lol.bai.megane.runtime.util.MeganeUtils; import mcp.mobius.waila.plugin.extra.config.ExtraBlacklistConfig; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ExtraBlacklistConfig.Adapter.class) public abstract class MixinExtraBlacklistConfigAdapter { - @Shadow - @Final - private Identifier tagId; + @Unique + private Identifier megane_tagId; + + @Inject(method = "", at = @At("TAIL")) + private void storeTagId(Identifier tagId, CallbackInfo ci) { + megane_tagId = 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) { MeganeConfig config = MeganeUtils.config(); - if (config.getMigratedBlacklist().contains(tagId)) return; + if (config.getMigratedBlacklist().contains(megane_tagId)) return; ExtraBlacklistConfig out = cir.getReturnValue(); - AccessorExtraBlacklistConfig access = (AccessorExtraBlacklistConfig) out; - - if (tagId.equals(new Identifier("waila:extra/energy_blacklist"))) { - add(out.blocks, access.getBlockIds(), Registry.BLOCK, config.energy.getBlacklist()); - } else if (tagId.equals(new Identifier("waila:extra/fluid_blacklist"))) { - add(out.blocks, access.getBlockIds(), Registry.BLOCK, config.fluid.getBlacklist()); - } else if (tagId.equals(new Identifier("waila:extra/item_blacklist"))) { - add(out.blocks, access.getBlockIds(), Registry.BLOCK, config.inventory.getBlacklist()); - add(out.entityTypes, access.getEntityTypeIds(), Registry.ENTITY_TYPE, config.entityInventory.getBlacklist()); - } else if (tagId.equals(new Identifier("waila:extra/progress_blacklist"))) { - add(out.blocks, access.getBlockIds(), Registry.BLOCK, config.progress.getBlacklist()); + + if (megane_tagId.equals(new Identifier("waila:extra/energy_blacklist"))) { + add(out.blocks, config.energy.getBlacklist()); + } else if (megane_tagId.equals(new Identifier("waila:extra/fluid_blacklist"))) { + add(out.blocks, config.fluid.getBlacklist()); + } else if (megane_tagId.equals(new Identifier("waila:extra/item_blacklist"))) { + add(out.blocks, config.inventory.getBlacklist()); + add(out.entityTypes, config.entityInventory.getBlacklist()); + } else if (megane_tagId.equals(new Identifier("waila:extra/progress_blacklist"))) { + add(out.blocks, config.progress.getBlacklist()); } - MeganeUtils.LOGGER.info("[megane] migrated {}", tagId); - config.getMigratedBlacklist().add(tagId); + MeganeUtils.LOGGER.info("[megane] migrated {}", megane_tagId); + config.getMigratedBlacklist().add(megane_tagId); MeganeUtils.CONFIG.save(); } @Unique - private void add(Set out, Set outIds, Registry registry, Set inIds) { + private void add(Set out, Set inIds) { for (Identifier inId : inIds) { - outIds.add(inId); - registry.getOrEmpty(inId).ifPresent(out::add); + out.add(inId.toString()); } } diff --git a/module-base/runtime/src/main/resources/fabric.mod.json b/module-base/runtime/src/main/resources/fabric.mod.json index 48ebbff..a818b5d 100644 --- a/module-base/runtime/src/main/resources/fabric.mod.json +++ b/module-base/runtime/src/main/resources/fabric.mod.json @@ -18,7 +18,7 @@ ], "depends" : { "minecraft" : ">=1.19", - "wthit" : ">=5.17", + "wthit" : ">=5.19", "megane-api" : "*" }, "custom" : { diff --git a/module-base/runtime/src/main/resources/megane-runtime.mixins.json b/module-base/runtime/src/main/resources/megane-runtime.mixins.json index 1289036..23c4f49 100644 --- a/module-base/runtime/src/main/resources/megane-runtime.mixins.json +++ b/module-base/runtime/src/main/resources/megane-runtime.mixins.json @@ -5,7 +5,6 @@ "compatibilityLevel": "JAVA_8", "mixins" : [ "AccessorBeaconBlockEntity", - "AccessorExtraBlacklistConfig", "MixinExtraBlacklistConfigAdapter", "MixinMinecraftServer", "MixinPluginConfig" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 9563dd4..d1f6116 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -22,6 +22,6 @@ "environment" : "*", "depends" : { "minecraft" : ">=1.19", - "wthit" : ">=5.17" + "wthit" : ">=5.19" } }