Skip to content

Commit

Permalink
fix mixin error with wthit 5.19
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Sep 5, 2023
1 parent bc47f42 commit 706b0d7
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 49 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<init>", 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<ExtraBlacklistConfig> 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 <T> void add(Set<T> out, Set<Identifier> outIds, Registry<T> registry, Set<Identifier> inIds) {
private void add(Set<String> out, Set<Identifier> inIds) {
for (Identifier inId : inIds) {
outIds.add(inId);
registry.getOrEmpty(inId).ifPresent(out::add);
out.add(inId.toString());
}
}

Expand Down
2 changes: 1 addition & 1 deletion module-base/runtime/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"depends" : {
"minecraft" : ">=1.19",
"wthit" : ">=5.17",
"wthit" : ">=5.19",
"megane-api" : "*"
},
"custom" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"compatibilityLevel": "JAVA_8",
"mixins" : [
"AccessorBeaconBlockEntity",
"AccessorExtraBlacklistConfig",
"MixinExtraBlacklistConfigAdapter",
"MixinMinecraftServer",
"MixinPluginConfig"
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"environment" : "*",
"depends" : {
"minecraft" : ">=1.19",
"wthit" : ">=5.17"
"wthit" : ">=5.19"
}
}

0 comments on commit 706b0d7

Please sign in to comment.