| 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.bee.AdultBeeModel;
|
| 6 | import net.minecraft.client.model.animal.bee.BabyBeeModel;
|
| 7 | import net.minecraft.client.model.animal.bee.BeeModel;
|
| 8 | import net.minecraft.client.model.geom.ModelLayers;
|
| 9 | import net.minecraft.client.renderer.entity.state.BeeRenderState;
|
| 10 | import net.minecraft.resources.Identifier;
|
| 11 | import net.minecraft.world.entity.animal.bee.Bee;
|
| 12 |
|
| 13 | @Environment(EnvType.CLIENT)
|
| 14 | public class BeeRenderer extends AgeableMobRenderer<Bee, BeeRenderState, BeeModel> {
|
| 15 | private static final Identifier ANGRY_BEE_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_angry.png");
|
| 16 | private static final Identifier ANGRY_NECTAR_BEE_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_angry_nectar.png");
|
| 17 | private static final Identifier BEE_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee.png");
|
| 18 | private static final Identifier NECTAR_BEE_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_nectar.png");
|
| 19 | private static final Identifier ANGRY_BEE_BABY_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_angry_baby.png");
|
| 20 | private static final Identifier ANGRY_NECTAR_BEE_BABY_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_angry_nectar_baby.png");
|
| 21 | private static final Identifier BEE_BABY_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_baby.png");
|
| 22 | private static final Identifier NECTAR_BEE_BABY_TEXTURE = Identifier.withDefaultNamespace("textures/entity/bee/bee_nectar_baby.png");
|
| 23 |
|
| 24 | public BeeRenderer(final EntityRendererProvider.Context context) {
|
| 25 | super(context, new AdultBeeModel(context.bakeLayer(ModelLayers.BEE)), new BabyBeeModel(context.bakeLayer(ModelLayers.BEE_BABY)), 0.4F);
|
| 26 | }
|
| 27 |
|
| 28 | public Identifier getTextureLocation(final BeeRenderState state) {
|
| 29 | if (state.isAngry) {
|
| 30 | if (state.hasNectar) {
|
| 31 | return state.isBaby ? ANGRY_NECTAR_BEE_BABY_TEXTURE : ANGRY_NECTAR_BEE_TEXTURE;
|
| 32 | } else {
|
| 33 | return state.isBaby ? ANGRY_BEE_BABY_TEXTURE : ANGRY_BEE_TEXTURE;
|
| 34 | }
|
| 35 | } else if (state.hasNectar) {
|
| 36 | return state.isBaby ? NECTAR_BEE_BABY_TEXTURE : NECTAR_BEE_TEXTURE;
|
| 37 | } else {
|
| 38 | return state.isBaby ? BEE_BABY_TEXTURE : BEE_TEXTURE;
|
| 39 | }
|
| 40 | }
|
| 41 |
|
| 42 | public BeeRenderState createRenderState() {
|
| 43 | return new BeeRenderState();
|
| 44 | }
|
| 45 |
|
| 46 | public void extractRenderState(final Bee entity, final BeeRenderState state, final float partialTicks) {
|
| 47 | super.extractRenderState(entity, state, partialTicks);
|
| 48 | state.rollAmount = entity.getRollAmount(partialTicks);
|
| 49 | state.hasStinger = !entity.hasStung();
|
| 50 | state.isOnGround = entity.onGround() && entity.getDeltaMovement().lengthSqr() < 1.0E-7;
|
| 51 | state.isAngry = entity.isAngry();
|
| 52 | state.hasNectar = entity.hasNectar();
|
| 53 | }
|
| 54 | }
|
| 55 |
|