| 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.animal.ghast.HappyGhastHarnessModel;
|
| 6 | import net.minecraft.client.model.animal.ghast.HappyGhastModel;
|
| 7 | import net.minecraft.client.model.geom.ModelLayers;
|
| 8 | import net.minecraft.client.renderer.entity.layers.RopesLayer;
|
| 9 | import net.minecraft.client.renderer.entity.layers.SimpleEquipmentLayer;
|
| 10 | import net.minecraft.client.renderer.entity.state.HappyGhastRenderState;
|
| 11 | import net.minecraft.client.resources.model.EquipmentClientInfo;
|
| 12 | import net.minecraft.resources.Identifier;
|
| 13 | import net.minecraft.world.entity.EquipmentSlot;
|
| 14 | import net.minecraft.world.entity.animal.happyghast.HappyGhast;
|
| 15 | import net.minecraft.world.phys.AABB;
|
| 16 |
|
| 17 | @Environment(EnvType.CLIENT)
|
| 18 | public class HappyGhastRenderer extends AgeableMobRenderer<HappyGhast, HappyGhastRenderState, HappyGhastModel> {
|
| 19 | private static final Identifier GHAST_LOCATION = Identifier.withDefaultNamespace("textures/entity/ghast/happy_ghast.png");
|
| 20 | private static final Identifier GHAST_BABY_LOCATION = Identifier.withDefaultNamespace("textures/entity/ghast/happy_ghast_baby.png");
|
| 21 | private static final Identifier GHAST_ROPES = Identifier.withDefaultNamespace("textures/entity/ghast/happy_ghast_ropes.png");
|
| 22 |
|
| 23 | public HappyGhastRenderer(final EntityRendererProvider.Context context) {
|
| 24 | super(context, new HappyGhastModel(context.bakeLayer(ModelLayers.HAPPY_GHAST)), new HappyGhastModel(context.bakeLayer(ModelLayers.HAPPY_GHAST_BABY)), 2.0F);
|
| 25 | this.addLayer(
|
| 26 | new SimpleEquipmentLayer<>(
|
| 27 | this,
|
| 28 | context.getEquipmentRenderer(),
|
| 29 | EquipmentClientInfo.LayerType.HAPPY_GHAST_BODY,
|
| 30 | state -> state.bodyItem,
|
| 31 | new HappyGhastHarnessModel(context.bakeLayer(ModelLayers.HAPPY_GHAST_HARNESS)),
|
| 32 | new HappyGhastHarnessModel(context.bakeLayer(ModelLayers.HAPPY_GHAST_BABY_HARNESS))
|
| 33 | )
|
| 34 | );
|
| 35 | this.addLayer(new RopesLayer<>(this, context.getModelSet(), GHAST_ROPES));
|
| 36 | }
|
| 37 |
|
| 38 | public Identifier getTextureLocation(final HappyGhastRenderState state) {
|
| 39 | return state.isBaby ? GHAST_BABY_LOCATION : GHAST_LOCATION;
|
| 40 | }
|
| 41 |
|
| 42 | public HappyGhastRenderState createRenderState() {
|
| 43 | return new HappyGhastRenderState();
|
| 44 | }
|
| 45 |
|
| 46 | protected AABB getBoundingBoxForCulling(final HappyGhast entity, final float partialTicks) {
|
| 47 | AABB aabb = super.getBoundingBoxForCulling(entity, partialTicks);
|
| 48 | float height = entity.getBbHeight();
|
| 49 | return aabb.setMinY(aabb.minY - height / 2.0F);
|
| 50 | }
|
| 51 |
|
| 52 | public void extractRenderState(final HappyGhast entity, final HappyGhastRenderState state, final float partialTicks) {
|
| 53 | super.extractRenderState(entity, state, partialTicks);
|
| 54 | state.bodyItem = entity.getItemBySlot(EquipmentSlot.BODY).copy();
|
| 55 | state.isRidden = entity.isVehicle();
|
| 56 | state.isLeashHolder = entity.isLeashHolder();
|
| 57 | }
|
| 58 | }
|
| 59 |
|