public class BaseEntity extends java.lang.Object implements NbtValued
An instance of this class contains all the information needed to accurately reproduce the entity, provided that the instance was made correctly. In some implementations, it may not be possible to get a snapshot of entities correctly, so, for example, the NBT data for an entity may be missing.
This class identifies entities using its entity type string, although this is not very efficient as the types are currently not interned. This may be changed in the future.
Constructor and Description |
---|
BaseEntity(BaseEntity other)
Make a clone of a
BaseEntity . |
BaseEntity(java.lang.String id)
Create a new base entity with no NBT data.
|
BaseEntity(java.lang.String id,
CompoundTag nbtData)
Create a new base entity.
|
Modifier and Type | Method and Description |
---|---|
CompoundTag |
getNbtData()
Get the object's NBT data (tile entity data).
|
java.lang.String |
getTypeId()
Get the entity that determines the type of entity.
|
boolean |
hasNbtData()
Returns whether the block contains NBT data.
|
void |
setNbtData(CompoundTag nbtData)
Set the object's NBT data (tile entity data).
|
void |
setTypeId(java.lang.String id)
Set the entity ID that determines the type of entity.
|
public BaseEntity(java.lang.String id, CompoundTag nbtData)
id
- the entity type IDnbtData
- NBT datapublic BaseEntity(java.lang.String id)
id
- the entity type IDpublic BaseEntity(BaseEntity other)
BaseEntity
.other
- the object to clonepublic boolean hasNbtData()
NbtValued
NbtValued.getNbtData()
must not return null if this method returns true.hasNbtData
in interface NbtValued
@Nullable public CompoundTag getNbtData()
NbtValued
NbtValued.setNbtData(CompoundTag)
so that the instance knows of the changes. Making changes without
calling NbtValued.setNbtData(CompoundTag)
could have unintended
consequences.
NbtValued.hasNbtData()
must return true if and only if method does
not return null.
getNbtData
in interface NbtValued
public void setNbtData(@Nullable CompoundTag nbtData)
NbtValued
setNbtData
in interface NbtValued
nbtData
- NBT data, or null if no datapublic java.lang.String getTypeId()
public void setTypeId(java.lang.String id)
id
- the id