Class BlockEntity

java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
All Implemented Interfaces:
IAttachmentHolder, IBlockEntityExtension, INBTSerializable<CompoundTag>
Direct Known Subclasses:
BannerBlockEntity, BaseContainerBlockEntity, BeaconBlockEntity, BedBlockEntity, BeehiveBlockEntity, BellBlockEntity, BlockPropertyTests.LightBlockEntity, BrushableBlockEntity, CampfireBlockEntity, ChiseledBookShelfBlockEntity, CommandBlockEntity, ComparatorBlockEntity, ConduitBlockEntity, CustomItemDisplayContextTest.ItemHangerBlockEntity, DaylightDetectorBlockEntity, DecoratedPotBlockEntity, EnchantmentTableBlockEntity, EnderChestBlockEntity, FullPotsAccessorDemo.DioriteFlowerPotBlockEntity, GameTestTest.EnergyBlockEntity, JigsawBlockEntity, JukeboxBlockEntity, LecternBlockEntity, MegaModelTest.TestBlock.Entity, PistonMovingBlockEntity, SculkCatalystBlockEntity, SculkSensorBlockEntity, SculkShriekerBlockEntity, SignBlockEntity, SkullBlockEntity, SpawnerBlockEntity, StructureBlockEntity, TheEndPortalBlockEntity, TrialSpawnerBlockEntity

public abstract class BlockEntity extends AttachmentHolder implements IBlockEntityExtension
  • 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()
    • 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: IBlockEntityExtension
      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 IBlockEntityExtension
      Returns:
      A compound tag for custom persistent data
    • setData

      @Nullable public final <T> T setData(AttachmentType<T> type, T data)
      Description copied from interface: IAttachmentHolder
      Sets the data attachment of the given type.
      Specified by:
      setData in interface IAttachmentHolder
      Overrides:
      setData in class AttachmentHolder
      Returns:
      the previous value for that attachment type, if any, or null if there was none
    • removeData

      @Nullable public final <T> T removeData(AttachmentType<T> type)
      Description copied from interface: IAttachmentHolder
      Removes the data attachment of the given type.
      Specified by:
      removeData in interface IAttachmentHolder
      Overrides:
      removeData in class AttachmentHolder
      Returns:
      the previous value for that attachment type, if any, or null if there was none
    • setBlockState

      @Deprecated public void setBlockState(BlockState p_155251_)
      Deprecated.