From 0e74cc6bbe394858edb0e2222e659c06353c892a Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 20 Sep 2022 18:17:02 +0200 Subject: [PATCH] Fixed block destructions not showing on tile entities when sodium is installed --- build.gradle | 2 ++ .../mixin/client/MixinWorldRenderer.java | 2 +- .../sodium/MixinSodiumWorldRenderer.java | 21 +++++++++++++++++++ src/main/resources/unicopia.mixin.json | 3 ++- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 src/main/java/com/minelittlepony/unicopia/mixin/client/sodium/MixinSodiumWorldRenderer.java diff --git a/build.gradle b/build.gradle index a038c47e..553ed649 100644 --- a/build.gradle +++ b/build.gradle @@ -53,6 +53,8 @@ dependencies { include "com.minelittlepony:kirin:${project.kirin_version}" modCompileOnly("com.terraformersmc:modmenu:${project.modmenu_version}") + // implementation 'org.jetbrains:intellij-fernflower:1.2.1.16' + modCompileOnly("net.caffienemc.sodium:sodium-fabric-mc1.19.2:0.4.4+build.18") } processResources { diff --git a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java index b9dc9479..313a4488 100644 --- a/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/MixinWorldRenderer.java @@ -18,7 +18,7 @@ import net.minecraft.client.render.BlockBreakingInfo; import net.minecraft.client.render.WorldRenderer; import net.minecraft.resource.SynchronousResourceReloader; -@Mixin(WorldRenderer.class) +@Mixin(value = WorldRenderer.class, priority = 1001) abstract class MixinWorldRenderer implements SynchronousResourceReloader, AutoCloseable, ClientBlockDestructionManager.Source { private final ClientBlockDestructionManager destructions = new ClientBlockDestructionManager(); 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 new file mode 100644 index 00000000..f1775201 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/mixin/client/sodium/MixinSodiumWorldRenderer.java @@ -0,0 +1,21 @@ +package com.minelittlepony.unicopia.mixin.client.sodium; + +import java.util.SortedSet; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.*; +import com.minelittlepony.unicopia.client.ClientBlockDestructionManager; + +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.*; + +@Mixin(SodiumWorldRenderer.class) +abstract class MixinSodiumWorldRenderer { + @ModifyVariable(method = "renderTileEntities", at = @At("HEAD")) + 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 bbbd7813..0a1e37b3 100644 --- a/src/main/resources/unicopia.mixin.json +++ b/src/main/resources/unicopia.mixin.json @@ -50,7 +50,8 @@ "client.MixinMouse", "client.MixinPlayerEntityRenderer", "client.MixinTooltipComponent", - "client.MixinWorldRenderer" + "client.MixinWorldRenderer", + "client.sodium.MixinSodiumWorldRenderer" ], "injectors": { "defaultRequire": 1