1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-12-14 20:20:30 +00:00

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

View File

@ -67,6 +67,12 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
@Override @Override
public void render(TurtleBlockEntity turtle, float partialTicks, PoseStack transform, MultiBufferSource buffers, int lightmapCoord, int overlayLight) { 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 // Render the label
var label = turtle.getLabel(); var label = turtle.getLabel();
var hit = renderer.cameraHitResult; var hit = renderer.cameraHitResult;
@ -88,17 +94,11 @@ public class TurtleBlockEntityRenderer implements BlockEntityRenderer<TurtleBloc
transform.popPose(); transform.popPose();
} }
transform.pushPose(); // Then apply rotation and flip if needed.
// Setup the transform.
var offset = turtle.getRenderOffset(partialTicks);
var yaw = turtle.getRenderYaw(partialTicks);
transform.translate(offset.x, offset.y, offset.z);
transform.translate(0.5f, 0.5f, 0.5f); transform.translate(0.5f, 0.5f, 0.5f);
var yaw = turtle.getRenderYaw(partialTicks);
transform.mulPose(Axis.YP.rotationDegrees(180.0f - yaw)); transform.mulPose(Axis.YP.rotationDegrees(180.0f - yaw));
if (label != null && (label.equals("Dinnerbone") || label.equals("Grumm"))) { if (label != null && (label.equals("Dinnerbone") || label.equals("Grumm"))) {
// Flip the model
transform.scale(1.0f, -1.0f, 1.0f); transform.scale(1.0f, -1.0f, 1.0f);
} }
transform.translate(-0.5f, -0.5f, -0.5f); transform.translate(-0.5f, -0.5f, -0.5f);