Draw the player preview at a given yaw
EntityDrawerImpl follows common's new EntityDrawer contract: it draws the player filling the preview box, turned by the yaw the cosmetics screen's drag sets, and returns false when there's no player. The angle no longer follows the cursor. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -7,7 +7,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
import org.saturnclient.ui.RenderScope;
|
||||
import org.saturnclient.ui.components.SkinPreview.EntityDrawer;
|
||||
|
||||
@@ -21,33 +20,32 @@ import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public class EntityDrawerImpl implements EntityDrawer {
|
||||
@Override
|
||||
public void render(RenderScope renderScope, boolean negativeAngle, float angle, float scale, ElementContext ctx) {
|
||||
public boolean render(RenderScope renderScope, int width, int height, float yaw) {
|
||||
LivingEntity entity = SaturnClient.client.player;
|
||||
|
||||
if (entity != null) {
|
||||
drawEntity(renderScope, 0, 0, 75, 78, 30, 0.0625F, ctx.mouseX / scale, ctx.mouseY / scale,
|
||||
SaturnClient.client.player);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The player is about 1.8 blocks tall; leave some room above and below.
|
||||
drawEntity(renderScope, 0, 0, width, height, (int) (height / 2.2F), 0.0625F, yaw, entity);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Draws the entity in the box, turned by yaw degrees (0 faces the viewer) with its head straight.
|
||||
public static void drawEntity(RenderScope renderScope, int x1, int y1, int x2, int y2, int size, float scale,
|
||||
float mouseX, float mouseY, LivingEntity entity) {
|
||||
float f = (float) (x1 + x2) / 2.0F;
|
||||
float g = (float) (y1 + y2) / 2.0F;
|
||||
float yaw, LivingEntity entity) {
|
||||
renderScope.enableScissor(x1, y1, x2, y2);
|
||||
float h = (float) Math.atan((double) ((f - mouseX) / 40.0F));
|
||||
float i = (float) Math.atan((double) ((g - mouseY) / 40.0F));
|
||||
Quaternionf quaternionf = (new Quaternionf()).rotateZ((float) Math.PI);
|
||||
Quaternionf quaternionf2 = (new Quaternionf()).rotateX(i * 20.0F * ((float) Math.PI / 180F));
|
||||
quaternionf.mul(quaternionf2);
|
||||
Quaternionf quaternionf2 = new Quaternionf();
|
||||
float j = entity.bodyYaw;
|
||||
float k = entity.getYaw();
|
||||
float l = entity.getPitch();
|
||||
float m = entity.lastHeadYaw;
|
||||
float n = entity.headYaw;
|
||||
entity.bodyYaw = 180.0F + h * 20.0F;
|
||||
entity.setYaw(180.0F + h * 40.0F);
|
||||
entity.setPitch(-i * 20.0F);
|
||||
entity.bodyYaw = 180.0F + yaw;
|
||||
entity.setYaw(180.0F + yaw);
|
||||
entity.setPitch(0.0F);
|
||||
entity.headYaw = entity.getYaw();
|
||||
entity.lastHeadYaw = entity.getYaw();
|
||||
float o = entity.getScale();
|
||||
@@ -83,7 +81,6 @@ public class EntityDrawerImpl implements EntityDrawer {
|
||||
import org.joml.Quaternionf;
|
||||
import org.joml.Vector3f;
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.ui.ElementContext;
|
||||
import org.saturnclient.ui.RenderScope;
|
||||
import org.saturnclient.ui.components.SkinPreview.EntityDrawer;
|
||||
|
||||
@@ -92,14 +89,12 @@ import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
|
||||
public class EntityDrawerImpl implements EntityDrawer {
|
||||
// Draws the entity in the box, turned by yaw degrees (0 faces the viewer) with its head straight.
|
||||
public static void drawEntity(RenderScope renderScope, int x1, int y1, int x2, int y2, int size, float f,
|
||||
float mouseX,
|
||||
float mouseY, LivingEntity entity, float angle, boolean negativeAngle) {
|
||||
float yaw, LivingEntity entity) {
|
||||
float g = (float) (x1 + x2) / 2.0F;
|
||||
float h = (float) (y1 + y2) / 2.0F;
|
||||
renderScope.enableScissor(0, 6, x2, y2);
|
||||
float i = (float) Math.atan((double) ((g - mouseX) / 40.0F));
|
||||
float j = (float) Math.atan((double) ((h - mouseY) / 40.0F));
|
||||
renderScope.enableScissor(x1, y1, x2, y2);
|
||||
Quaternionf quaternionf = (new Quaternionf()).rotateZ(3.1415927F);
|
||||
float k = entity.bodyYaw;
|
||||
float l = entity.getYaw();
|
||||
@@ -109,10 +104,10 @@ public class EntityDrawerImpl implements EntityDrawer {
|
||||
//? if <1.21.5
|
||||
//float n = entity.prevHeadYaw;
|
||||
float o = entity.headYaw;
|
||||
entity.setYaw(angle);
|
||||
entity.bodyYaw = angle;
|
||||
entity.setPitch(-(j * 20.0F));
|
||||
entity.headYaw = negativeAngle ? (i * 40.0F) + 180f : -(i * 40.0F);
|
||||
entity.setYaw(180.0F + yaw);
|
||||
entity.bodyYaw = 180.0F + yaw;
|
||||
entity.setPitch(0.0F);
|
||||
entity.headYaw = entity.getYaw();
|
||||
//? if >=1.21.5
|
||||
entity.lastHeadYaw = entity.getHeadYaw();
|
||||
//? if <1.21.5
|
||||
@@ -166,12 +161,15 @@ public class EntityDrawerImpl implements EntityDrawer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(RenderScope renderScope, boolean negativeAngle, float angle, float scale, ElementContext ctx) {
|
||||
public boolean render(RenderScope renderScope, int width, int height, float yaw) {
|
||||
LivingEntity entity = SaturnClient.client.player;
|
||||
if (entity != null) {
|
||||
drawEntity(renderScope, 0, 0, 75, 78, 30, 0.0625F, ctx.mouseX / scale, ctx.mouseY / scale, entity, angle,
|
||||
negativeAngle);
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// The player is about 1.8 blocks tall; leave some room above and below.
|
||||
drawEntity(renderScope, 0, 0, width, height, (int) (height / 2.2F), 0.0625F, yaw, entity);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*///?}
|
||||
|
||||
Reference in New Issue
Block a user