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
,BlockPropertyTests.LightBlockEntity
,BrushableBlockEntity
,CampfireBlockEntity
,ChiseledBookShelfBlockEntity
,CommandBlockEntity
,ComparatorBlockEntity
,ConduitBlockEntity
,CustomItemDisplayContextTest.ItemHangerBlockEntity
,DaylightDetectorBlockEntity
,DecoratedPotBlockEntity
,EnchantingTableBlockEntity
,EnderChestBlockEntity
,FullPotsAccessorDemo.DioriteFlowerPotBlockEntity
,GameTestTest.EnergyBlockEntity
,JigsawBlockEntity
,JukeboxBlockEntity
,LecternBlockEntity
,MegaModelTest.TestBlock.Entity
,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
ConstructorsConstructorDescriptionBlockEntity
(BlockEntityType<?> pType, BlockPos pPos, BlockState pBlockState) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
addEntityType
(CompoundTag pTag, BlockEntityType<?> pEntityType) final void
applyComponents
(DataComponentMap pComponents, DataComponentPatch pPatch) final void
protected void
applyImplicitComponents
(BlockEntity.DataComponentInput pComponentInput) void
final DataComponentMap
protected void
collectImplicitComponents
(DataComponentMap.Builder pComponents) void
fillCrashReportCategory
(CrashReportCategory pReportCategory) getLevel()
private String
Gets aCompoundTag
that can be used to store custom data for this block entity.static BlockPos
getPosFromTag
(CompoundTag pTag) getType()
getUpdateTag
(HolderLookup.Provider pRegistries) boolean
hasLevel()
boolean
boolean
isValidBlockState
(BlockState p_353131_) protected void
loadAdditional
(CompoundTag pTag, HolderLookup.Provider pRegistries) final void
loadCustomOnly
(CompoundTag pTag, HolderLookup.Provider pRegistries) static BlockEntity
loadStatic
(BlockPos pPos, BlockState pState, CompoundTag pTag, HolderLookup.Provider pRegistries) final void
loadWithComponents
(CompoundTag pTag, HolderLookup.Provider pRegistries) boolean
static Component
parseCustomNameSafe
(String pCustomName, HolderLookup.Provider pRegistries) void
Deprecated.final <T> T
removeData
(AttachmentType<T> type) Removes the data attachment of the given type.protected void
saveAdditional
(CompoundTag pTag, HolderLookup.Provider pRegistries) final CompoundTag
saveCustomAndMetadata
(HolderLookup.Provider pRegistries) final CompoundTag
saveCustomOnly
(HolderLookup.Provider pRegistries) private void
saveId
(CompoundTag pTag) private void
saveMetadata
(CompoundTag pTag) void
saveToItem
(ItemStack pStack, HolderLookup.Provider pRegistries) final CompoundTag
saveWithFullMetadata
(HolderLookup.Provider pRegistries) final CompoundTag
saveWithId
(HolderLookup.Provider pRegistries) final CompoundTag
saveWithoutMetadata
(HolderLookup.Provider pRegistries) void
setBlockState
(BlockState pBlockState) Deprecated.void
protected static void
setChanged
(Level pLevel, BlockPos pPos, BlockState pState) void
setComponents
(DataComponentMap pComponents) final <T> T
setData
(AttachmentType<T> type, T data) Sets the data attachment of the given type.void
void
boolean
triggerEvent
(int pId, int pType) 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 pPos, BlockState pState, CompoundTag pTag, HolderLookup.Provider pRegistries) -
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 pId, int pType) -
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 pCustomName, HolderLookup.Provider pRegistries)
-