Fix crash with latest sodium. Closes #156

This commit is contained in:
Sollace 2023-08-17 17:04:51 +01:00
parent 56e3807770
commit 2841c8ab7b
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
3 changed files with 59 additions and 2 deletions

View file

@ -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<String> myTargets, Set<String> otherTargets) { }
@Override
public List<String> 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) { }
}

View file

@ -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<SortedSet<BlockBreakingInfo>> modifyDestruction(Long2ObjectMap<SortedSet<BlockBreakingInfo>> blockBreakingProgressions) {
ClientBlockDestructionManager destructions = ((ClientBlockDestructionManager.Source)MinecraftClient.getInstance().worldRenderer).getDestructionManager();
return destructions.getCombinedDestructions(blockBreakingProgressions);

View file

@ -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": [