meteor-client icon indicating copy to clipboard operation
meteor-client copied to clipboard

Individual Nametags configuration for each EntityType

Open crazycat256 opened this issue 1 year ago • 8 comments

Type of change

  • [ ] Bug fix
  • [x] New feature

Description

Changes:

  • Allows configuring nametags differently for each EntityType.
  • Adds a "trough-walls" option.

This notably allows knowing the health of nearby mobs without having the screen filled with nametags.

Checklist:

  • [x] My code follows the style guidelines of this project.
  • [x] I have added comments to my code in more complex areas.
  • [x] I have tested the code in both development and production environments.

crazycat256 avatar Jan 25 '24 15:01 crazycat256

What's the expected behavior for through-walls when it's disabled? The current approach has rather lackluster and unrefined results, and a different approach might be better.

tanchevk avatar Jan 25 '24 16:01 tanchevk

@Theboiboi8 The expected behavior when disabled is simply not to display nametags of entities that are not directly visible to the player.

What do you think could be improved?

crazycat256 avatar Jan 25 '24 16:01 crazycat256

Nametags don't render even when part of the entity is in view, so you can be looking at most of the entity and still not see any nametags. i.e. image In this example, nametags are enabled, through-walls is set to false, and I'm using a fake player (.fake-player) to have a non-moving entity. As observed, even though part (most) of the fake player is directly visible, the nametag doesn't appear. image In contrast, when the player moves ever so slightly to the right, as to view more of the fake player, the nametag appears, as observed in the above screenshot.

I feel as though this isn't the correct behavior, and I feel that when at least part of an entity is showing, nametags should, logically, appear, as otherwise issues like the one illustrated previously occur and hinder the player.

tanchevk avatar Jan 25 '24 16:01 tanchevk

This looks at the position of the player's eye. Indeed, player parts can appear without the nametag being displayed but that does not seem problematic to me. The main objective of this PR is to allow the player to know the health of the entities around him without having a lot of nametags for the mobs in the caves.

crazycat256 avatar Jan 25 '24 16:01 crazycat256

The problem, I feel, with this approach, is that given the nametag is hidden if the player doesn't see the eyes of the entity, wouldn't that present an issue with mobs that the player is fighting, but not seeing the eyes of? If, for example, the player is fighting an enderman and hiding under a 2 block tall roof, wouldn't it be better to see the health of the enderman even though the eyes aren't in direct view? As for mobs in caves, it would make little difference whether the visibility is based on whether the player sees the eyes of the entity or if the player sees part of the entity, regardless of eye visibility. On the contrary, the player may be facing a mob that is obscured partly by a block and trying to see the mob's health, but not succeeding in doing so as the mob's eyes arent in direct view.

tanchevk avatar Jan 25 '24 17:01 tanchevk

It would be quite complicated because it would mean raycasting all over the entity, which would rapidly reduce fps

crazycat256 avatar Jan 25 '24 17:01 crazycat256

replacing

((IVec3d) vec2).set(entity.getX(), entity.getY() + entity.getStandingEyeHeight(), entity.getZ());

with

((IVec3d) vec2).set(entity.getX() + entity.getWidth(), entity.getY() + entity.getStandingEyeHeight(), entity.getZ() + entity.getWidth());

in the isBehindWall(Entity entity) boolean seems to yield okay results without compromising on FPS (~5 FPS difference vs without this change, within normal FPS fluctuation range for MC on my machine). This solution isn't perfect, particularly when it comes to the Y-axis, but it does offer a simple and acceptable solution for the problem outlined in my initial comment.

tanchevk avatar Jan 25 '24 17:01 tanchevk

This modification just adds an unwanted offset to the eye position. Place your fake-player to the left of your blocks to see this

crazycat256 avatar Jan 25 '24 18:01 crazycat256