Class BaseEntity

java.lang.Object
com.sk89q.worldedit.entity.BaseEntity
All Implemented Interfaces:
NbtValued

public class BaseEntity extends Object implements NbtValued
Represents a mutable "snapshot" of an entity.

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 Details

    • BaseEntity

      public BaseEntity(EntityType type, CompoundTag nbtData)
      Create a new base entity.
      Parameters:
      type - the entity type
      nbtData - NBT data
    • BaseEntity

      public BaseEntity(EntityType type)
      Create a new base entity with no NBT data.
      Parameters:
      type - the entity type
    • BaseEntity

      public BaseEntity(BaseEntity other)
      Make a clone of a BaseEntity.
      Parameters:
      other - the object to clone
  • Method Details

    • hasNbtData

      public boolean hasNbtData()
      Description copied from interface: NbtValued
      Returns whether the block contains NBT data. NbtValued.getNbtData() must not return null if this method returns true.
      Specified by:
      hasNbtData in interface NbtValued
      Returns:
      true if there is NBT data
    • getNbtData

      @Nullable public CompoundTag getNbtData()
      Description copied from interface: NbtValued
      Get the object's NBT data (tile entity data). The returned tag, if modified in any way, should be sent to 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.

      Specified by:
      getNbtData in interface NbtValued
      Returns:
      compound tag, or null
    • setNbtData

      public void setNbtData(@Nullable CompoundTag nbtData)
      Description copied from interface: NbtValued
      Set the object's NBT data (tile entity data).
      Specified by:
      setNbtData in interface NbtValued
      Parameters:
      nbtData - NBT data, or null if no data
    • getType

      public EntityType getType()
      Get the type of entity.
      Returns:
      the entity type