Commit 21fb4bbe by Jonathan Thomas

Fixing SHIFT sneak issue that lowers the chat bubble and causes extreme tilt…

Fixing SHIFT sneak issue that lowers the chat bubble and causes extreme tilt issues when close to an entity.
parent 7a3463f5
Pipeline #11651 passed with stage
in 20 seconds
......@@ -148,25 +148,8 @@ public class ClientInit implements ClientModInitializer {
VertexConsumerProvider immediate = context.consumers();
// Get camera position
Vec3d interpolatedCameraPos;
double cameraHeight = 0D;
double sneakHeight = 0.3D;
if (MinecraftClient.getInstance().options.getPerspective().isFirstPerson()) {
// 1st person, Use the cameraEntity (interpolate for smooth motion)
if (cameraEntity.isSneaking()) {
cameraHeight = cameraEntity.getHeight() + sneakHeight;
} else {
cameraHeight = cameraEntity.getHeight();
}
interpolatedCameraPos = new Vec3d(
MathHelper.lerp(partialTicks, cameraEntity.prevX, cameraEntity.getPos().x),
MathHelper.lerp(partialTicks, cameraEntity.prevY, cameraEntity.getPos().y),
MathHelper.lerp(partialTicks, cameraEntity.prevZ, cameraEntity.getPos().z)
);
} else {
// Use the camera (3rd person)
interpolatedCameraPos = new Vec3d(camera.getPos().x, camera.getPos().y, camera.getPos().z);
}
double cameraHeight = cameraEntity.getHeight();
Vec3d interpolatedCameraPos = new Vec3d(camera.getPos().x, camera.getPos().y, camera.getPos().z);
// Get all entities
List<Entity> nearbyEntities = world.getOtherEntities(null, area);
......@@ -204,11 +187,11 @@ public class ClientInit implements ClientModInitializer {
// Translate to the entity's position
matrices.translate(interpolatedEntityPos.x - interpolatedCameraPos.x,
(interpolatedEntityPos.y + entity.getHeight()) - (interpolatedCameraPos.y + cameraHeight) + paddingAboveEntity,
(interpolatedEntityPos.y + entity.getHeight()) - interpolatedCameraPos.y + paddingAboveEntity,
interpolatedEntityPos.z - interpolatedCameraPos.z);
// Calculate the difference vector (from entity to camera)
Vec3d difference = interpolatedCameraPos.subtract(interpolatedEntityPos);
Vec3d difference = interpolatedCameraPos.subtract(interpolatedEntityPos).subtract(0, cameraHeight, 0);
// Calculate the yaw angle
double yaw = -(Math.atan2(difference.z, difference.x) + Math.PI / 2D);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment