MixinRenderBlockCampfire

基本信息

属性 值
类名 com.gtnewhorizons.angelicacompat.mixins.late.client.campfirebackport.MixinRenderBlockCampfire
目标类 connor135246.campfirebackport.client.rendering.RenderBlockCampfire(remap = false)
类级注解 @ThreadSafeISBRH(perThread = false)
Mixin 阶段 LATE
Mixin 启用条件 PatchesConfig.patchCampfireBackport == true
Mixin 注入方法 renderFace (@Inject HEAD)、renderFire 内 drawCrossedSquaresTwoIcons 调用 (@ModifyArgs)
启用版本 Minecraft 1.7.10(仅客户端)

功能

Campfire Backport(campfirebackport mod)的 RenderBlockCampfire 渲染篝火的烟雾/火焰动画——纹理会在多个 tick 内逐帧变化。Angelica 的 Sodium 路径为 RenderBlocks 引入了 ITexturesCache.getRenderedTextures()(动画纹理缓存),需要在每次调用 renderFace/drawCrossedSquaresTwoIcons 时把本次用到的 IIcon 登记到缓存里,并调用 AnimationsRenderUtils.markBlockTextureForUpdate(icon, blockAccess) 通知动画时间线。

本 Mixin 完成两件事:

1. 类级 @ThreadSafeISBRH(perThread=false) 声明

直接用注解告知 Angelica 本类仍然同步——动画纹理缓存对每个 worker 线程独立,但 per-thread 请求相同,因为缓存本身就是线程局部的。perThread=false 意味着本类依然由主线程渲染(Angelica 会按此分配)。

2. 注入动画纹理登记

@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);
}
  • renderFace 每次篝火方块绘制前,把当前面用到的 IIcon 登记;
  • renderFire 中的 drawCrossedSquaresTwoIcons 接收 2 个 icon(火焰层 + 烟雾层),逐个登记。

第三方 mod 集成

依赖 包 是否必需
com.gtnewhorizons.angelica.api.ThreadSafeISBRH Angelica 是
com.gtnewhorizons.angelica.mixins.interfaces.ITexturesCache Angelica 是
com.gtnewhorizons.angelica.utils.AnimationsRenderUtils Angelica 是
connor135246.campfirebackport.client.rendering.RenderBlockCampfire CampfireBackport 是(注入目标)

相关条目