Class BlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
- All Implemented Interfaces:
IAttachmentHolder
,IBlockEntityExtension
- Direct Known Subclasses:
BannerBlockEntity
,BaseContainerBlockEntity
,BeaconBlockEntity
,BedBlockEntity
,BeehiveBlockEntity
,BellBlockEntity
,BrushableBlockEntity
,CampfireBlockEntity
,ChiseledBookShelfBlockEntity
,CommandBlockEntity
,ComparatorBlockEntity
,ConduitBlockEntity
,DaylightDetectorBlockEntity
,DecoratedPotBlockEntity
,EnchantingTableBlockEntity
,EnderChestBlockEntity
,JigsawBlockEntity
,JukeboxBlockEntity
,LecternBlockEntity
,PistonMovingBlockEntity
,SculkCatalystBlockEntity
,SculkSensorBlockEntity
,SculkShriekerBlockEntity
,SignBlockEntity
,SkullBlockEntity
,SpawnerBlockEntity
,StructureBlockEntity
,TheEndPortalBlockEntity
,TrialSpawnerBlockEntity
,VaultBlockEntity
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
protected static interface
Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BlockState
private DataComponentMap
private CompoundTag
protected Level
private static final org.slf4j.Logger
protected boolean
private final BlockEntityType
<?> Deprecated.protected final BlockPos
Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEntityType
(CompoundTag tag, BlockEntityType<?> entityType) final void
applyComponents
(DataComponentMap components, DataComponentPatch patch) final void
protected void
applyImplicitComponents
(BlockEntity.DataComponentInput componentInput) void
final DataComponentMap
protected void
collectImplicitComponents
(DataComponentMap.Builder components) void
fillCrashReportCategory
(CrashReportCategory reportCategory) getLevel()
private String
Gets aCompoundTag
that can be used to store custom data for this block entity.static BlockPos
getPosFromTag
(CompoundTag tag) getType()
getUpdateTag
(HolderLookup.Provider registries) boolean
hasLevel()
boolean
boolean
isValidBlockState
(BlockState p_353131_) protected void
loadAdditional
(CompoundTag tag, HolderLookup.Provider registries) final void
loadCustomOnly
(CompoundTag tag, HolderLookup.Provider registries) static BlockEntity
loadStatic
(BlockPos pos, BlockState state, CompoundTag tag, HolderLookup.Provider registries) final void
loadWithComponents
(CompoundTag tag, HolderLookup.Provider registries) boolean
static Component
parseCustomNameSafe
(String customName, HolderLookup.Provider registries) void
Deprecated.final <T> T
removeData
(AttachmentType<T> type) Removes the data attachment of the given type.protected void
saveAdditional
(CompoundTag tag, HolderLookup.Provider registries) final CompoundTag
saveCustomAndMetadata
(HolderLookup.Provider registries) final CompoundTag
saveCustomOnly
(HolderLookup.Provider registries) private void
saveId
(CompoundTag tag) private void
saveMetadata
(CompoundTag tag) void
saveToItem
(ItemStack stack, HolderLookup.Provider registries) final CompoundTag
saveWithFullMetadata
(HolderLookup.Provider registries) final CompoundTag
saveWithId
(HolderLookup.Provider registries) final CompoundTag
saveWithoutMetadata
(HolderLookup.Provider registries) void
setBlockState
(BlockState blockState) Deprecated.void
protected static void
setChanged
(Level level, BlockPos pos, BlockState state) void
setComponents
(DataComponentMap components) final <T> T
setData
(AttachmentType<T> type, T data) Sets the data attachment of the given type.void
void
boolean
triggerEvent
(int id, int type) private void
validateBlockState
(BlockState p_353132_) Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachments
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData
Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
type
Deprecated. -
level
-
worldPosition
-
remove
protected boolean remove -
blockState
-
components
-
customPersistentData
-
-
Constructor Details
-
BlockEntity
-
-
Method Details
-
validateBlockState
-
isValidBlockState
-
getPosFromTag
-
getLevel
-
setLevel
-
hasLevel
public boolean hasLevel() -
loadAdditional
-
loadWithComponents
-
loadCustomOnly
-
saveAdditional
-
saveWithFullMetadata
-
saveWithId
-
saveWithoutMetadata
-
saveCustomOnly
-
saveCustomAndMetadata
-
saveId
-
addEntityType
-
saveToItem
-
saveMetadata
-
loadStatic
@Nullable public static BlockEntity loadStatic(BlockPos pos, BlockState state, CompoundTag tag, HolderLookup.Provider registries) -
setChanged
public void setChanged() -
setChanged
-
getBlockPos
-
getBlockState
-
getUpdatePacket
-
getUpdateTag
-
isRemoved
public boolean isRemoved() -
setRemoved
public void setRemoved() -
clearRemoved
public void clearRemoved() -
triggerEvent
public boolean triggerEvent(int id, int type) -
fillCrashReportCategory
-
getNameForReporting
-
onlyOpCanSetNbt
public boolean onlyOpCanSetNbt() -
getType
-
getPersistentData
Description copied from interface:IBlockEntityExtension
Gets aCompoundTag
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 interfaceIBlockEntityExtension
- Returns:
- A compound tag for custom persistent data
-
setData
Description copied from interface:IAttachmentHolder
Sets the data attachment of the given type.- Specified by:
setData
in interfaceIAttachmentHolder
- Overrides:
setData
in classAttachmentHolder
- Returns:
- the previous value for that attachment type, if any, or
null
if there was none
-
removeData
Description copied from interface:IAttachmentHolder
Removes the data attachment of the given type.- Specified by:
removeData
in interfaceIAttachmentHolder
- Overrides:
removeData
in classAttachmentHolder
- Returns:
- the previous value for that attachment type, if any, or
null
if there was none
-
setBlockState
Deprecated. -
applyImplicitComponents
-
applyComponentsFromItemStack
-
applyComponents
-
collectImplicitComponents
-
removeComponentsFromTag
Deprecated. -
collectComponents
-
components
-
setComponents
-
parseCustomNameSafe
@Nullable public static Component parseCustomNameSafe(String customName, HolderLookup.Provider registries)
-