minecraft-src/net/minecraft/client/renderer/entity/ThrownTridentRenderer.java
2025-07-04 03:45:38 +03:00

47 lines
2.3 KiB
Java

package net.minecraft.client.renderer.entity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.model.TridentModel;
import net.minecraft.client.model.geom.ModelLayers;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRendererProvider.Context;
import net.minecraft.client.renderer.entity.state.ThrownTridentRenderState;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.projectile.ThrownTrident;
@Environment(EnvType.CLIENT)
public class ThrownTridentRenderer extends EntityRenderer<ThrownTrident, ThrownTridentRenderState> {
public static final ResourceLocation TRIDENT_LOCATION = ResourceLocation.withDefaultNamespace("textures/entity/trident.png");
private final TridentModel model;
public ThrownTridentRenderer(Context context) {
super(context);
this.model = new TridentModel(context.bakeLayer(ModelLayers.TRIDENT));
}
public void render(ThrownTridentRenderState thrownTridentRenderState, PoseStack poseStack, MultiBufferSource multiBufferSource, int i) {
poseStack.pushPose();
poseStack.mulPose(Axis.YP.rotationDegrees(thrownTridentRenderState.yRot - 90.0F));
poseStack.mulPose(Axis.ZP.rotationDegrees(thrownTridentRenderState.xRot + 90.0F));
VertexConsumer vertexConsumer = ItemRenderer.getFoilBuffer(multiBufferSource, this.model.renderType(TRIDENT_LOCATION), false, thrownTridentRenderState.isFoil);
this.model.renderToBuffer(poseStack, vertexConsumer, i, OverlayTexture.NO_OVERLAY);
poseStack.popPose();
super.render(thrownTridentRenderState, poseStack, multiBufferSource, i);
}
public ThrownTridentRenderState createRenderState() {
return new ThrownTridentRenderState();
}
public void extractRenderState(ThrownTrident thrownTrident, ThrownTridentRenderState thrownTridentRenderState, float f) {
super.extractRenderState(thrownTrident, thrownTridentRenderState, f);
thrownTridentRenderState.yRot = thrownTrident.getYRot(f);
thrownTridentRenderState.xRot = thrownTrident.getXRot(f);
thrownTridentRenderState.isFoil = thrownTrident.isFoil();
}
}