40 lines
1.7 KiB
Java
40 lines
1.7 KiB
Java
package net.minecraft.client.renderer.entity;
|
|
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.math.Axis;
|
|
import net.fabricmc.api.EnvType;
|
|
import net.fabricmc.api.Environment;
|
|
import net.minecraft.client.model.IronGolemModel;
|
|
import net.minecraft.client.model.geom.ModelLayers;
|
|
import net.minecraft.client.renderer.entity.layers.IronGolemCrackinessLayer;
|
|
import net.minecraft.client.renderer.entity.layers.IronGolemFlowerLayer;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.world.entity.animal.IronGolem;
|
|
|
|
@Environment(EnvType.CLIENT)
|
|
public class IronGolemRenderer extends MobRenderer<IronGolem, IronGolemModel<IronGolem>> {
|
|
private static final ResourceLocation GOLEM_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/iron_golem/iron_golem.png");
|
|
|
|
public IronGolemRenderer(EntityRendererProvider.Context context) {
|
|
super(context, new IronGolemModel<>(context.bakeLayer(ModelLayers.IRON_GOLEM)), 0.7F);
|
|
this.addLayer(new IronGolemCrackinessLayer(this));
|
|
this.addLayer(new IronGolemFlowerLayer(this, context.getBlockRenderDispatcher()));
|
|
}
|
|
|
|
/**
|
|
* Returns the location of an entity's texture.
|
|
*/
|
|
public ResourceLocation getTextureLocation(IronGolem entity) {
|
|
return GOLEM_LOCATION;
|
|
}
|
|
|
|
protected void setupRotations(IronGolem entity, PoseStack poseStack, float bob, float yBodyRot, float partialTick, float scale) {
|
|
super.setupRotations(entity, poseStack, bob, yBodyRot, partialTick, scale);
|
|
if (!(entity.walkAnimation.speed() < 0.01)) {
|
|
float f = 13.0F;
|
|
float g = entity.walkAnimation.position(partialTick) + 6.0F;
|
|
float h = (Math.abs(g % 13.0F - 6.5F) - 3.25F) / 3.25F;
|
|
poseStack.mulPose(Axis.ZP.rotationDegrees(6.5F * h));
|
|
}
|
|
}
|
|
}
|