| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import net.fabricmc.api.EnvType;
|
| 4 | import net.fabricmc.api.Environment;
|
| 5 | import net.minecraft.client.model.geom.ModelLayers;
|
| 6 | import net.minecraft.client.model.monster.creaking.CreakingModel;
|
| 7 | import net.minecraft.client.renderer.entity.layers.LivingEntityEmissiveLayer;
|
| 8 | import net.minecraft.client.renderer.entity.state.CreakingRenderState;
|
| 9 | import net.minecraft.client.renderer.rendertype.RenderTypes;
|
| 10 | import net.minecraft.resources.Identifier;
|
| 11 | import net.minecraft.world.entity.monster.creaking.Creaking;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public class CreakingRenderer<T extends Creaking> extends MobRenderer<T, CreakingRenderState, CreakingModel> {
|
| 15 | private static final Identifier TEXTURE_LOCATION = Identifier.withDefaultNamespace("textures/entity/creaking/creaking.png");
|
| 16 | private static final Identifier EYES_TEXTURE_LOCATION = Identifier.withDefaultNamespace("textures/entity/creaking/creaking_eyes.png");
|
| 17 |
|
| 18 | public CreakingRenderer(final EntityRendererProvider.Context context) {
|
| 19 | super(context, new CreakingModel(context.bakeLayer(ModelLayers.CREAKING)), 0.6F);
|
| 20 | this.addLayer(
|
| 21 | new LivingEntityEmissiveLayer<>(
|
| 22 | this,
|
| 23 | renderState -> EYES_TEXTURE_LOCATION,
|
| 24 | (state, ageInTicks) -> state.eyesGlowing ? 1.0F : 0.0F,
|
| 25 | new CreakingModel(context.bakeLayer(ModelLayers.CREAKING_EYES)),
|
| 26 | RenderTypes::eyes,
|
| 27 | true
|
| 28 | )
|
| 29 | );
|
| 30 | }
|
| 31 |
|
| 32 | public Identifier getTextureLocation(final CreakingRenderState state) {
|
| 33 | return TEXTURE_LOCATION;
|
| 34 | }
|
| 35 |
|
| 36 | public CreakingRenderState createRenderState() {
|
| 37 | return new CreakingRenderState();
|
| 38 | }
|
| 39 |
|
| 40 | public void extractRenderState(final T entity, final CreakingRenderState state, final float partialTicks) {
|
| 41 | super.extractRenderState(entity, state, partialTicks);
|
| 42 | state.attackAnimationState.copyFrom(entity.attackAnimationState);
|
| 43 | state.invulnerabilityAnimationState.copyFrom(entity.invulnerabilityAnimationState);
|
| 44 | state.deathAnimationState.copyFrom(entity.deathAnimationState);
|
| 45 | if (entity.isTearingDown()) {
|
| 46 | state.deathTime = 0.0F;
|
| 47 | state.hasRedOverlay = false;
|
| 48 | state.eyesGlowing = entity.hasGlowingEyes();
|
| 49 | } else {
|
| 50 | state.eyesGlowing = entity.isActive();
|
| 51 | }
|
| 52 |
|
| 53 | state.canMove = entity.canMove();
|
| 54 | }
|
| 55 | }
|
| 56 |
|