Class BlockEntity

All Implemented Interfaces:
ICapabilityProvider, ICapabilityProviderImpl<BlockEntity>, ICapabilitySerializable<CompoundTag>, IForgeBlockEntity, INBTSerializable<CompoundTag>
Direct Known Subclasses:
BannerBlockEntity, BaseContainerBlockEntity, BeaconBlockEntity, BedBlockEntity, BeehiveBlockEntity, BellBlockEntity, BrushableBlockEntity, CampfireBlockEntity, ChiseledBookShelfBlockEntity, CommandBlockEntity, ComparatorBlockEntity, ConduitBlockEntity, DaylightDetectorBlockEntity, DecoratedPotBlockEntity, EnchantmentTableBlockEntity, EnderChestBlockEntity, FluidHandlerBlockEntity, JigsawBlockEntity, JukeboxBlockEntity, LecternBlockEntity, PistonMovingBlockEntity, SculkCatalystBlockEntity, SculkSensorBlockEntity, SculkShriekerBlockEntity, SignBlockEntity, SkullBlockEntity, SpawnerBlockEntity, StructureBlockEntity, TheEndPortalBlockEntity

public abstract class BlockEntity extends CapabilityProvider<BlockEntity> implements IForgeBlockEntity
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • type

      private final BlockEntityType<?> type
    • level

      @Nullable protected Level level
    • worldPosition

      protected final BlockPos worldPosition
    • remove

      protected boolean remove
    • blockState

      private BlockState blockState
    • customPersistentData

      private CompoundTag customPersistentData
  • Constructor Details

  • Method Details

    • getPosFromTag

      public static BlockPos getPosFromTag(CompoundTag p_187473_)
    • getLevel

      @Nullable public Level getLevel()
    • setLevel

      public void setLevel(Level p_155231_)
    • hasLevel

      public boolean hasLevel()
    • load

      public void load(CompoundTag p_155245_)
    • saveAdditional

      protected void saveAdditional(CompoundTag p_187471_)
    • saveWithFullMetadata

      public final CompoundTag saveWithFullMetadata()
    • saveWithId

      public final CompoundTag saveWithId()
    • saveWithoutMetadata

      public final CompoundTag saveWithoutMetadata()
    • saveId

      private void saveId(CompoundTag p_187475_)
    • addEntityType

      public static void addEntityType(CompoundTag p_187469_, BlockEntityType<?> p_187470_)
    • saveToItem

      public void saveToItem(ItemStack p_187477_)
    • saveMetadata

      private void saveMetadata(CompoundTag p_187479_)
    • loadStatic

      @Nullable public static BlockEntity loadStatic(BlockPos p_155242_, BlockState p_155243_, CompoundTag p_155244_)
    • setChanged

      public void setChanged()
    • setChanged

      protected static void setChanged(Level p_155233_, BlockPos p_155234_, BlockState p_155235_)
    • getBlockPos

      public BlockPos getBlockPos()
    • getBlockState

      public BlockState getBlockState()
    • getUpdatePacket

      @Nullable public Packet<ClientGamePacketListener> getUpdatePacket()
    • getUpdateTag

      public CompoundTag getUpdateTag()
    • isRemoved

      public boolean isRemoved()
    • setRemoved

      public void setRemoved()
    • onChunkUnloaded

      public void onChunkUnloaded()
      Specified by:
      onChunkUnloaded in interface IForgeBlockEntity
    • clearRemoved

      public void clearRemoved()
    • triggerEvent

      public boolean triggerEvent(int p_58889_, int p_58890_)
    • fillCrashReportCategory

      public void fillCrashReportCategory(CrashReportCategory p_58887_)
    • onlyOpCanSetNbt

      public boolean onlyOpCanSetNbt()
    • getType

      public BlockEntityType<?> getType()
    • getPersistentData

      public CompoundTag getPersistentData()
      Description copied from interface: IForgeBlockEntity
      Gets a CompoundTag that can be used to store custom data for this block entity. It will be written, and read from disc, so it persists over world saves.
      Specified by:
      getPersistentData in interface IForgeBlockEntity
      Returns:
      A compound tag for custom persistent data
    • setBlockState

      @Deprecated public void setBlockState(BlockState p_155251_)
      Deprecated.