Class BlockEntity

java.lang.Object
net.glowstone.block.entity.BlockEntity
Direct Known Subclasses:
BannerEntity, BeaconEntity, BedEntity, ContainerEntity, EnchantingTableEntity, FlowerPotEntity, JukeboxEntity, MobSpawnerEntity, SignEntity, SkullEntity

public abstract class BlockEntity extends Object
Base class for block entities (blocks with NBT data) in the world. Most access to block entities should occur through the Bukkit BlockState API.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final GlowBlock
    Get the block this BlockEntity is associated with.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new BlockEntity at the given location.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Destroy this BlockEntity.
    Get the block this BlockEntity is associated with.
    Create a new BlockState which will correspond to this block entity.
    void
    Read this BlockEntity's data from the saved tag.
    void
    Generic pulse for this block entity.
    void
    Save this BlockEntity's data to NBT.
    protected final void
    setSaveId(@NonNls String saveId)
    Set the text ID this block entity is saved to disk with.
    void
    Update this BlockEntity's visible state to the given player.
    final void
    Update this BlockEntity's visible state to all players in range.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • block

      protected final GlowBlock block
      Get the block this BlockEntity is associated with.
  • Constructor Details

    • BlockEntity

      public BlockEntity(GlowBlock block)
      Create a new BlockEntity at the given location.
      Parameters:
      block - The block the BlockEntity is attached to.
  • Method Details

    • updateInRange

      public final void updateInRange()
      Update this BlockEntity's visible state to all players in range.
    • setSaveId

      protected final void setSaveId(@NonNls @NonNls String saveId)
      Set the text ID this block entity is saved to disk with. If this is not set, then load and save of the "id" tag must be performed manually.
      Parameters:
      saveId - The ID.
    • loadNbt

      public void loadNbt(CompoundTag tag)
      Read this BlockEntity's data from the saved tag.
      Parameters:
      tag - The tag to load from.
    • saveNbt

      public void saveNbt(CompoundTag tag)
      Save this BlockEntity's data to NBT.
      Parameters:
      tag - The tag to save to.
    • getState

      public GlowBlockState getState()
      Create a new BlockState which will correspond to this block entity.
      Returns:
      A GlowBlockState, or null to use a standard BlockState.
    • destroy

      public void destroy()
      Destroy this BlockEntity.
    • update

      public void update(GlowPlayer player)
      Update this BlockEntity's visible state to the given player.
      Parameters:
      player - The player to update.
    • pulse

      public void pulse()
      Generic pulse for this block entity.
    • getBlock

      public GlowBlock getBlock()
      Get the block this BlockEntity is associated with.
      Returns:
      The entity's block.