Package com.sk89q.worldedit.entity
Interface Player
- All Superinterfaces:
Actor
,Entity
,Faceted
,Identifiable
,Locatable
,SessionOwner
,Subject
- All Known Implementing Classes:
AbstractPlayerActor
Represents a player.
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Go up one level to the next free space above.boolean
ascendToCeiling
(int clearance) Ascend to the ceiling above.boolean
ascendToCeiling
(int clearance, boolean alwaysGlass) Ascend to the ceiling above.boolean
ascendUpwards
(int distance) Just go up.boolean
ascendUpwards
(int distance, boolean alwaysGlass) Just go up.boolean
Go up one level to the next free space above.void
Find a position for the player to stand that is not inside a block.void
findFreePosition
(Location searchPos) Find a position for the actor to stand that is not inside a block.void
floatAt
(int x, int y, int z, boolean alwaysGlass) Make the player float in the given blocks.default Location
Deprecated.Use Locatable#getBlockLocationgetBlockInHand
(HandSide handSide) Get the Block that the player is holding.Get the point of the block that is being stood upon.getBlockTrace
(int range) Get the point of the block being looked at.getBlockTrace
(int range, boolean useLastBlock) Get the point of the block being looked at.getBlockTrace
(int range, boolean useLastBlock, Mask stopMask) Get the point of the block being looked at.getBlockTraceFace
(int range, boolean useLastBlock) Get the face that the player is looking at.getBlockTraceFace
(int range, boolean useLastBlock, Mask stopMask) Get the face that the player is looking at.Get the player's cardinal direction (N, W, NW, etc.).getCardinalDirection
(int yawOffset) Get the player's cardinal direction (N, W, NW, etc.) with an offset.Return this actor's game mode.Get this actor's block bag.getItemInHand
(HandSide handSide) Get the item that the player is holding.getSolidBlockTrace
(int range) Get the point of the block being looked at.getWorld()
Return the world that the player is on.void
giveItem
(BaseItemStack itemStack) Gives the player an item.boolean
Returns true if the entity is holding a pick axe.boolean
passThroughForwardWall
(int range) Pass through the wall that you are looking at.<B extends BlockStateHolder<B>>
voidsendFakeBlock
(BlockVector3 pos, B block) Sends a fake block to the client.void
setGameMode
(GameMode gameMode) Sets the player to the given game mode.void
setOnGround
(Location searchPos) Set the actor on the ground.default void
setPosition
(Vector3 pos, float pitch, float yaw) Deprecated.This method may fail without indication.default boolean
trySetPosition
(Vector3 pos, float pitch, float yaw) Attempt to move the player.Methods inherited from interface com.sk89q.worldedit.extension.platform.Actor
canDestroyBedrock, dispatchCUIEvent, getDisplayName, getLocale, getName, isPlayer, openFileOpenDialog, openFileSaveDialog, print, print, printDebug, printDebug, printError, printError, printInfo, printRaw, sendAnnouncements
Methods inherited from interface com.sk89q.worldedit.util.Identifiable
getUniqueId
Methods inherited from interface com.sk89q.worldedit.extension.platform.Locatable
getBlockLocation, getExtent, getLocation, setLocation, setPosition, trySetPosition
Methods inherited from interface com.sk89q.worldedit.session.SessionOwner
getSessionKey
Methods inherited from interface com.sk89q.worldedit.util.auth.Subject
checkPermission, getGroups, hasPermission
-
Method Details
-
getWorld
World getWorld()Return the world that the player is on.- Returns:
- the world
-
isHoldingPickAxe
boolean isHoldingPickAxe()Returns true if the entity is holding a pick axe.- Returns:
- whether a pick axe is held
-
getCardinalDirection
Get the player's cardinal direction (N, W, NW, etc.) with an offset. May return null.- Parameters:
yawOffset
- offset that is added to the player's yaw before determining the cardinal direction- Returns:
- the direction
-
getItemInHand
Get the item that the player is holding.- Returns:
- the item the player is holding
-
getBlockInHand
Get the Block that the player is holding.- Returns:
- the item id of the item the player is holding
- Throws:
WorldEditException
-
giveItem
Gives the player an item.- Parameters:
itemStack
- The item to give
-
getInventoryBlockBag
BlockBag getInventoryBlockBag()Get this actor's block bag.- Returns:
- the actor's block bag
-
getGameMode
GameMode getGameMode()Return this actor's game mode.- Returns:
- the game mode
-
setGameMode
Sets the player to the given game mode.- Parameters:
gameMode
- The game mode
-
findFreePosition
Find a position for the actor to stand that is not inside a block. Blocks above the player will be iteratively tested until there is a series of two free blocks. The actor will be teleported to that free position.- Parameters:
searchPos
- search position
-
setOnGround
Set the actor on the ground.- Parameters:
searchPos
- The location to start searching from
-
findFreePosition
void findFreePosition()Find a position for the player to stand that is not inside a block. Blocks above the player will be iteratively tested until there is a series of two free blocks. The player will be teleported to that free position. -
ascendLevel
boolean ascendLevel()Go up one level to the next free space above.- Returns:
- true if a spot was found
-
descendLevel
boolean descendLevel()Go up one level to the next free space above.- Returns:
- true if a spot was found
-
ascendToCeiling
boolean ascendToCeiling(int clearance) Ascend to the ceiling above.- Parameters:
clearance
- How many blocks to leave above the player's head- Returns:
- whether the player was moved
-
ascendToCeiling
boolean ascendToCeiling(int clearance, boolean alwaysGlass) Ascend to the ceiling above.- Parameters:
clearance
- How many blocks to leave above the player's headalwaysGlass
- Always put glass under the player- Returns:
- whether the player was moved
-
ascendUpwards
boolean ascendUpwards(int distance) Just go up.- Parameters:
distance
- How far up to teleport- Returns:
- whether the player was moved
-
ascendUpwards
boolean ascendUpwards(int distance, boolean alwaysGlass) Just go up.- Parameters:
distance
- How far up to teleportalwaysGlass
- Always put glass under the player- Returns:
- whether the player was moved
-
floatAt
void floatAt(int x, int y, int z, boolean alwaysGlass) Make the player float in the given blocks.- Parameters:
x
- The X coordinate of the block to float iny
- The Y coordinate of the block to float inz
- The Z coordinate of the block to float in
-
getBlockIn
Deprecated.Use Locatable#getBlockLocationGet the point of the block that is being stood in.- Returns:
- point
-
getBlockOn
Location getBlockOn()Get the point of the block that is being stood upon.- Returns:
- point
-
getBlockTrace
Get the point of the block being looked at. May return null. Will return the farthest away air block if useLastBlock is true and no other block is found.- Parameters:
range
- how far to checks for blocksuseLastBlock
- try to return the last valid air block found- Returns:
- point
-
getBlockTrace
Get the point of the block being looked at. May return null. Will return the farthest away block before matching the stop mask if useLastBlock is true and no other block is found.- Parameters:
range
- how far to checks for blocksuseLastBlock
- try to return the last valid block not matching the stop mask foundstopMask
- the mask used to determine when to stop tracing- Returns:
- point
-
getBlockTraceFace
Get the face that the player is looking at.- Parameters:
range
- the rangeuseLastBlock
- try to return the last valid air block found- Returns:
- a face
-
getBlockTraceFace
Get the face that the player is looking at.- Parameters:
range
- the rangeuseLastBlock
- try to return the last valid block not matching the stop mask foundstopMask
- the mask used to determine when to stop tracing- Returns:
- a face
-
getBlockTrace
Get the point of the block being looked at. May return null.- Parameters:
range
- How far to checks for blocks- Returns:
- point
-
getSolidBlockTrace
Get the point of the block being looked at. May return null.- Parameters:
range
- How far to checks for blocks- Returns:
- point
-
getCardinalDirection
Direction getCardinalDirection()Get the player's cardinal direction (N, W, NW, etc.). May return null.- Returns:
- the direction
-
passThroughForwardWall
boolean passThroughForwardWall(int range) Pass through the wall that you are looking at.- Parameters:
range
- How far to checks for blocks- Returns:
- whether the player was pass through
-
setPosition
Deprecated.This method may fail without indication. UsetrySetPosition(Vector3, float, float)
insteadMove the player.- Parameters:
pos
- where to move thempitch
- the pitch (up/down) of the player's view in degreesyaw
- the yaw (left/right) of the player's view in degrees
-
trySetPosition
@NonAbstractForCompatibility(delegateName="setPosition", delegateParams={Vector3.class,float.class,float.class}) default boolean trySetPosition(Vector3 pos, float pitch, float yaw) Attempt to move the player.This action may fail, due to other mods cancelling the move. If so, this method will return
false
.- Parameters:
pos
- where to move thempitch
- the pitch (up/down) of the player's view in degreesyaw
- the yaw (left/right) of the player's view in degrees- Returns:
- if the move was able to occur
- API Note:
- This must be overridden by new subclasses. See
NonAbstractForCompatibility
for details
-
sendFakeBlock
Sends a fake block to the client.This block isn't real.
- Parameters:
pos
- The position of the blockblock
- The block to send, null to reset
-