plane fix kinda
This commit is contained in:
@@ -6,7 +6,7 @@ minecraft_version=1.20.1
|
|||||||
yarn_mappings=1.20.1+build.10
|
yarn_mappings=1.20.1+build.10
|
||||||
loader_version=0.18.3
|
loader_version=0.18.3
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version=26.3.26
|
mod_version=26.3.27
|
||||||
maven_group=dev.tggamesyt
|
maven_group=dev.tggamesyt
|
||||||
archives_base_name=szar
|
archives_base_name=szar
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|||||||
@@ -38,31 +38,35 @@ public class PlaneEntityRenderer extends EntityRenderer<PlaneEntity> {
|
|||||||
) {
|
) {
|
||||||
matrices.push();
|
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;
|
float interpolatedPitch = entity.prevPitch + (entity.getPitch() - entity.prevPitch) * tickDelta;
|
||||||
|
|
||||||
// Scale
|
float pitchRad = (float) Math.toRadians(interpolatedPitch);
|
||||||
matrices.scale(4.0F, 4.0F, 4.0F);
|
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);
|
matrices.translate(0.0, 1.5, 0.0);
|
||||||
|
|
||||||
// Rotate to match hitbox exactly
|
|
||||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-interpolatedYaw));
|
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(-interpolatedYaw));
|
||||||
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(interpolatedPitch));
|
matrices.multiply(RotationAxis.POSITIVE_X.rotationDegrees(interpolatedPitch));
|
||||||
|
|
||||||
// Rotate 180° to fix backwards-facing
|
|
||||||
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F));
|
matrices.multiply(RotationAxis.POSITIVE_Y.rotationDegrees(180.0F));
|
||||||
|
|
||||||
// Flip model upright (Minecraft model fix)
|
|
||||||
matrices.scale(-1.0F, -1.0F, 1.0F);
|
matrices.scale(-1.0F, -1.0F, 1.0F);
|
||||||
|
|
||||||
// Set model angles
|
|
||||||
model.setAngles(
|
model.setAngles(
|
||||||
entity,
|
entity, 0, 0,
|
||||||
0,
|
|
||||||
0,
|
|
||||||
entity.age + tickDelta,
|
entity.age + tickDelta,
|
||||||
interpolatedYaw,
|
interpolatedYaw,
|
||||||
interpolatedPitch
|
interpolatedPitch
|
||||||
@@ -72,10 +76,8 @@ public class PlaneEntityRenderer extends EntityRenderer<PlaneEntity> {
|
|||||||
vertices.getBuffer(RenderLayer.getEntityCutout(getTexture(entity)));
|
vertices.getBuffer(RenderLayer.getEntityCutout(getTexture(entity)));
|
||||||
|
|
||||||
model.render(
|
model.render(
|
||||||
matrices,
|
matrices, consumer,
|
||||||
consumer,
|
light, OverlayTexture.DEFAULT_UV,
|
||||||
light,
|
|
||||||
OverlayTexture.DEFAULT_UV,
|
|
||||||
1.0F, 1.0F, 1.0F, 1.0F
|
1.0F, 1.0F, 1.0F, 1.0F
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user