From 3755e2595f419acf4fb4929990bfcc739cdabf6a Mon Sep 17 00:00:00 2001 From: makamys Date: Sun, 21 Jan 2024 18:12:30 +0100 Subject: [PATCH] Fix campfire backport animations (#224) * Mark animations of crossed squares Fixes Angelica's equivalent of https://github.com/GTNewHorizons/Hodgepodge/issues/264 Fixes Campfire Backport campfire flames not animating (but the embers and the mixed NEI flames are still broken) * Add Campfire Backport compatibility to animation speedup Fixes Angelica's equivalent of https://github.com/GTNewHorizons/Hodgepodge/issues/204 Fixes embers and NEI mixed flames not animating --- dependencies.gradle | 1 + .../gtnewhorizons/angelica/mixins/Mixins.java | 5 +++ .../angelica/mixins/TargetedMod.java | 1 + .../angelica/animation/MixinRenderBlocks.java | 8 +++++ .../MixinRenderBlockCampfire.java | 35 +++++++++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 src/main/java/com/gtnewhorizons/angelica/mixins/late/client/campfirebackport/MixinRenderBlockCampfire.java diff --git a/dependencies.gradle b/dependencies.gradle index 0d2c850d3..c1bea7013 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -85,6 +85,7 @@ dependencies { compileOnly("com.github.GTNewHorizons:NotEnoughIds-Legacy:1.4.7:dev") // ASM Version compileOnly("com.github.GTNewHorizons:Jabba:1.3.1:dev") + compileOnly(rfg.deobf("curse.maven:campfirebackport-387444:4611675")) // HMMMMM compileOnly(rfg.deobf("curse.maven:journeymap-32274:2367915")) diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java index d95ecf4d6..983fa34ea 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/Mixins.java @@ -194,6 +194,11 @@ public enum Mixins { "angelica.animation.MixinRenderBlockFluid", "angelica.animation.MixinWorldRenderer", "angelica.animation.MixinRenderItem")), + + SPEEDUP_CAMPFIRE_BACKPORT_ANIMATIONS(new Builder("Add animation speedup support to Campfire Backport").setPhase(Phase.LATE) + .addTargetedMod(TargetedMod.CAMPFIRE_BACKPORT).setSide(Side.CLIENT) + .setApplyIf(() -> AngelicaConfig.speedupAnimations) + .addMixinClasses("client.campfirebackport.MixinRenderBlockCampfire")), IC2_FLUID_RENDER_FIX(new Builder("IC2 Fluid Render Fix").setPhase(Phase.EARLY).setSide(Side.CLIENT) .addTargetedMod(TargetedMod.IC2).setApplyIf(() -> AngelicaConfig.speedupAnimations) diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java b/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java index e1e0d3651..b7f4156be 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/TargetedMod.java @@ -9,6 +9,7 @@ public enum TargetedMod { , OPTIFINE("Optifine", "optifine.OptiFineForgeTweaker", "Optifine") , ARCHAICFIX("ArchaicFix", "org.embeddedt.archaicfix.ArchaicCore", "archaicfix") , BOTANIA("Botania", null, "Botania") + , CAMPFIRE_BACKPORT("CampfireBackport", null, "campfirebackport") , CHICKENCHUNKS("ChickenChunks", null, "ChickenChunks") , COFHCORE("CoFHCore", "cofh.asm.LoadingPlugin", "CoFHCore") , DYNAMIC_SURROUNDINGS_MIST("Dynamic Surroundings", "org.blockartistry.mod.DynSurround.mixinplugin.DynamicSurroundingsEarlyMixins", "dsurround") diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java index e204d5c3f..ec20ffa60 100644 --- a/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/early/angelica/animation/MixinRenderBlocks.java @@ -66,6 +66,14 @@ public class MixinRenderBlocks implements ITexturesCache { return icon; } + + @Inject(method = "drawCrossedSquares", at = @At("HEAD")) + public void angelica$markCrossedSquaresAnimationForUpdate(IIcon icon, double p_147765_2_, double p_147765_4_, double p_147765_6_, float p_147765_8_, + CallbackInfo ci) { + AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess); + + this.renderedSprites.add(icon); + } @Override public Set getRenderedTextures() { diff --git a/src/main/java/com/gtnewhorizons/angelica/mixins/late/client/campfirebackport/MixinRenderBlockCampfire.java b/src/main/java/com/gtnewhorizons/angelica/mixins/late/client/campfirebackport/MixinRenderBlockCampfire.java new file mode 100644 index 000000000..7d02bba08 --- /dev/null +++ b/src/main/java/com/gtnewhorizons/angelica/mixins/late/client/campfirebackport/MixinRenderBlockCampfire.java @@ -0,0 +1,35 @@ +package com.gtnewhorizons.angelica.mixins.late.client.campfirebackport; + +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.ModifyArgs; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +import com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache; +import com.gtnewhorizons.angelica.utils.AnimationsRenderUtils; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.util.IIcon; + +@Mixin(targets = "connor135246.campfirebackport.client.rendering.RenderBlockCampfire", remap = false) +public class MixinRenderBlockCampfire { + @Inject(method = "renderFace", at = @At("HEAD")) + private static void angelica$beforeRenderFace(double x, double y, double z, Block block, RenderBlocks renderer, IIcon icon, int side, CallbackInfo ci) { + AnimationsRenderUtils.markBlockTextureForUpdate(icon, renderer.blockAccess); + ((ITexturesCache)renderer).getRenderedTextures().add(icon); + } + + @ModifyArgs(method = "renderFire", at = @At(value = "INVOKE", target = "Lconnor135246/campfirebackport/client/rendering/RenderBlockCampfire;drawCrossedSquaresTwoIcons(Lnet/minecraft/util/IIcon;Lnet/minecraft/util/IIcon;DDDF)V")) + private static void angelica$onDrawCrossedSquaresTwoIcons(Args args, double x, double y, double z, Block block, RenderBlocks renderer, boolean mix) { + IIcon icon1 = (IIcon)args.get(0); + AnimationsRenderUtils.markBlockTextureForUpdate(icon1, renderer.blockAccess); + ((ITexturesCache)renderer).getRenderedTextures().add(icon1); + + IIcon icon2 = (IIcon)args.get(1); + AnimationsRenderUtils.markBlockTextureForUpdate(icon2, renderer.blockAccess); + ((ITexturesCache)renderer).getRenderedTextures().add(icon2); + } +}