Make the turtle label move with the turtle

We now perform movement translations before rendering the label, rather
than afterwards. This means the label moves smoothly(ish), rather than
jumping from block to block.
This commit is contained in:
Jonathan Coates 2022-12-15 22:25:14 +00:00
parent 4fa7f50534
commit 27b732f835
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06
1 changed files with 8 additions and 8 deletions

View File

@ -67,6 +67,12 @@ public static ResourceLocation getTurtleModel(ComputerFamily family, boolean col
@Override
public void render(TurtleBlockEntity turtle, float partialTicks, PoseStack transform, MultiBufferSource buffers, int lightmapCoord, int overlayLight) {
transform.pushPose();
// Translate the turtle first, so the label moves with it.
var offset = turtle.getRenderOffset(partialTicks);
transform.translate(offset.x, offset.y, offset.z);
// Render the label
var label = turtle.getLabel();
var hit = renderer.cameraHitResult;
@ -88,17 +94,11 @@ public void render(TurtleBlockEntity turtle, float partialTicks, PoseStack trans
transform.popPose();
}
transform.pushPose();
// Setup the transform.
var offset = turtle.getRenderOffset(partialTicks);
var yaw = turtle.getRenderYaw(partialTicks);
transform.translate(offset.x, offset.y, offset.z);
// Then apply rotation and flip if needed.
transform.translate(0.5f, 0.5f, 0.5f);
var yaw = turtle.getRenderYaw(partialTicks);
transform.mulPose(Axis.YP.rotationDegrees(180.0f - yaw));
if (label != null && (label.equals("Dinnerbone") || label.equals("Grumm"))) {
// Flip the model
transform.scale(1.0f, -1.0f, 1.0f);
}
transform.translate(-0.5f, -0.5f, -0.5f);