2025-11-24 22:52:51 +03:00

65 lines
2.5 KiB
Java

/*
* Decompiled with CFR 0.152.
*
* Could not load the following classes:
* org.joml.Quaternionf
* org.joml.Quaternionfc
* org.joml.Vector3f
*/
package net.minecraft.client.gui.render.pip;
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.render.pip.PictureInPictureRenderer;
import net.minecraft.client.gui.render.state.pip.GuiEntityRenderState;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.client.renderer.feature.FeatureRenderDispatcher;
import net.minecraft.client.renderer.state.CameraRenderState;
import org.joml.Quaternionf;
import org.joml.Quaternionfc;
import org.joml.Vector3f;
public class GuiEntityRenderer
extends PictureInPictureRenderer<GuiEntityRenderState> {
private final EntityRenderDispatcher entityRenderDispatcher;
public GuiEntityRenderer(MultiBufferSource.BufferSource bufferSource, EntityRenderDispatcher entityRenderDispatcher) {
super(bufferSource);
this.entityRenderDispatcher = entityRenderDispatcher;
}
@Override
public Class<GuiEntityRenderState> getRenderStateClass() {
return GuiEntityRenderState.class;
}
@Override
protected void renderToTexture(GuiEntityRenderState entityState, PoseStack poseStack) {
Minecraft.getInstance().gameRenderer.getLighting().setupFor(Lighting.Entry.ENTITY_IN_UI);
Vector3f translation = entityState.translation();
poseStack.translate(translation.x, translation.y, translation.z);
poseStack.mulPose((Quaternionfc)entityState.rotation());
Quaternionf overriddenCameraAngle = entityState.overrideCameraAngle();
FeatureRenderDispatcher featureRenderDispatcher = Minecraft.getInstance().gameRenderer.getFeatureRenderDispatcher();
CameraRenderState cameraRenderState = new CameraRenderState();
if (overriddenCameraAngle != null) {
cameraRenderState.orientation = overriddenCameraAngle.conjugate(new Quaternionf()).rotateY((float)Math.PI);
}
this.entityRenderDispatcher.submit(entityState.renderState(), cameraRenderState, 0.0, 0.0, 0.0, poseStack, featureRenderDispatcher.getSubmitNodeStorage());
featureRenderDispatcher.renderAllFeatures();
}
@Override
protected float getTranslateY(int height, int guiScale) {
return (float)height / 2.0f;
}
@Override
protected String getTextureLabel() {
return "entity";
}
}