Started by
Doo89
on
Topic category: User side tutorials
1 - Completely realize your GUI
2 - Edit your GUI code, the one that ends up: Screen.java
3 - At the end of the imports, add:
import com.mojang.blaze3d.platform.Lighting;
import com.mojang.math.Quaternion;
import com.mojang.math.Vector3f;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.entity.EntityRenderDispatcher;
import net.minecraft.world.entity.LivingEntity;
4 - Add attributes:
private float xMouse;
private float yMouse;
(After:)
private final Player entity;
5 - At the end of class 'render':
this.xMouse = mouseX;
this.yMouse = mouseY;
6 - At the end of class 'renderBg':
renderEntityInInventory(this.leftPos + 30, this.topPos + 70, 30, this.leftPos + 30 - this.xMouse, (float)(this.topPos + 70 - 50) - this.yMouse, this.minecraft.player);
7 - Before the last }, paste this method:
public static void renderEntityInInventory(int leftPos, int topPos, int height, float LookH, float LookV, LivingEntity player) {
float f = (float)Math.atan((double)(LookH / 40.0F));
float f1 = (float)Math.atan((double)(LookV / 40.0F));
PoseStack posestack = RenderSystem.getModelViewStack();
posestack.pushPose();
posestack.translate((double)leftPos, (double)topPos, 1050.0D);
posestack.scale(1.0F, 1.0F, -1.0F);
RenderSystem.applyModelViewMatrix();
PoseStack posestack1 = new PoseStack();
posestack1.translate(0.0D, 0.0D, 1000.0D);
posestack1.scale((float)height, (float)height, (float)height);
Quaternion quaternion = Vector3f.ZP.rotationDegrees(180.0F);
Quaternion quaternion1 = Vector3f.XP.rotationDegrees(f1 * 20.0F);
quaternion.mul(quaternion1);
posestack1.mulPose(quaternion);
float f2 = player.yBodyRot;
float f3 = player.getYRot();
float f4 = player.getXRot();
float f5 = player.yHeadRotO;
float f6 = player.yHeadRot;
player.yBodyRot = 180.0F + f * 20.0F;
player.setYRot(180.0F + f * 40.0F);
player.setXRot(-f1 * 20.0F);
player.yHeadRot = player.getYRot();
player.yHeadRotO = player.getYRot();
Lighting.setupForEntityInInventory();
EntityRenderDispatcher entityrenderdispatcher = Minecraft.getInstance().getEntityRenderDispatcher();
quaternion1.conj();
entityrenderdispatcher.overrideCameraOrientation(quaternion1);
entityrenderdispatcher.setRenderShadow(false);
MultiBufferSource.BufferSource multibuffersource$buffersource = Minecraft.getInstance().renderBuffers().bufferSource();
RenderSystem.runAsFancy(() -> {
entityrenderdispatcher.render(player, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F, posestack1, multibuffersource$buffersource, 15728880);
});
multibuffersource$buffersource.endBatch();
entityrenderdispatcher.setRenderShadow(true);
player.yBodyRot = f2;
player.setYRot(f3);
player.setXRot(f4);
player.yHeadRotO = f5;
player.yHeadRot = f6;
posestack.popPose();
RenderSystem.applyModelViewMatrix();
Lighting.setupFor3DItems();
}
8 - Save and lock code.
9 - Test and adjust x and y position:
Inspiration from the KinderrKill Youtube channel:
https://www.youtube.com/c/KinderrKill/
Thanks KinderrKill.
Sorry for my english.
Edited by Doo89 on Fri, 02/04/2022 - 14:20
What do you mean "before the last }"? could you add a image
This kind of confuses me. Is there any way you can make a video on this? Cuz I love that you made this, but I don't understand.
whats so confusing? it all works for me 1.18.2
Oh yeah, I didn't realize this was 1.18. Is there a way to do this in 1.16.5?
Here is a 1.16.5 tutorial: https://mcreator.net/forum/91339/player-avatar-gui
Great tutorial!
Good tutorial! Can you make a tutorial on how to do the same with the mob please?
Thanks.
This will be added in the next version of MCreator : https://twitter.com/PyloDEV