75 lines
3.3 KiB
Java
75 lines
3.3 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.client.renderer.entity;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import net.minecraft.client.model.SkullModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.model.geom.PartPose;
|
|
import net.minecraft.client.model.geom.builders.CubeListBuilder;
|
|
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
|
import net.minecraft.client.model.geom.builders.MeshDefinition;
|
|
import net.minecraft.client.model.geom.builders.PartDefinition;
|
|
import net.minecraft.client.renderer.SubmitNodeCollector;
|
|
import net.minecraft.client.renderer.entity.EntityRenderer;
|
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
import net.minecraft.client.renderer.entity.state.WitherSkullRenderState;
|
|
import net.minecraft.client.renderer.state.CameraRenderState;
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
|
import net.minecraft.core.BlockPos;
|
|
import net.minecraft.resources.Identifier;
|
|
import net.minecraft.world.entity.projectile.WitherSkull;
|
|
|
|
public class WitherSkullRenderer
|
|
extends EntityRenderer<WitherSkull, WitherSkullRenderState> {
|
|
private static final Identifier WITHER_INVULNERABLE_LOCATION = Identifier.withDefaultNamespace("textures/entity/wither/wither_invulnerable.png");
|
|
private static final Identifier WITHER_LOCATION = Identifier.withDefaultNamespace("textures/entity/wither/wither.png");
|
|
private final SkullModel model;
|
|
|
|
public WitherSkullRenderer(EntityRendererProvider.Context context) {
|
|
super(context);
|
|
this.model = new SkullModel(context.bakeLayer(ModelLayers.WITHER_SKULL));
|
|
}
|
|
|
|
public static LayerDefinition createSkullLayer() {
|
|
MeshDefinition mesh = new MeshDefinition();
|
|
PartDefinition root = mesh.getRoot();
|
|
root.addOrReplaceChild("head", CubeListBuilder.create().texOffs(0, 35).addBox(-4.0f, -8.0f, -4.0f, 8.0f, 8.0f, 8.0f), PartPose.ZERO);
|
|
return LayerDefinition.create(mesh, 64, 64);
|
|
}
|
|
|
|
@Override
|
|
protected int getBlockLightLevel(WitherSkull entity, BlockPos blockPos) {
|
|
return 15;
|
|
}
|
|
|
|
@Override
|
|
public void submit(WitherSkullRenderState state, PoseStack poseStack, SubmitNodeCollector submitNodeCollector, CameraRenderState camera) {
|
|
poseStack.pushPose();
|
|
poseStack.scale(-1.0f, -1.0f, 1.0f);
|
|
submitNodeCollector.submitModel(this.model, state.modelState, poseStack, this.model.renderType(this.getTextureLocation(state)), state.lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor, null);
|
|
poseStack.popPose();
|
|
super.submit(state, poseStack, submitNodeCollector, camera);
|
|
}
|
|
|
|
private Identifier getTextureLocation(WitherSkullRenderState state) {
|
|
return state.isDangerous ? WITHER_INVULNERABLE_LOCATION : WITHER_LOCATION;
|
|
}
|
|
|
|
@Override
|
|
public WitherSkullRenderState createRenderState() {
|
|
return new WitherSkullRenderState();
|
|
}
|
|
|
|
@Override
|
|
public void extractRenderState(WitherSkull entity, WitherSkullRenderState state, float partialTicks) {
|
|
super.extractRenderState(entity, state, partialTicks);
|
|
state.isDangerous = entity.isDangerous();
|
|
state.modelState.animationPos = 0.0f;
|
|
state.modelState.yRot = entity.getYRot(partialTicks);
|
|
state.modelState.xRot = entity.getXRot(partialTicks);
|
|
}
|
|
}
|
|
|