Added an entity, weathertype, and gamemode registry.

This commit is contained in:
Matthew Miller
2018-07-19 22:41:26 +10:00
parent 572bf04482
commit 663dd1f4d8
33 changed files with 747 additions and 115 deletions

View File

@ -21,6 +21,7 @@ package com.sk89q.worldedit.entity;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.world.NbtValued;
import com.sk89q.worldedit.world.entity.EntityType;
import javax.annotation.Nullable;
@ -41,27 +42,27 @@ import static com.google.common.base.Preconditions.checkNotNull;
*/
public class BaseEntity implements NbtValued {
private String id;
private EntityType type;
private CompoundTag nbtData;
/**
* Create a new base entity.
*
* @param id the entity type ID
* @param type the entity type
* @param nbtData NBT data
*/
public BaseEntity(String id, CompoundTag nbtData) {
setTypeId(id);
public BaseEntity(EntityType type, CompoundTag nbtData) {
this(type);
setNbtData(nbtData);
}
/**
* Create a new base entity with no NBT data.
*
* @param id the entity type ID
* @param type the entity type
*/
public BaseEntity(String id) {
setTypeId(id);
public BaseEntity(EntityType type) {
this.type = type;
}
/**
@ -71,7 +72,7 @@ public class BaseEntity implements NbtValued {
*/
public BaseEntity(BaseEntity other) {
checkNotNull(other);
setTypeId(other.getTypeId());
this.type = other.getType();
setNbtData(other.getNbtData());
}
@ -92,22 +93,12 @@ public class BaseEntity implements NbtValued {
}
/**
* Get the entity that determines the type of entity.
* Get the type of entity.
*
* @return the entity ID
* @return the entity type
*/
public String getTypeId() {
return id;
}
/**
* Set the entity ID that determines the type of entity.
*
* @param id the id
*/
public void setTypeId(String id) {
checkNotNull(id);
this.id = id;
public EntityType getType() {
return this.type;
}
}

View File

@ -29,6 +29,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.gamemode.GameMode;
/**
* Represents a player
@ -86,11 +87,18 @@ public interface Player extends Entity, Actor {
BlockBag getInventoryBlockBag();
/**
* Return whether this actor has creative mode.
* Return this actor's game mode.
*
* @return true if creative mode is enabled
* @return the game mode
*/
boolean hasCreativeMode();
GameMode getGameMode();
/**
* Sets the player to the given game mode.
*
* @param gameMode The game mode
*/
void setGameMode(GameMode gameMode);
/**
* Find a position for the actor to stand that is not inside a block.

View File

@ -22,7 +22,7 @@ package com.sk89q.worldedit.entity.metadata;
/**
* Describes various classes of entities.
*/
public interface EntityType {
public interface EntityProperties {
/**
* Test whether the entity is a player-derived entity.