diff --git a/src/main/java/com/minelittlepony/unicopia/UnicopiaMixinPlugin.java b/src/main/java/com/minelittlepony/unicopia/UnicopiaMixinPlugin.java new file mode 100644 index 00000000..9210e524 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/UnicopiaMixinPlugin.java @@ -0,0 +1,49 @@ +package com.minelittlepony.unicopia; + +import java.util.List; +import java.util.Set; + +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +import net.fabricmc.loader.api.FabricLoader; + +public class UnicopiaMixinPlugin implements IMixinConfigPlugin { + private static final String MIXIN_PACKAGE = "com.minelittlepony.unicopia.mixin"; + + @Override + public void onLoad(String mixinPackage) { } + + @Override + public String getRefMapperConfig() { + return null; + } + + @Override + public boolean shouldApplyMixin(String targetClassName, String mixinClassName) { + if (mixinClassName.startsWith(MIXIN_PACKAGE)) { + if (mixinClassName.indexOf("sodium") != -1) { + return FabricLoader.getInstance().isModLoaded("sodium"); + } + if (mixinClassName.indexOf("trinkets") != -1) { + return FabricLoader.getInstance().isModLoaded("trinkets"); + } + } + return true; + } + + @Override + public void acceptTargets(Set myTargets, Set otherTargets) { } + + @Override + public List getMixins() { + return null; + } + + @Override + public void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { } + + @Override + public void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) { } +} diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/sodium/MixinSodiumWorldRenderer.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/sodium/MixinSodiumWorldRenderer.java index b904d737..fb9c23e0 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/sodium/MixinSodiumWorldRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/sodium/MixinSodiumWorldRenderer.java @@ -12,9 +12,16 @@ import net.minecraft.client.MinecraftClient; import net.minecraft.client.render.*; @Pseudo -@Mixin(targets = { "me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer" }, remap = false) +@Mixin( + targets = { "me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer" }, + remap = false +) abstract class MixinSodiumWorldRenderer { - @ModifyVariable(method = "renderTileEntities", at = @At("HEAD")) + @ModifyVariable( + method = { "renderTileEntities", "renderBlockEntities" }, + at = @At("HEAD"), + require = 0 + ) public Long2ObjectMap> modifyDestruction(Long2ObjectMap> blockBreakingProgressions) { ClientBlockDestructionManager destructions = ((ClientBlockDestructionManager.Source)MinecraftClient.getInstance().worldRenderer).getDestructionManager(); return destructions.getCombinedDestructions(blockBreakingProgressions); diff --git a/src/main/resources/unicopia.mixin.json b/src/main/resources/unicopia.mixin.json index 47dda76f..6d6cb13f 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -2,6 +2,7 @@ "required": true, "minVersion": "0.7", "package": "com.minelittlepony.unicopia.mixin", + "plugin" : "com.minelittlepony.unicopia.UnicopiaMixinPlugin", "refmap": "unicopia.mixin.refmap.json", "compatibilityLevel": "JAVA_17", "mixins": [