Class BlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
- All Implemented Interfaces:
DebugValueSource,IAttachmentHolder,IBlockEntityExtension
- Direct Known Subclasses:
BannerBlockEntity,BaseContainerBlockEntity,BeaconBlockEntity,BedBlockEntity,BeehiveBlockEntity,BellBlockEntity,BrushableBlockEntity,CampfireBlockEntity,ChiseledBookShelfBlockEntity,CommandBlockEntity,ComparatorBlockEntity,ConduitBlockEntity,CopperGolemStatueBlockEntity,CreakingHeartBlockEntity,DaylightDetectorBlockEntity,DecoratedPotBlockEntity,EnchantingTableBlockEntity,EnderChestBlockEntity,JigsawBlockEntity,JukeboxBlockEntity,LecternBlockEntity,PistonMovingBlockEntity,SculkCatalystBlockEntity,SculkSensorBlockEntity,SculkShriekerBlockEntity,ShelfBlockEntity,SignBlockEntity,SkullBlockEntity,SpawnerBlockEntity,StructureBlockEntity,TestBlockEntity,TestInstanceBlockEntity,TheEndPortalBlockEntity,TrialSpawnerBlockEntity,VaultBlockEntity
public abstract class BlockEntity
extends AttachmentHolder
implements DebugValueSource, IBlockEntityExtension
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static final recordNested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsFieldNested classes/interfaces inherited from interface net.minecraft.util.debug.DebugValueSource
DebugValueSource.Registration, DebugValueSource.ValueGetter<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BlockStateprivate DataComponentMapprivate CompoundTagprotected Levelprivate static final org.slf4j.Loggerprotected booleanprivate final BlockEntityType<?> Deprecated.private static final com.mojang.serialization.Codec<BlockEntityType<?>> protected final BlockPosFields 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 voidaddEntityType(ValueOutput pOutput, BlockEntityType<?> pEntityType) final voidapplyComponents(DataComponentMap pComponents, DataComponentPatch pPatch) final voidprotected voidapplyImplicitComponents(DataComponentGetter pComponentGetter) voidfinal DataComponentMapprotected voidcollectImplicitComponents(DataComponentMap.Builder pComponents) voidfillCrashReportCategory(CrashReportCategory pReportCategory) getLevel()Gets aCompoundTagthat can be used to store custom data for this block entity.static BlockPosgetPosFromTag(ChunkPos pChunkPos, CompoundTag pTag) getType()getUpdateTag(HolderLookup.Provider pRegistries) booleanhasLevel()booleanbooleanisValidBlockState(BlockState pState) protected voidloadAdditional(ValueInput pInput) final voidloadCustomOnly(ValueInput pInput) static BlockEntityloadStatic(BlockPos pPos, BlockState pState, CompoundTag pTag, HolderLookup.Provider pRegistries) final voidloadWithComponents(ValueInput pInput) static ComponentparseCustomNameSafe(ValueInput pInput, String pCustomName) voidpreRemoveSideEffects(BlockPos pPos, BlockState pState) voidregisterDebugValues(ServerLevel p_449833_, DebugValueSource.Registration p_449301_) voidremoveComponentsFromTag(ValueOutput pOutput) Deprecated.final <T> TremoveData(AttachmentType<T> type) Removes the data attachment of the given type.protected voidsaveAdditional(ValueOutput pOutput) final CompoundTagsaveCustomOnly(HolderLookup.Provider pRegistries) voidsaveCustomOnly(ValueOutput pOutput) private voidsaveId(ValueOutput pOutput) private voidsaveMetadata(ValueOutput pOutput) final CompoundTagsaveWithFullMetadata(HolderLookup.Provider pRegistries) voidsaveWithFullMetadata(ValueOutput pOutput) voidsaveWithId(ValueOutput pOutput) final CompoundTagsaveWithoutMetadata(HolderLookup.Provider pRegistries) voidsaveWithoutMetadata(ValueOutput pOutput) voidsetBlockState(BlockState pBlockState) Deprecated.voidprotected static voidsetChanged(Level pLevel, BlockPos pPos, BlockState pState) voidsetComponents(DataComponentMap pComponents) final <T> TsetData(AttachmentType<T> type, T data) Sets the data attachment of the given type.voidvoidfinal voidsyncData(AttachmentType<?> type) Syncs a data attachment of the given type with all relevant clients.booleantriggerEvent(int pId, int pType) private voidvalidateBlockState(BlockState pState) 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, setData, syncDataMethods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, 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: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
-
syncData
Description copied from interface:IAttachmentHolderSyncs a data attachment of the given type with all relevant clients.If there is currently no attachment of the given type, the removal of the attachment is synced to the client.
- Specified by:
syncDatain interfaceIAttachmentHolder- See Also:
-
setBlockState
Deprecated. -
applyImplicitComponents
-
applyComponentsFromItemStack
-
applyComponents
-
collectImplicitComponents
-
removeComponentsFromTag
Deprecated. -
collectComponents
-
components
-
setComponents
-
parseCustomNameSafe
-
problemPath
-
registerDebugValues
- Specified by:
registerDebugValuesin interfaceDebugValueSource
-