Interface IPlayerExtension
- All Known Implementing Classes:
AbstractClientPlayer,FakePlayer,LocalPlayer,Player,RemotePlayer,ServerPlayer
public interface IPlayerExtension
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanChecks if the player can reach a block.
On the server, additional padding is added to account for movement/lag.default booleanChecks if the player can reach an entity.
On the server, additional padding is added to account for movement/lag.default booleanChecks if the player can reach an entity by targeting the passed vector.
On the server, additional padding is added to account for movement/lag.default doubleThe reach distance is increased by 0.5 for creative players, unless it is currently zero, which disables interactions.default doubleThe entity reach is increased by 2 for creative players, unless it is currently zero, which disables attacks and entity interactions.default booleanisCloseEnough(Entity entity, double dist) Utility check to see if the player is close enough to a target entity.default OptionalIntopenMenu(MenuProvider menuProvider, Consumer<FriendlyByteBuf> extraDataWriter) Request to open a GUI on the client, from the serverdefault OptionalIntopenMenu(MenuProvider menuProvider, BlockPos pos) Request to open a GUI on the client, from the serverprivate Playerself()
-
Method Details
-
self
-
getEntityReach
default double getEntityReach()The entity reach is increased by 2 for creative players, unless it is currently zero, which disables attacks and entity interactions.- Returns:
- The entity reach of this player.
-
getBlockReach
default double getBlockReach()The reach distance is increased by 0.5 for creative players, unless it is currently zero, which disables interactions.- Returns:
- The reach distance of this player.
-
canReach
Checks if the player can reach an entity by targeting the passed vector.
On the server, additional padding is added to account for movement/lag.- Parameters:
entityHitVec- The vector being range-checked.padding- Extra validation distance.- Returns:
- If the player can attack the entity.
- API Note:
- Do not use for block checks, as this method uses
getEntityReach()
-
canReach
Checks if the player can reach an entity.
On the server, additional padding is added to account for movement/lag.- Parameters:
entity- The entity being range-checked.padding- Extra validation distance.- Returns:
- If the player can attack the passed entity.
- API Note:
- Prefer using
canReach(Vec3, double)if you have aHitResultavailable.
-
canReach
Checks if the player can reach a block.
On the server, additional padding is added to account for movement/lag.- Parameters:
pos- The position being range-checked.padding- Extra validation distance.- Returns:
- If the player can interact with this location.
-
isCloseEnough
Utility check to see if the player is close enough to a target entity. Uses "eye-to-closest-corner" checks.- Parameters:
entity- The entity being checked againstdist- The max distance allowed- Returns:
- If the eye-to-center distance between this player and the passed entity is less than dist.
- Implementation Note:
- This method inflates the bounding box by the pick radius, which differs from vanilla. But vanilla doesn't use the pick radius, the only entity with > 0 is AbstractHurtingProjectile.
-
openMenu
Request to open a GUI on the client, from the serverRefer to
IMenuTypeExtension.create(IContainerFactory)for how to provide a function to consume these GUI requests on the client.- Parameters:
menuProvider- A supplier of container properties including the registry name of the containerpos- A block pos, which will be encoded into the additional data for this request
-
openMenu
Request to open a GUI on the client, from the serverRefer to
IMenuTypeExtension.create(IContainerFactory)for how to provide a function to consume these GUI requests on the client.The maximum size for #extraDataWriter is 32600 bytes.
- Parameters:
menuProvider- A supplier of container properties including the registry name of the containerextraDataWriter- Consumer to write any additional data the GUI needs- Returns:
- The window ID of the opened GUI, or empty if the GUI could not be opened
-