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
,CreakingHeartBlockEntity
,DaylightDetectorBlockEntity
,DecoratedPotBlockEntity
,EnchantingTableBlockEntity
,EnderChestBlockEntity
,JigsawBlockEntity
,JukeboxBlockEntity
,LecternBlockEntity
,PistonMovingBlockEntity
,SculkCatalystBlockEntity
,SculkSensorBlockEntity
,SculkShriekerBlockEntity
,SignBlockEntity
,SkullBlockEntity
,SpawnerBlockEntity
,StructureBlockEntity
,TestBlockEntity
,TestInstanceBlockEntity
,TheEndPortalBlockEntity
,TrialSpawnerBlockEntity
,VaultBlockEntity
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final record
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.private static final com.mojang.serialization.Codec
<BlockEntityType<?>> 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
(ValueOutput pOutput, BlockEntityType<?> pEntityType) final void
applyComponents
(DataComponentMap pComponents, DataComponentPatch pPatch) final void
protected void
applyImplicitComponents
(DataComponentGetter pComponentGetter) void
final DataComponentMap
protected void
collectImplicitComponents
(DataComponentMap.Builder pComponents) void
fillCrashReportCategory
(CrashReportCategory pReportCategory) getLevel()
Gets aCompoundTag
that can be used to store custom data for this block entity.static BlockPos
getPosFromTag
(ChunkPos pChunkPos, CompoundTag pTag) getType()
getUpdateTag
(HolderLookup.Provider pRegistries) boolean
hasLevel()
boolean
boolean
isValidBlockState
(BlockState pState) protected void
loadAdditional
(ValueInput pInput) final void
loadCustomOnly
(ValueInput pInput) static BlockEntity
loadStatic
(BlockPos pPos, BlockState pState, CompoundTag pTag, HolderLookup.Provider pRegistries) final void
loadWithComponents
(ValueInput pInput) static Component
parseCustomNameSafe
(ValueInput pInput, String pCustomName) void
preRemoveSideEffects
(BlockPos pPos, BlockState pState) void
removeComponentsFromTag
(ValueOutput pOutput) Deprecated.final <T> T
removeData
(AttachmentType<T> type) Removes the data attachment of the given type.protected void
saveAdditional
(ValueOutput pOutput) final CompoundTag
saveCustomOnly
(HolderLookup.Provider pRegistries) void
saveCustomOnly
(ValueOutput pOutput) private void
saveId
(ValueOutput pOutput) private void
saveMetadata
(ValueOutput pOutput) final CompoundTag
saveWithFullMetadata
(HolderLookup.Provider pRegistries) void
saveWithFullMetadata
(ValueOutput pOutput) void
saveWithId
(ValueOutput pOutput) final CompoundTag
saveWithoutMetadata
(HolderLookup.Provider pRegistries) void
saveWithoutMetadata
(ValueOutput pOutput) 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 pState) 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, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate
-
Field Details
-
TYPE_CODEC
-
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
-
saveWithFullMetadata
-
saveWithId
-
saveWithoutMetadata
-
saveWithoutMetadata
-
saveCustomOnly
-
saveCustomOnly
-
saveId
-
addEntityType
-
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() -
preRemoveSideEffects
-
triggerEvent
public boolean triggerEvent(int pId, int pType) -
fillCrashReportCategory
-
getNameForReporting
-
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
-
problemPath
-