Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt 2 (to) fix issue #50 #65

Merged
merged 7 commits into from
Aug 21, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ private static void renderSkull(Direction direction, float yaw, float animationP
SkullBlockRendererAccessor.SkullRenderMode localMode = SkullBlockRendererAccessor.getRenderMode();
SkullBlockRendererAccessor.setRenderMode(SkullBlockRendererAccessor.SkullRenderMode.OTHER);

// avatar
// avatar pointer incase avatar variable is set during render. (unlikely)
Avatar localAvatar = avatar;
avatar = null;
alekso56 marked this conversation as resolved.
Show resolved Hide resolved

if (localAvatar == null || localAvatar.permissions.get(Permissions.CUSTOM_SKULL) == 0)
return;
Expand Down Expand Up @@ -89,11 +88,25 @@ public void render(SkullBlockEntity skullBlockEntity, float f, PoseStack poseSta

@Override
public boolean shouldRenderOffScreen(SkullBlockEntity blockEntity) {
return avatar == null ? BlockEntityRenderer.super.shouldRenderOffScreen(blockEntity) : avatar.permissions.get(Permissions.OFFSCREEN_RENDERING) == 1;
// if we have an avatar, check permissions
if(avatar != null && avatar.permissions != null) {
// if we have permissions to render, then we render, else we don't render.
if(avatar.permissions.get(Permissions.OFFSCREEN_RENDERING) == 1) {
return true;
}
return false;
}
//no avatar present, default rendering used.
return BlockEntityRenderer.super.shouldRenderOffScreen(blockEntity);
alekso56 marked this conversation as resolved.
Show resolved Hide resolved
}

@Inject(at = @At("HEAD"), method = "getRenderType")
private static void getRenderType(SkullBlock.Type type, GameProfile profile, CallbackInfoReturnable<RenderType> cir) {
avatar = profile != null && profile.getId() != null ? AvatarManager.getAvatarForPlayer(profile.getId()) : null;
// reset avatar for skull
avatar = null;
alekso56 marked this conversation as resolved.
Show resolved Hide resolved
// set skull owner's avatar to be associated with this skull.
if(profile != null && profile.getId() != null) {
avatar = AvatarManager.getAvatarForPlayer(profile.getId());
}
}
}