From 7c779124dc05ecac0207c0f427e631a49546d789 Mon Sep 17 00:00:00 2001 From: TGdoesCode Date: Fri, 27 Mar 2026 13:34:11 +0100 Subject: [PATCH] plane fix kinda --- gradle.properties | 2 +- .../szar/client/PlaneEntityRenderer.java | 38 ++++++++++--------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4abad65..f91597c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.20.1 yarn_mappings=1.20.1+build.10 loader_version=0.18.3 # Mod Properties -mod_version=26.3.26 +mod_version=26.3.27 maven_group=dev.tggamesyt archives_base_name=szar # Dependencies diff --git a/src/client/java/dev/tggamesyt/szar/client/PlaneEntityRenderer.java b/src/client/java/dev/tggamesyt/szar/client/PlaneEntityRenderer.java index 71a2391..367334b 100644 --- a/src/client/java/dev/tggamesyt/szar/client/PlaneEntityRenderer.java +++ b/src/client/java/dev/tggamesyt/szar/client/PlaneEntityRenderer.java @@ -38,31 +38,35 @@ public class PlaneEntityRenderer extends EntityRenderer { ) { matrices.push(); - // Smooth interpolation of rotation - float interpolatedYaw = entity.prevYaw + (entity.getYaw() - entity.prevYaw) * tickDelta; + float interpolatedYaw = entity.prevYaw + (entity.getYaw() - entity.prevYaw) * tickDelta; float interpolatedPitch = entity.prevPitch + (entity.getPitch() - entity.prevPitch) * tickDelta; - // Scale - matrices.scale(4.0F, 4.0F, 4.0F); + float pitchRad = (float) Math.toRadians(interpolatedPitch); + float yawRad = (float) Math.toRadians(interpolatedYaw); - // Move model to correct pivot point + final float PIVOT_OFFSET = 4F; + final float ARC_RADIUS = 8F; + + float dy = PIVOT_OFFSET * (1.0F - (float) Math.cos(pitchRad)) + - (ARC_RADIUS * (1.0F - (float) Math.cos(pitchRad)) - ARC_RADIUS * (1.0F - (float) Math.cos(pitchRad))); + float dz = ARC_RADIUS * (float) Math.sin(pitchRad); + + float worldX = -dz * (float) Math.sin(yawRad); + float worldZ = dz * (float) Math.cos(yawRad); + float worldY = PIVOT_OFFSET * (1.0F - (float) Math.cos(pitchRad)); + + matrices.translate(worldX, worldY, worldZ); + + matrices.scale(4.0F, 4.0F, 4.0F); matrices.translate(0.0, 1.5, 0.0); - // Rotate to match hitbox exactly matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-interpolatedYaw)); matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(interpolatedPitch)); - - // Rotate 180° to fix backwards-facing matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F)); - - // Flip model upright (Minecraft model fix) matrices.scale(-1.0F, -1.0F, 1.0F); - // Set model angles model.setAngles( - entity, - 0, - 0, + entity, 0, 0, entity.age + tickDelta, interpolatedYaw, interpolatedPitch @@ -72,10 +76,8 @@ public class PlaneEntityRenderer extends EntityRenderer { vertices.getBuffer(RenderLayer.getEntityCutout(getTexture(entity))); model.render( - matrices, - consumer, - light, - OverlayTexture.DEFAULT_UV, + matrices, consumer, + light, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F );