| 1 | package net.minecraft.client.renderer.entity;
|
| 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.geom.ModelLayers;
|
| 8 | import net.minecraft.client.model.object.projectile.TridentModel;
|
| 9 | import net.minecraft.client.renderer.SubmitNodeCollector;
|
| 10 | import net.minecraft.client.renderer.entity.state.ThrownTridentRenderState;
|
| 11 | import net.minecraft.client.renderer.rendertype.RenderTypes;
|
| 12 | import net.minecraft.client.renderer.state.level.CameraRenderState;
|
| 13 | import net.minecraft.client.renderer.texture.OverlayTexture;
|
| 14 | import net.minecraft.resources.Identifier;
|
| 15 | import net.minecraft.util.Unit;
|
| 16 | import net.minecraft.world.entity.projectile.arrow.ThrownTrident;
|
| 17 | import net.minecraft.world.phys.AABB;
|
| 18 |
|
| 19 | @Environment(EnvType.CLIENT)
|
| 20 | public class ThrownTridentRenderer extends EntityRenderer<ThrownTrident, ThrownTridentRenderState> {
|
| 21 | public static final Identifier TRIDENT_LOCATION = Identifier.withDefaultNamespace("textures/entity/trident/trident.png");
|
| 22 | private final TridentModel model;
|
| 23 |
|
| 24 | public ThrownTridentRenderer(final EntityRendererProvider.Context context) {
|
| 25 | super(context);
|
| 26 | this.model = new TridentModel(context.bakeLayer(ModelLayers.TRIDENT));
|
| 27 | }
|
| 28 |
|
| 29 | public void submit(
|
| 30 | final ThrownTridentRenderState state, final PoseStack poseStack, final SubmitNodeCollector submitNodeCollector, final CameraRenderState camera
|
| 31 | ) {
|
| 32 | poseStack.pushPose();
|
| 33 | poseStack.rotateDegrees(Axis.YP, state.yRot - 90.0F);
|
| 34 | poseStack.rotateDegrees(Axis.ZP, state.xRot + 90.0F);
|
| 35 | if (state.isFoil) {
|
| 36 | submitNodeCollector.submitModel(
|
| 37 | this.model, Unit.INSTANCE, poseStack, RenderTypes.entitySolidGlint(TRIDENT_LOCATION), state.lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor
|
| 38 | );
|
| 39 | } else {
|
| 40 | submitNodeCollector.submitModel(this.model, Unit.INSTANCE, poseStack, TRIDENT_LOCATION, state.lightCoords, OverlayTexture.NO_OVERLAY, state.outlineColor);
|
| 41 | }
|
| 42 |
|
| 43 | poseStack.popPose();
|
| 44 | super.submit(state, poseStack, submitNodeCollector, camera);
|
| 45 | }
|
| 46 |
|
| 47 | protected AABB getBoundingBoxForCulling(final ThrownTrident entity, final float partialTicks) {
|
| 48 | return super.getBoundingBoxForCulling(entity, partialTicks).inflate(1.5);
|
| 49 | }
|
| 50 |
|
| 51 | public ThrownTridentRenderState createRenderState() {
|
| 52 | return new ThrownTridentRenderState();
|
| 53 | }
|
| 54 |
|
| 55 | public void extractRenderState(final ThrownTrident entity, final ThrownTridentRenderState state, final float partialTicks) {
|
| 56 | super.extractRenderState(entity, state, partialTicks);
|
| 57 | state.yRot = entity.getYRot(partialTicks);
|
| 58 | state.xRot = entity.getXRot(partialTicks);
|
| 59 | state.isFoil = entity.isFoil();
|
| 60 | }
|
| 61 | }
|
| 62 |
|