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;
|
|
|
|
|
|
|
|
import com.sk89q.worldedit.extent.Extent;
|
2014-07-16 02:47:47 +00:00
|
|
|
import com.sk89q.worldedit.util.Faceted;
|
2014-04-27 02:48:21 +00:00
|
|
|
import com.sk89q.worldedit.util.Location;
|
2019-04-13 14:00:38 +00:00
|
|
|
import com.sk89q.worldedit.world.entity.EntityType;
|
2014-04-05 00:54:14 +00:00
|
|
|
|
2014-07-14 09:15:21 +00:00
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
2014-04-05 00:54:14 +00:00
|
|
|
/**
|
|
|
|
* A reference to an instance of an entity that exists in an {@link Extent}
|
|
|
|
* and thus would have position and similar details.
|
2014-07-26 07:29:12 +00:00
|
|
|
*
|
|
|
|
* <p>This object cannot be directly cloned because it represents a particular
|
2014-04-05 00:54:14 +00:00
|
|
|
* instance of an entity, but a {@link BaseEntity} can be created from
|
2014-07-26 07:29:12 +00:00
|
|
|
* this entity by calling {@link #getState()}.</p>
|
2014-04-05 00:54:14 +00:00
|
|
|
*/
|
2014-07-16 02:47:47 +00:00
|
|
|
public interface Entity extends Faceted {
|
2014-04-05 00:54:14 +00:00
|
|
|
|
2014-04-28 06:34:39 +00:00
|
|
|
/**
|
|
|
|
* Get a copy of the entity's state.
|
|
|
|
*
|
2014-07-26 07:29:12 +00:00
|
|
|
* <p>In some cases, this method may return {@code null} if a snapshot
|
|
|
|
* of the entity can't be created. It may not be possible, for example,
|
|
|
|
* to get a snapshot of a player.</p>
|
|
|
|
*
|
|
|
|
* @return the entity's state or null if one cannot be created
|
2014-04-28 06:34:39 +00:00
|
|
|
*/
|
2014-07-14 09:15:21 +00:00
|
|
|
@Nullable
|
2014-04-28 06:34:39 +00:00
|
|
|
BaseEntity getState();
|
|
|
|
|
2014-04-27 02:48:21 +00:00
|
|
|
/**
|
|
|
|
* Get the location of this entity.
|
|
|
|
*
|
|
|
|
* @return the location of the entity
|
|
|
|
*/
|
|
|
|
Location getLocation();
|
|
|
|
|
2018-12-21 06:56:10 +00:00
|
|
|
/**
|
|
|
|
* Sets the location of this entity.
|
|
|
|
*
|
|
|
|
* @param location the new location of the entity
|
|
|
|
* @return if the teleport worked
|
|
|
|
*/
|
|
|
|
boolean setLocation(Location location);
|
|
|
|
|
2019-04-13 14:00:38 +00:00
|
|
|
default EntityType getType() {
|
|
|
|
BaseEntity state = getState();
|
|
|
|
return state != null ? state.getType() : null;
|
|
|
|
}
|
|
|
|
|
2014-04-05 05:40:29 +00:00
|
|
|
/**
|
2014-06-29 22:36:41 +00:00
|
|
|
* Get the extent that this entity is on.
|
2014-04-05 05:40:29 +00:00
|
|
|
*
|
2014-06-29 22:36:41 +00:00
|
|
|
* @return the extent
|
2014-04-05 05:40:29 +00:00
|
|
|
*/
|
2014-06-29 22:36:41 +00:00
|
|
|
Extent getExtent();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove this entity from it container.
|
|
|
|
*
|
|
|
|
* @return true if removal was successful
|
|
|
|
*/
|
|
|
|
boolean remove();
|
2014-04-05 05:40:29 +00:00
|
|
|
|
2014-04-05 00:54:14 +00:00
|
|
|
}
|