Class PlayerLookup
java.lang.Object
net.fabricmc.fabric.api.networking.v1.PlayerLookup
Helper methods to lookup players in a server.
The word "tracking" means that an entity/chunk on the server is known to a player's client (within in view distance) and the (block) entity should notify tracking clients of changes.
These methods should only be called on the server thread and only be used on logical a server.
-
Method Summary
Modifier and TypeMethodDescriptionstatic Collection
<ServerPlayerEntity> all
(MinecraftServer server) Gets all the players on the minecraft server.static Collection
<ServerPlayerEntity> around
(ServerWorld world, Vec3d pos, double radius) Gets all players around a position in a world.static Collection
<ServerPlayerEntity> around
(ServerWorld world, Vec3i pos, double radius) Gets all players around a position in a world.static Collection
<ServerPlayerEntity> tracking
(BlockEntity blockEntity) Gets all players tracking a block entity in a server world.static Collection
<ServerPlayerEntity> Gets all players tracking an entity in a server world.static Collection
<ServerPlayerEntity> tracking
(ServerWorld world, BlockPos pos) Gets all players tracking a block position in a server world.static Collection
<ServerPlayerEntity> tracking
(ServerWorld world, ChunkPos pos) Gets all players tracking a chunk in a server world.static Collection
<ServerPlayerEntity> world
(ServerWorld world) Gets all the players in a server world.
-
Method Details
-
all
Gets all the players on the minecraft server.The returned collection is immutable.
- Parameters:
server
- the server- Returns:
- all players on the server
-
world
Gets all the players in a server world.The returned collection is immutable.
- Parameters:
world
- the server world- Returns:
- the players in the server world
-
tracking
Gets all players tracking a chunk in a server world.- Parameters:
world
- the server worldpos
- the chunk in question- Returns:
- the players tracking the chunk
-
tracking
Gets all players tracking an entity in a server world.The returned collection is immutable.
Warning: If the provided entity is a player, it is not guaranteed by the contract that said player is included in the resulting stream.
- Parameters:
entity
- the entity being tracked- Returns:
- the players tracking the entity
- Throws:
IllegalArgumentException
- if the entity is not in a server world
-
tracking
Gets all players tracking a block entity in a server world.- Parameters:
blockEntity
- the block entity- Returns:
- the players tracking the block position
- Throws:
IllegalArgumentException
- if the block entity is not in a server world
-
tracking
Gets all players tracking a block position in a server world.- Parameters:
world
- the server worldpos
- the block position- Returns:
- the players tracking the block position
-
around
Gets all players around a position in a world.The distance check is done in the three-dimensional space instead of in the horizontal plane.
- Parameters:
world
- the worldpos
- the positionradius
- the maximum distance from the position in blocks- Returns:
- the players around the position
-
around
Gets all players around a position in a world.The distance check is done in the three-dimensional space instead of in the horizontal plane.
- Parameters:
world
- the worldpos
- the position (can be a block pos)radius
- the maximum distance from the position in blocks- Returns:
- the players around the position
-