| 1 | package net.minecraft.client.renderer.entity;
|
| 2 |
|
| 3 | import com.mojang.blaze3d.vertex.PoseStack;
|
| 4 | import net.fabricmc.api.EnvType;
|
| 5 | import net.fabricmc.api.Environment;
|
| 6 | import net.minecraft.client.model.geom.ModelLayers;
|
| 7 | import net.minecraft.client.model.monster.wither.WitherBossModel;
|
| 8 | import net.minecraft.client.renderer.entity.layers.WitherArmorLayer;
|
| 9 | import net.minecraft.client.renderer.entity.state.WitherRenderState;
|
| 10 | import net.minecraft.core.BlockPos;
|
| 11 | import net.minecraft.resources.Identifier;
|
| 12 | import net.minecraft.util.Mth;
|
| 13 | import net.minecraft.world.entity.boss.wither.WitherBoss;
|
| 14 |
|
| 15 | @Environment(EnvType.CLIENT)
|
| 16 | public class WitherBossRenderer extends MobRenderer<WitherBoss, WitherRenderState, WitherBossModel> {
|
| 17 | private static final Identifier WITHER_INVULNERABLE_LOCATION = Identifier.withDefaultNamespace("textures/entity/wither/wither_invulnerable.png");
|
| 18 | private static final Identifier WITHER_LOCATION = Identifier.withDefaultNamespace("textures/entity/wither/wither.png");
|
| 19 |
|
| 20 | public WitherBossRenderer(final EntityRendererProvider.Context context) {
|
| 21 | super(context, new WitherBossModel(context.bakeLayer(ModelLayers.WITHER)), 1.0F);
|
| 22 | this.addLayer(new WitherArmorLayer(this, context.getModelSet()));
|
| 23 | }
|
| 24 |
|
| 25 | protected int getBlockLightLevel(final WitherBoss entity, final BlockPos blockPos) {
|
| 26 | return 15;
|
| 27 | }
|
| 28 |
|
| 29 | public Identifier getTextureLocation(final WitherRenderState state) {
|
| 30 | int invulnerableTicks = Mth.floor(state.invulnerableTicks);
|
| 31 | return invulnerableTicks > 0 && (invulnerableTicks > 80 || invulnerableTicks / 5 % 2 != 1) ? WITHER_INVULNERABLE_LOCATION : WITHER_LOCATION;
|
| 32 | }
|
| 33 |
|
| 34 | public WitherRenderState createRenderState() {
|
| 35 | return new WitherRenderState();
|
| 36 | }
|
| 37 |
|
| 38 | protected void scale(final WitherRenderState state, final PoseStack poseStack) {
|
| 39 | float scale = 2.0F;
|
| 40 | if (state.invulnerableTicks > 0.0F) {
|
| 41 | scale -= state.invulnerableTicks / 220.0F * 0.5F;
|
| 42 | }
|
| 43 |
|
| 44 | poseStack.scale(scale, scale, scale);
|
| 45 | }
|
| 46 |
|
| 47 | public void extractRenderState(final WitherBoss entity, final WitherRenderState state, final float partialTicks) {
|
| 48 | super.extractRenderState(entity, state, partialTicks);
|
| 49 | int invulnerableTicks = entity.getInvulnerableTicks();
|
| 50 | state.invulnerableTicks = invulnerableTicks > 0 ? invulnerableTicks - partialTicks : 0.0F;
|
| 51 | System.arraycopy(entity.getHeadXRots(), 0, state.xHeadRots, 0, state.xHeadRots.length);
|
| 52 | System.arraycopy(entity.getHeadYRots(), 0, state.yHeadRots, 0, state.yHeadRots.length);
|
| 53 | state.isPowered = entity.isPowered();
|
| 54 | }
|
| 55 | }
|
| 56 |
|