Class BlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
- All Implemented Interfaces:
TypedInstance<BlockEntityType<?>>, 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, TypedInstance<BlockEntityType<?>>, IBlockEntityExtension
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class AttachmentHolder
AttachmentHolder.AsFieldNested classes/interfaces inherited from interface DebugValueSource
DebugValueSource.Registration, DebugValueSource.ValueGetter<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate @Nullable Set<AttachmentType<?>> private BlockStateprivate DataComponentMapprivate @Nullable CompoundTagprotected @Nullable Levelprivate static final org.slf4j.Loggerprotected booleanprivate final BlockEntityType<?> Deprecated.private static final com.mojang.serialization.Codec<BlockEntityType<?>> protected final BlockPosFields inherited from class AttachmentHolder
ATTACHMENTS_NBT_KEY -
Constructor Summary
ConstructorsConstructorDescriptionBlockEntity(BlockEntityType<?> type, BlockPos worldPosition, BlockState blockState) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEntityType(ValueOutput output, BlockEntityType<?> type) final voidapplyComponents(DataComponentMap prototype, DataComponentPatch patch) final voidprotected voidapplyImplicitComponents(DataComponentGetter components) voidfinal DataComponentMapprotected voidcollectImplicitComponents(DataComponentMap.Builder components) voidfillCrashReportCategory(CrashReportCategory category) final @Nullable Set<AttachmentType<?>> @Nullable LevelgetLevel()Gets aCompoundTagthat can be used to store custom data for this block entity.static BlockPosgetPosFromTag(ChunkPos base, CompoundTag entityTag) getType()@Nullable Packet<ClientGamePacketListener> getUpdateTag(HolderLookup.Provider registries) booleanhasLevel()booleanbooleanisValidBlockState(BlockState blockState) protected voidloadAdditional(ValueInput input) final voidloadCustomOnly(ValueInput input) static @Nullable BlockEntityloadStatic(BlockPos pos, BlockState state, CompoundTag tag, HolderLookup.Provider registries) final voidloadWithComponents(ValueInput input) static @Nullable ComponentparseCustomNameSafe(ValueInput input, String name) voidpreRemoveSideEffects(BlockPos pos, BlockState state) voidregisterDebugValues(ServerLevel level, DebugValueSource.Registration registration) voidremoveComponentsFromTag(ValueOutput output) Deprecated.final <T> @Nullable TremoveData(AttachmentType<T> type) Removes the data attachment of the given type.protected voidsaveAdditional(ValueOutput output) final CompoundTagsaveCustomOnly(HolderLookup.Provider registries) voidsaveCustomOnly(ValueOutput output) private voidsaveId(ValueOutput output) private voidsaveMetadata(ValueOutput output) final CompoundTagsaveWithFullMetadata(HolderLookup.Provider registries) voidsaveWithFullMetadata(ValueOutput output) voidsaveWithId(ValueOutput output) final CompoundTagsaveWithoutMetadata(HolderLookup.Provider registries) voidsaveWithoutMetadata(ValueOutput output) voidsetBlockState(BlockState blockState) Deprecated.voidprotected static voidsetChanged(Level level, BlockPos worldPosition, BlockState blockState) voidsetComponents(DataComponentMap components) final <T> @Nullable 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 b0, int b1) private voidvalidateBlockState(BlockState blockState) Methods inherited from class AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface 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
-
attachmentTypesToSync
-
-
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
public static @Nullable 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() -
preRemoveSideEffects
-
triggerEvent
public boolean triggerEvent(int b0, int b1) -
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:
-
getAndClearAttachmentTypesToSync
-
typeHolder
- Specified by:
typeHolderin interfaceTypedInstance<BlockEntityType<?>>
-
setBlockState
Deprecated. -
applyImplicitComponents
-
applyComponentsFromItemStack
-
applyComponents
-
collectImplicitComponents
-
removeComponentsFromTag
Deprecated. -
collectComponents
-
components
-
setComponents
-
parseCustomNameSafe
-
problemPath
-
registerDebugValues
- Specified by:
registerDebugValuesin interfaceDebugValueSource
-