diff --git a/src/main/java/dev/tr7zw/skinlayers/mixin/CustomHeadLayerMixin.java b/src/main/java/dev/tr7zw/skinlayers/mixin/CustomHeadLayerMixin.java index 04905c2..b23340f 100644 --- a/src/main/java/dev/tr7zw/skinlayers/mixin/CustomHeadLayerMixin.java +++ b/src/main/java/dev/tr7zw/skinlayers/mixin/CustomHeadLayerMixin.java @@ -39,7 +39,7 @@ public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int if (!SkinLayersModBase.config.enableSkulls) return; if (Minecraft.getInstance().player != null && livingEntity - .distanceToSqr(Minecraft.getInstance().player) > SkinLayersModBase.config.renderDistanceLOD + .distanceToSqr(Minecraft.getInstance().gameRenderer.getMainCamera().getPosition()) > SkinLayersModBase.config.renderDistanceLOD * SkinLayersModBase.config.renderDistanceLOD) { return; // too far away } diff --git a/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java b/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java index 017c1c9..42fd3ee 100644 --- a/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java +++ b/src/main/java/dev/tr7zw/skinlayers/mixin/PlayerRendererMixin.java @@ -66,8 +66,8 @@ public void setModelProperties(AbstractClientPlayer abstractClientPlayer, Callba this.addLayer(new CustomLayerFeatureRenderer(this)); loaded = true; } - if (Minecraft.getInstance().player == null || Minecraft.getInstance().player - .distanceToSqr(abstractClientPlayer) > SkinLayersModBase.config.renderDistanceLOD + if (Minecraft.getInstance().player == null || abstractClientPlayer + .distanceToSqr(Minecraft.getInstance().gameRenderer.getMainCamera().getPosition()) > SkinLayersModBase.config.renderDistanceLOD * SkinLayersModBase.config.renderDistanceLOD) { return; } diff --git a/src/main/java/dev/tr7zw/skinlayers/mixin/SkullBlockEntityRendererMixin.java b/src/main/java/dev/tr7zw/skinlayers/mixin/SkullBlockEntityRendererMixin.java index 869dac7..312c155 100644 --- a/src/main/java/dev/tr7zw/skinlayers/mixin/SkullBlockEntityRendererMixin.java +++ b/src/main/java/dev/tr7zw/skinlayers/mixin/SkullBlockEntityRendererMixin.java @@ -27,7 +27,9 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.entity.SkullBlockEntity; +import net.minecraft.world.phys.Vec3; // spotless:off //#if MC >= 11700 import net.minecraft.client.model.SkullModelBase; @@ -55,11 +57,11 @@ public class SkullBlockEntityRendererMixin { @Inject(method = "render", at = @At("HEAD")) public void render(SkullBlockEntity skullBlockEntity, float f, PoseStack poseStack, MultiBufferSource multiBufferSource, int i, int j, CallbackInfo info) { - LocalPlayer player = Minecraft.getInstance().player; + Vec3 camera = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); if (!SkinLayersModBase.config.enableSkulls) return; - if (internalDistToCenterSqr(skullBlockEntity.getBlockPos(), (int) player.getX(), (int) player.getY(), - (int) player.getZ()) < SkinLayersModBase.config.renderDistanceLOD + if (internalDistToCenterSqr(skullBlockEntity.getBlockPos(), (int) camera.x(), (int) camera.y(), + (int) camera.z()) < SkinLayersModBase.config.renderDistanceLOD * SkinLayersModBase.config.renderDistanceLOD) { lastSkull = (SkullSettings) skullBlockEntity; GameProfile gameProfile = null; diff --git a/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java b/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java index a230d4a..81cf111 100644 --- a/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java +++ b/src/main/java/dev/tr7zw/skinlayers/renderlayers/CustomLayerFeatureRenderer.java @@ -75,7 +75,7 @@ public void render(PoseStack poseStack, MultiBufferSource multiBufferSource, int if (mc.level == null) { return; // in a menu or something and the model gets rendered } - if (mc.player.distanceToSqr(player) > SkinLayersModBase.config.renderDistanceLOD + if (player.distanceToSqr(mc.gameRenderer.getMainCamera().getPosition()) > SkinLayersModBase.config.renderDistanceLOD * SkinLayersModBase.config.renderDistanceLOD) return;