From f84d92a38d60d88c25c3647b0a3bbfb55c039802 Mon Sep 17 00:00:00 2001 From: kurrycat Date: Sun, 27 Oct 2024 00:34:49 +0200 Subject: [PATCH] fix destroy block animation like 1.12 --- .../gtnewhorizons/angelica/mixins/Mixins.java | 1 + .../MixinRenderGlobal_DestroyBlock.java | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/bugfixes/MixinRenderGlobal_DestroyBlock.java diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java index 330f7ee6b..e294dfeab 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java @@ -29,6 +29,7 @@ public enum Mixins { ,"angelica.MixinMinecraft" ,"angelica.optimizations.MixinRendererLivingEntity" ,"angelica.MixinFMLClientHandler" + ,"angelica.bugfixes.MixinRenderGlobal_DestroyBlock" ) ), ANGELICA_VBO( diff --git a/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/bugfixes/MixinRenderGlobal_DestroyBlock.java b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/bugfixes/MixinRenderGlobal_DestroyBlock.java new file mode 100644 index 000000000..98654dd18 --- /dev/null +++ b/src/mixin/java/com/gtnewhorizons/angelica/mixins/early/angelica/bugfixes/MixinRenderGlobal_DestroyBlock.java @@ -0,0 +1,41 @@ +package com.gtnewhorizons.angelica.mixins.early.angelica.bugfixes; + +import com.gtnewhorizons.angelica.glsm.GLStateManager; +import com.gtnewhorizons.angelica.glsm.texture.TextureInfo; +import com.gtnewhorizons.angelica.glsm.texture.TextureInfoCache; +import com.llamalad7.mixinextras.sugar.Share; +import com.llamalad7.mixinextras.sugar.ref.LocalIntRef; +import net.minecraft.client.renderer.RenderGlobal; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.entity.EntityLivingBase; +import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(RenderGlobal.class) +public class MixinRenderGlobal_DestroyBlock { + @Inject( + method = "drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V", + at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/Tessellator;startDrawingQuads()V"), + remap = false + ) + private void iris$beginDrawBlockDamageTexture(Tessellator tessellator, EntityLivingBase entity, float partialTicks, CallbackInfo ci, @Share("lastMin") LocalIntRef lastMin, @Share("lastMag") LocalIntRef lastMag) { + TextureInfo info = TextureInfoCache.INSTANCE.getInfo(GLStateManager.getBoundTexture()); + lastMin.set(info.getMinFilter()); + lastMag.set(info.getMagFilter()); + GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST); + GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST); + } + + @Inject( + method = "drawBlockDamageTexture(Lnet/minecraft/client/renderer/Tessellator;Lnet/minecraft/entity/EntityLivingBase;F)V", + at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glPopMatrix()V"), + remap = false + ) + private void iris$endDrawBlockDamageTexture(Tessellator tessellator, EntityLivingBase entity, float partialTicks, CallbackInfo ci, @Share("lastMin") LocalIntRef lastMin, @Share("lastMag") LocalIntRef lastMag) { + GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, lastMin.get()); + GLStateManager.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, lastMag.get()); + } +}