| 1 | package net.minecraft.client.renderer.entity.layers;
|
| 2 |
|
| 3 | import com.mojang.blaze3d.vertex.PoseStack;
|
| 4 | import com.mojang.math.Axis;
|
| 5 | import net.fabricmc.api.EnvType;
|
| 6 | import net.fabricmc.api.Environment;
|
| 7 | import net.minecraft.client.model.animal.cow.CowModel;
|
| 8 | import net.minecraft.client.renderer.SubmitNodeCollector;
|
| 9 | import net.minecraft.client.renderer.block.BlockModelRenderState;
|
| 10 | import net.minecraft.client.renderer.entity.LivingEntityRenderer;
|
| 11 | import net.minecraft.client.renderer.entity.RenderLayerParent;
|
| 12 | import net.minecraft.client.renderer.entity.state.MushroomCowRenderState;
|
| 13 |
|
| 14 | @Environment(EnvType.CLIENT)
|
| 15 | public class MushroomCowMushroomLayer extends RenderLayer<MushroomCowRenderState, CowModel> {
|
| 16 | public MushroomCowMushroomLayer(final RenderLayerParent<MushroomCowRenderState, CowModel> renderer) {
|
| 17 | super(renderer);
|
| 18 | }
|
| 19 |
|
| 20 | public void submit(
|
| 21 | final PoseStack poseStack,
|
| 22 | final SubmitNodeCollector submitNodeCollector,
|
| 23 | final int lightCoords,
|
| 24 | final MushroomCowRenderState state,
|
| 25 | final float yRot,
|
| 26 | final float xRot
|
| 27 | ) {
|
| 28 | if (!state.isBaby && !state.mushroomModel.isEmpty()) {
|
| 29 | boolean appearsGlowingWithInvisibility = state.appearsGlowing() && state.isInvisible;
|
| 30 | if (!state.isInvisible || appearsGlowingWithInvisibility) {
|
| 31 | int overlayCoords = LivingEntityRenderer.getOverlayCoords(state, 0.0F);
|
| 32 | poseStack.pushPose();
|
| 33 | poseStack.translate(0.2F, -0.35F, 0.5F);
|
| 34 | poseStack.rotateDegrees(Axis.YP, -48.0F);
|
| 35 | poseStack.scale(-1.0F, -1.0F, 1.0F);
|
| 36 | poseStack.translate(-0.5F, -0.5F, -0.5F);
|
| 37 | this.submitMushroomBlock(
|
| 38 | poseStack, submitNodeCollector, lightCoords, appearsGlowingWithInvisibility, state.outlineColor, state.mushroomModel, overlayCoords
|
| 39 | );
|
| 40 | poseStack.popPose();
|
| 41 | poseStack.pushPose();
|
| 42 | poseStack.translate(0.2F, -0.35F, 0.5F);
|
| 43 | poseStack.rotateDegrees(Axis.YP, 42.0F);
|
| 44 | poseStack.translate(0.1F, 0.0F, -0.6F);
|
| 45 | poseStack.rotateDegrees(Axis.YP, -48.0F);
|
| 46 | poseStack.scale(-1.0F, -1.0F, 1.0F);
|
| 47 | poseStack.translate(-0.5F, -0.5F, -0.5F);
|
| 48 | this.submitMushroomBlock(
|
| 49 | poseStack, submitNodeCollector, lightCoords, appearsGlowingWithInvisibility, state.outlineColor, state.mushroomModel, overlayCoords
|
| 50 | );
|
| 51 | poseStack.popPose();
|
| 52 | poseStack.pushPose();
|
| 53 | this.getParentModel().getHead().translateAndRotate(poseStack);
|
| 54 | poseStack.translate(0.0F, -0.7F, -0.2F);
|
| 55 | poseStack.rotateDegrees(Axis.YP, -78.0F);
|
| 56 | poseStack.scale(-1.0F, -1.0F, 1.0F);
|
| 57 | poseStack.translate(-0.5F, -0.5F, -0.5F);
|
| 58 | this.submitMushroomBlock(
|
| 59 | poseStack, submitNodeCollector, lightCoords, appearsGlowingWithInvisibility, state.outlineColor, state.mushroomModel, overlayCoords
|
| 60 | );
|
| 61 | poseStack.popPose();
|
| 62 | }
|
| 63 | }
|
| 64 | }
|
| 65 |
|
| 66 | private void submitMushroomBlock(
|
| 67 | final PoseStack poseStack,
|
| 68 | final SubmitNodeCollector submitNodeCollector,
|
| 69 | final int lightCoords,
|
| 70 | final boolean appearsGlowingWithInvisibility,
|
| 71 | final int outlineColor,
|
| 72 | final BlockModelRenderState mushroomModel,
|
| 73 | final int overlayCoords
|
| 74 | ) {
|
| 75 | if (appearsGlowingWithInvisibility) {
|
| 76 | mushroomModel.submitOnlyOutline(poseStack, submitNodeCollector, lightCoords, overlayCoords, outlineColor);
|
| 77 | } else {
|
| 78 | mushroomModel.submit(poseStack, submitNodeCollector, lightCoords, overlayCoords, outlineColor);
|
| 79 | }
|
| 80 | }
|
| 81 | }
|
| 82 |
|