Skip to content

Commit

Permalink
update camera rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
acikek committed May 6, 2024
1 parent ad0df9d commit 353a8fe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public record ItemDisplayBlockEntityRenderer(BlockEntityRendererFactory.Context

@Override
public void render(ItemDisplayBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
PlayerEntity player = mc.player;
Entity camera = mc.getCameraEntity();

if (player == null) return;
if (camera == null) return;

matrices.push();
matrices.translate(0.5D, 0D, 0.5D);
Expand All @@ -41,7 +41,7 @@ public void render(ItemDisplayBlockEntity entity, float tickDelta, MatrixStack m

switch (entity.rotationType) {
case TRACKING -> {
Vec2f pitchAndYaw = ItemDisplayBlockEntity.getPitchAndYaw(mc.cameraEntity, entity.getPos());
Vec2f pitchAndYaw = ItemDisplayBlockEntity.getPitchAndYaw(camera, entity.getPos());
pitch = pitchAndYaw.x;
yaw = pitchAndYaw.y;
matrices.multiply(RotationAxis.POSITIVE_Y.rotation(yaw));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public static void editHyperlinkBlock(BlockPos pos, String url) {

//TODO: Pretty spicy, copied from the old code. Should maybe break this into more packets, or dispatch off the type of property I'm setting.
public static void editItemDisplayBlock(ItemDisplayBlockEntity be, boolean updatePitchAndYaw) {
if (updatePitchAndYaw && MinecraftClient.getInstance().player != null) {
Vec2f pitchAndYaw = ItemDisplayBlockEntity.getPitchAndYaw(MinecraftClient.getInstance().cameraEntity, be.getPos());
if (updatePitchAndYaw && MinecraftClient.getInstance().getCameraEntity() != null) {
Vec2f pitchAndYaw = ItemDisplayBlockEntity.getPitchAndYaw(MinecraftClient.getInstance().getCameraEntity(), be.getPos());
be.pitch = pitchAndYaw.x;
be.yaw = pitchAndYaw.y;
}
Expand Down

0 comments on commit 353a8fe

Please sign in to comment.