Interface IPlayerExtension
- All Known Implementing Classes:
AbstractClientPlayer
,FakePlayer
,GameTestPlayer
,LocalPlayer
,Player
,RemotePlayer
,ServerPlayer
public interface IPlayerExtension
-
Method Summary
Modifier and TypeMethodDescriptiondefault boolean
isCloseEnough
(Entity entity, double dist) Utility check to see if the player is close enough to a target entity.default boolean
Returns whether this player is a fake player, such asFakePlayer
.default boolean
mayFly()
Determine whether a player is allowed creative flight via game mode or attribute.default OptionalInt
openMenu
(MenuProvider menuProvider, Consumer<RegistryFriendlyByteBuf> extraDataWriter) Request to open a GUI on the client, from the serverdefault OptionalInt
openMenu
(MenuProvider menuProvider, BlockPos pos) Request to open a GUI on the client, from the serverprivate Player
self()
-
Method Details
-
self
-
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.
-
openMenu
Request to open a GUI on the client, from the serverRefer to
IMenuTypeExtension.create(IContainerFactory)
for creating aMenuType
that can consume the extra data sent to the client by this method.Use
FriendlyByteBuf.readBlockPos()
to read the position you pass to this method.- 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, after data written byinvalid reference
IMenuProviderExtension#writeClientSideData(AbstractContainerMenu, RegistryFriendlyByteBuf)
-
openMenu
default OptionalInt openMenu(MenuProvider menuProvider, Consumer<RegistryFriendlyByteBuf> extraDataWriter) Request to open a GUI on the client, from the serverRefer to
IMenuTypeExtension.create(IContainerFactory)
for creating aMenuType
that can consume the extra data sent to the client by this method.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. This data is written afterinvalid reference
IMenuProviderExtension#writeClientSideData(AbstractContainerMenu, RegistryFriendlyByteBuf)
- Returns:
- The window ID of the opened GUI, or empty if the GUI could not be opened
-
mayFly
default boolean mayFly()Determine whether a player is allowed creative flight via game mode or attribute.Modders are discouraged from setting
Abilities.mayfly
directly.- Returns:
- true when creative flight is available
- See Also:
-
isFakePlayer
default boolean isFakePlayer()Returns whether this player is a fake player, such asFakePlayer
.- Returns:
- whether this player is a fake player, such as
FakePlayer
-