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 classprotected static interfaceNested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BlockStateprivate DataComponentMapprivate CompoundTagprotected Levelprivate static final org.slf4j.Loggerprotected booleanprivate final BlockEntityType<?> Deprecated.protected final BlockPosFields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEntityType(CompoundTag tag, BlockEntityType<?> entityType) final voidapplyComponents(DataComponentMap components, DataComponentPatch patch) final voidprotected voidapplyImplicitComponents(BlockEntity.DataComponentInput componentInput) voidfinal DataComponentMapprotected voidcollectImplicitComponents(DataComponentMap.Builder components) voidfillCrashReportCategory(CrashReportCategory reportCategory) getLevel()private StringGets aCompoundTagthat can be used to store custom data for this block entity.static BlockPosgetPosFromTag(CompoundTag tag) getType()getUpdateTag(HolderLookup.Provider registries) booleanhasLevel()booleanbooleanisValidBlockState(BlockState p_353131_) protected voidloadAdditional(CompoundTag tag, HolderLookup.Provider registries) final voidloadCustomOnly(CompoundTag tag, HolderLookup.Provider registries) static BlockEntityloadStatic(BlockPos pos, BlockState state, CompoundTag tag, HolderLookup.Provider registries) final voidloadWithComponents(CompoundTag tag, HolderLookup.Provider registries) booleanstatic ComponentparseCustomNameSafe(String customName, HolderLookup.Provider registries) voidDeprecated.final <T> TremoveData(AttachmentType<T> type) Removes the data attachment of the given type.protected voidsaveAdditional(CompoundTag tag, HolderLookup.Provider registries) final CompoundTagsaveCustomAndMetadata(HolderLookup.Provider registries) final CompoundTagsaveCustomOnly(HolderLookup.Provider registries) private voidsaveId(CompoundTag tag) private voidsaveMetadata(CompoundTag tag) voidsaveToItem(ItemStack stack, HolderLookup.Provider registries) final CompoundTagsaveWithFullMetadata(HolderLookup.Provider registries) final CompoundTagsaveWithId(HolderLookup.Provider registries) final CompoundTagsaveWithoutMetadata(HolderLookup.Provider registries) voidsetBlockState(BlockState blockState) Deprecated.voidprotected static voidsetChanged(Level level, BlockPos pos, BlockState state) voidsetComponents(DataComponentMap components) final <T> TsetData(AttachmentType<T> type, T data) Sets the data attachment of the given type.voidvoidbooleantriggerEvent(int id, int type) private voidvalidateBlockState(BlockState p_353132_) Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setDataMethods 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:IBlockEntityExtensionGets aCompoundTagthat 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:
getPersistentDatain interfaceIBlockEntityExtension- Returns:
- A compound tag for custom persistent data
-
setData
Description copied from interface:IAttachmentHolderSets the data attachment of the given type.- Specified by:
setDatain interfaceIAttachmentHolder- Overrides:
setDatain classAttachmentHolder- Returns:
- the previous value for that attachment type, if any, or
nullif there was none
-
removeData
Description copied from interface:IAttachmentHolderRemoves the data attachment of the given type.- Specified by:
removeDatain interfaceIAttachmentHolder- Overrides:
removeDatain classAttachmentHolder- Returns:
- the previous value for that attachment type, if any, or
nullif 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)
-