AxolotlRenderer.java

net.minecraft.client.renderer.entity.AxolotlRenderer

信息

  • 全限定名:net.minecraft.client.renderer.entity.AxolotlRenderer
  • 类型:public class
  • 包:net.minecraft.client.renderer.entity
  • 源码路径:src/main/java/net/minecraft/client/renderer/entity/AxolotlRenderer.java
  • 起始行号:L18
  • 继承:AgeableMobRenderer<Axolotl,AxolotlRenderState,EntityModel>
  • 职责:

    TODO

字段/常量

  • TEXTURE_BY_TYPE
    • 类型: Map<Axolotl.Variant,AxolotlRenderer.AxolotlTextures>
    • 修饰符: private static final
    • 源码定位: L19
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.renderer.entity.AxolotlRenderer.AxolotlTextures
    • 类型: record
    • 修饰符: private
    • 源码定位: L62
    • 说明:

      TODO

构造器

public AxolotlRenderer(EntityRendererProvider.Context context) @ L32

  • 构造器名:AxolotlRenderer
  • 源码定位:L32
  • 修饰符:public

参数:

  • context: EntityRendererProvider.Context

说明:

TODO

方法

下面的方法块按源码顺序生成。

public Identifier getTextureLocation(AxolotlRenderState state) @ L36

  • 方法名:getTextureLocation
  • 源码定位:L36
  • 返回类型:Identifier
  • 修饰符:public

参数:

  • state: AxolotlRenderState

说明:

TODO

public AxolotlRenderState createRenderState() @ L41

  • 方法名:createRenderState
  • 源码定位:L41
  • 返回类型:AxolotlRenderState
  • 修饰符:public

参数:

说明:

TODO

public void extractRenderState(Axolotl entity, AxolotlRenderState state, float partialTicks) @ L45

  • 方法名:extractRenderState
  • 源码定位:L45
  • 返回类型:void
  • 修饰符:public

参数:

  • entity: Axolotl
  • state: AxolotlRenderState
  • partialTicks: float

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class AxolotlRenderer extends AgeableMobRenderer<Axolotl, AxolotlRenderState, EntityModel<AxolotlRenderState>> {
    private static final Map<Axolotl.Variant, AxolotlRenderer.AxolotlTextures> TEXTURE_BY_TYPE = Util.make(
        Maps.newHashMap(),
        map -> {
            for (Axolotl.Variant variant : Axolotl.Variant.values()) {
                AxolotlRenderer.AxolotlTextures textures = new AxolotlRenderer.AxolotlTextures(
                    Identifier.withDefaultNamespace(String.format(Locale.ROOT, "textures/entity/axolotl/axolotl_%s.png", variant.getName())),
                    Identifier.withDefaultNamespace(String.format(Locale.ROOT, "textures/entity/axolotl/axolotl_%s_baby.png", variant.getName()))
                );
                map.put(variant, textures);
            }
        }
    );
 
    public AxolotlRenderer(EntityRendererProvider.Context context) {
        super(context, new AdultAxolotlModel(context.bakeLayer(ModelLayers.AXOLOTL)), new BabyAxolotlModel(context.bakeLayer(ModelLayers.AXOLOTL_BABY)), 0.5F);
    }
 
    public Identifier getTextureLocation(AxolotlRenderState state) {
        AxolotlRenderer.AxolotlTextures textures = TEXTURE_BY_TYPE.get(state.variant);
        return state.isBaby ? textures.baby : textures.adult;
    }
 
    public AxolotlRenderState createRenderState() {
        return new AxolotlRenderState();
    }
 
    public void extractRenderState(Axolotl entity, AxolotlRenderState state, float partialTicks) {
        super.extractRenderState(entity, state, partialTicks);
        state.variant = entity.getVariant();
        state.playingDeadFactor = entity.playingDeadAnimator.getFactor(partialTicks);
        state.inWaterFactor = entity.inWaterAnimator.getFactor(partialTicks);
        state.onGroundFactor = entity.onGroundAnimator.getFactor(partialTicks);
        state.movingFactor = entity.movingAnimator.getFactor(partialTicks);
        state.swimAnimation.copyFrom(entity.swimAnimationState);
        state.walkAnimationState.copyFrom(entity.walkAnimationState);
        state.walkUnderWaterAnimationState.copyFrom(entity.walkUnderWaterAnimationState);
        state.idleOnGroundAnimationState.copyFrom(entity.idleOnGroundAnimationState);
        state.idleUnderWaterOnGroundAnimationState.copyFrom(entity.idleUnderWaterOnGroundAnimationState);
        state.idleUnderWaterAnimationState.copyFrom(entity.idleUnderWaterAnimationState);
        state.playDeadAnimationState.copyFrom(entity.playDeadAnimationState);
    }
 
    @OnlyIn(Dist.CLIENT)
    private record AxolotlTextures(Identifier adult, Identifier baby) {
    }
}

引用的其他类

  • AdultAxolotlModel

    • 引用位置: 构造调用
    • 关联成员: AdultAxolotlModel()
  • BabyAxolotlModel

    • 引用位置: 构造调用
    • 关联成员: BabyAxolotlModel()
  • AgeableMobRenderer

    • 引用位置: 继承
  • EntityRendererProvider

    • 引用位置: 参数
  • AxolotlRenderState

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: AxolotlRenderState()
  • Identifier

    • 引用位置: 方法调用/返回值
    • 关联成员: Identifier.withDefaultNamespace()
  • Util

    • 引用位置: 方法调用
    • 关联成员: Util.make()
  • Axolotl

    • 引用位置: 参数/字段/方法调用
    • 关联成员: Axolotl.Variant.values()