2014-04-05 00:54:14 +00:00
|
|
|
/*
|
|
|
|
* WorldEdit, a Minecraft world manipulation toolkit
|
|
|
|
* Copyright (C) sk89q <http://www.sk89q.com>
|
|
|
|
* Copyright (C) WorldEdit team and contributors
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package com.sk89q.worldedit.entity;
|
|
|
|
|
2014-06-29 22:36:41 +00:00
|
|
|
import com.sk89q.worldedit.WorldEditException;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
2014-06-27 03:07:04 +00:00
|
|
|
import com.sk89q.worldedit.extension.platform.Actor;
|
2014-04-05 00:54:14 +00:00
|
|
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
2018-10-14 10:40:53 +00:00
|
|
|
import com.sk89q.worldedit.math.BlockVector3;
|
|
|
|
import com.sk89q.worldedit.math.Vector3;
|
2018-11-12 02:38:13 +00:00
|
|
|
import com.sk89q.worldedit.util.Direction;
|
2018-06-17 07:50:04 +00:00
|
|
|
import com.sk89q.worldedit.util.HandSide;
|
2018-06-16 05:29:48 +00:00
|
|
|
import com.sk89q.worldedit.util.Location;
|
2014-06-29 22:36:41 +00:00
|
|
|
import com.sk89q.worldedit.world.World;
|
2018-10-14 10:40:53 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
2018-08-18 05:22:49 +00:00
|
|
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
2018-07-19 12:41:26 +00:00
|
|
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
2014-04-05 00:54:14 +00:00
|
|
|
|
2018-08-18 05:22:49 +00:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2014-04-05 00:54:14 +00:00
|
|
|
/**
|
2014-07-26 07:29:12 +00:00
|
|
|
* Represents a player
|
2014-04-05 00:54:14 +00:00
|
|
|
*/
|
2014-06-27 03:07:04 +00:00
|
|
|
public interface Player extends Entity, Actor {
|
2014-04-05 00:54:14 +00:00
|
|
|
|
2014-06-29 22:36:41 +00:00
|
|
|
/**
|
|
|
|
* Return the world that the player is on.
|
|
|
|
*
|
|
|
|
* @return the world
|
|
|
|
*/
|
|
|
|
World getWorld();
|
|
|
|
|
2014-04-05 00:54:14 +00:00
|
|
|
/**
|
|
|
|
* Returns true if the entity is holding a pick axe.
|
|
|
|
*
|
|
|
|
* @return whether a pick axe is held
|
|
|
|
*/
|
|
|
|
boolean isHoldingPickAxe();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the player's cardinal direction (N, W, NW, etc.) with an offset. May return null.
|
|
|
|
* @param yawOffset offset that is added to the player's yaw before determining the cardinal direction
|
|
|
|
*
|
|
|
|
* @return the direction
|
|
|
|
*/
|
2018-11-12 02:38:13 +00:00
|
|
|
Direction getCardinalDirection(int yawOffset);
|
2014-04-05 00:54:14 +00:00
|
|
|
|
|
|
|
/**
|
2018-06-17 07:50:04 +00:00
|
|
|
* Get the item that the player is holding.
|
2014-04-05 00:54:14 +00:00
|
|
|
*
|
2018-06-17 07:50:04 +00:00
|
|
|
* @return the item the player is holding
|
2014-04-05 00:54:14 +00:00
|
|
|
*/
|
2018-06-17 07:50:04 +00:00
|
|
|
BaseItemStack getItemInHand(HandSide handSide);
|
2014-04-05 00:54:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Block that the player is holding.
|
|
|
|
*
|
|
|
|
* @return the item id of the item the player is holding
|
|
|
|
*/
|
2018-06-17 07:50:04 +00:00
|
|
|
BaseBlock getBlockInHand(HandSide handSide) throws WorldEditException;
|
2014-04-05 00:54:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gives the player an item.
|
|
|
|
*
|
2018-06-18 07:53:33 +00:00
|
|
|
* @param itemStack The item to give
|
2014-04-05 00:54:14 +00:00
|
|
|
*/
|
2018-06-18 07:53:33 +00:00
|
|
|
void giveItem(BaseItemStack itemStack);
|
2014-04-05 00:54:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get this actor's block bag.
|
|
|
|
*
|
|
|
|
* @return the actor's block bag
|
|
|
|
*/
|
|
|
|
BlockBag getInventoryBlockBag();
|
|
|
|
|
|
|
|
/**
|
2018-07-19 12:41:26 +00:00
|
|
|
* Return this actor's game mode.
|
2014-04-05 00:54:14 +00:00
|
|
|
*
|
2018-07-19 12:41:26 +00:00
|
|
|
* @return the game mode
|
2014-04-05 00:54:14 +00:00
|
|
|
*/
|
2018-07-19 12:41:26 +00:00
|
|
|
GameMode getGameMode();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the player to the given game mode.
|
|
|
|
*
|
|
|
|
* @param gameMode The game mode
|
|
|
|
*/
|
|
|
|
void setGameMode(GameMode gameMode);
|
2014-04-05 00:54:14 +00:00
|
|
|
|
2014-04-27 04:57:45 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param searchPos search position
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
void findFreePosition(Location searchPos);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the actor on the ground.
|
|
|
|
*
|
|
|
|
* @param searchPos The location to start searching from
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
void setOnGround(Location searchPos);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
void findFreePosition();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Go up one level to the next free space above.
|
|
|
|
*
|
|
|
|
* @return true if a spot was found
|
|
|
|
*/
|
|
|
|
boolean ascendLevel();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Go up one level to the next free space above.
|
|
|
|
*
|
|
|
|
* @return true if a spot was found
|
|
|
|
*/
|
|
|
|
boolean descendLevel();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ascend to the ceiling above.
|
|
|
|
*
|
|
|
|
* @param clearance How many blocks to leave above the player's head
|
|
|
|
* @return whether the player was moved
|
|
|
|
*/
|
|
|
|
boolean ascendToCeiling(int clearance);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ascend to the ceiling above.
|
|
|
|
*
|
|
|
|
* @param clearance How many blocks to leave above the player's head
|
|
|
|
* @param alwaysGlass Always put glass under the player
|
|
|
|
* @return whether the player was moved
|
|
|
|
*/
|
|
|
|
boolean ascendToCeiling(int clearance, boolean alwaysGlass);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Just go up.
|
|
|
|
*
|
|
|
|
* @param distance How far up to teleport
|
|
|
|
* @return whether the player was moved
|
|
|
|
*/
|
|
|
|
boolean ascendUpwards(int distance);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Just go up.
|
|
|
|
*
|
|
|
|
* @param distance How far up to teleport
|
|
|
|
* @param alwaysGlass Always put glass under the player
|
|
|
|
* @return whether the player was moved
|
|
|
|
*/
|
|
|
|
boolean ascendUpwards(int distance, boolean alwaysGlass);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Make the player float in the given blocks.
|
|
|
|
*
|
|
|
|
* @param x The X coordinate of the block to float in
|
|
|
|
* @param y The Y coordinate of the block to float in
|
|
|
|
* @param z The Z coordinate of the block to float in
|
|
|
|
*/
|
|
|
|
void floatAt(int x, int y, int z, boolean alwaysGlass);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the point of the block that is being stood in.
|
|
|
|
*
|
|
|
|
* @return point
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
Location getBlockIn();
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the point of the block that is being stood upon.
|
|
|
|
*
|
|
|
|
* @return point
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
Location getBlockOn();
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
2014-07-26 07:29:12 +00:00
|
|
|
* @param range how far to checks for blocks
|
|
|
|
* @param useLastBlock try to return the last valid air block found
|
2014-04-27 04:57:45 +00:00
|
|
|
* @return point
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
Location getBlockTrace(int range, boolean useLastBlock);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
2014-07-26 07:29:12 +00:00
|
|
|
/**
|
|
|
|
* Get the face that the player is looking at.
|
|
|
|
*
|
|
|
|
* @param range the range
|
|
|
|
* @param useLastBlock try to return the last valid air block found
|
|
|
|
* @return a face
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
Location getBlockTraceFace(int range, boolean useLastBlock);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the point of the block being looked at. May return null.
|
|
|
|
*
|
|
|
|
* @param range How far to checks for blocks
|
|
|
|
* @return point
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
Location getBlockTrace(int range);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the point of the block being looked at. May return null.
|
|
|
|
*
|
|
|
|
* @param range How far to checks for blocks
|
|
|
|
* @return point
|
|
|
|
*/
|
2018-06-16 05:29:48 +00:00
|
|
|
Location getSolidBlockTrace(int range);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the player's cardinal direction (N, W, NW, etc.). May return null.
|
|
|
|
*
|
|
|
|
* @return the direction
|
|
|
|
*/
|
2018-11-12 02:38:13 +00:00
|
|
|
Direction getCardinalDirection();
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Pass through the wall that you are looking at.
|
|
|
|
*
|
|
|
|
* @param range How far to checks for blocks
|
|
|
|
* @return whether the player was pass through
|
|
|
|
*/
|
|
|
|
boolean passThroughForwardWall(int range);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the player.
|
|
|
|
*
|
2014-07-26 07:29:12 +00:00
|
|
|
* @param pos where to move them
|
|
|
|
* @param pitch the pitch (up/down) of the player's view in degrees
|
|
|
|
* @param yaw the yaw (left/right) of the player's view in degrees
|
2014-04-27 04:57:45 +00:00
|
|
|
*/
|
2018-10-14 10:40:53 +00:00
|
|
|
void setPosition(Vector3 pos, float pitch, float yaw);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the player.
|
|
|
|
*
|
2014-07-26 07:29:12 +00:00
|
|
|
* @param pos where to move them
|
2014-04-27 04:57:45 +00:00
|
|
|
*/
|
2018-10-14 10:40:53 +00:00
|
|
|
void setPosition(Vector3 pos);
|
2014-04-27 04:57:45 +00:00
|
|
|
|
2018-08-18 05:22:49 +00:00
|
|
|
/**
|
|
|
|
* Sends a fake block to the client.
|
|
|
|
*
|
|
|
|
* <p>
|
|
|
|
* This block isn't real.
|
|
|
|
* </p>
|
|
|
|
*
|
|
|
|
* @param pos The position of the block
|
|
|
|
* @param block The block to send, null to reset
|
|
|
|
*/
|
2018-12-27 00:39:10 +00:00
|
|
|
<B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, @Nullable B block);
|
2014-04-05 00:54:14 +00:00
|
|
|
}
|