Class FakePlayer

All Implemented Interfaces:
Attackable, DataTracked, ScoreHolder, CommandOutput, Nameable, EntityLike

public class FakePlayer extends ServerPlayerEntity
A "fake player" is a ServerPlayerEntity that is not a human player. They are typically used to automatically perform player actions such as placing blocks.

The easiest way to obtain a fake player is with get(ServerWorld) or get(ServerWorld, GameProfile). It is also possible to create a subclass for more control over the fake player's behavior.

For good inter-mod compatibility, fake players should have the UUID of their owning (human) player. They should still have a different name to ensure the GameProfile is different. For example:


 UUID humanPlayerUuid = ...;
 String humanPlayerName = ...;
 GameProfile fakeProfile = new GameProfile(humanPlayerUuid, "[Block Breaker of " + humanPlayerName + "]");
 
If a fake player does not belong to a specific player, the default UUID should be used.

Fake players try to behave like regular ServerPlayerEntity objects to a reasonable extent. In some edge cases, or for gameplay considerations, it might be necessary to check whether a ServerPlayerEntity is a fake player. This can be done with an instanceof check: player instanceof FakePlayer.