Class BaseContainerBlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
net.minecraft.world.level.block.entity.BaseContainerBlockEntity
- All Implemented Interfaces:
Iterable<ItemStack>, TypedInstance<BlockEntityType<?>>, DebugValueSource, Clearable, Container, SlotProvider, MenuConstructor, MenuProvider, Nameable, IAttachmentHolder, ContainerExtension, IBlockEntityExtension, IMenuProviderExtension
- Direct Known Subclasses:
AbstractFurnaceBlockEntity, BrewingStandBlockEntity, RandomizableContainerBlockEntity
public abstract class BaseContainerBlockEntity
extends BlockEntity
implements Container, MenuProvider, Nameable
-
Nested Class Summary
Nested classes/interfaces inherited from class AttachmentHolder
AttachmentHolder.AsFieldNested classes/interfaces inherited from interface Container
Container.ContainerIteratorNested classes/interfaces inherited from interface DebugValueSource
DebugValueSource.Registration, DebugValueSource.ValueGetter<T> -
Field Summary
FieldsFields inherited from class BlockEntity
level, remove, worldPositionFields inherited from class AttachmentHolder
ATTACHMENTS_NBT_KEYFields inherited from interface Container
DEFAULT_DISTANCE_BUFFER -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBaseContainerBlockEntity(BlockEntityType<?> type, BlockPos worldPosition, BlockState blockState) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidapplyImplicitComponents(DataComponentGetter components) booleanvoidprotected voidcollectImplicitComponents(DataComponentMap.Builder components) protected abstract AbstractContainerMenucreateMenu(int containerId, Inventory inventory) @Nullable AbstractContainerMenucreateMenu(int containerId, Inventory inventory, Player player) @Nullable Componentprotected abstract ComponentgetItem(int slot) Returns the stack in the given slot.protected abstract NonNullList<ItemStack> getItems()getName()booleanisEmpty()booleanisLocked()protected voidloadAdditional(ValueInput input) voidremoveComponentsFromTag(ValueOutput output) removeItem(int slot, int count) Removes up to a specified number of items from an inventory slot and returns them in a new stack.removeItemNoUpdate(int slot) Removes a stack from the given slot and returns it.protected voidsaveAdditional(ValueOutput output) static voidsendChestLockedNotifications(Vec3 pos, Player player, Component displayName) voidSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).voidAn extension ofContainer.setItem(int, ItemStack)that allows non-transactional side-effects to be skipped.protected abstract voidsetItems(NonNullList<ItemStack> items) booleanstillValid(Player player) Don't rename this method to canInteractWith due to conflicts with ContainerMethods inherited from class BlockEntity
addEntityType, applyComponents, applyComponentsFromItemStack, clearRemoved, collectComponents, components, fillCrashReportCategory, getAndClearAttachmentTypesToSync, getBlockPos, getBlockState, getLevel, getNameForReporting, getPersistentData, getPosFromTag, getType, getUpdatePacket, getUpdateTag, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, parseCustomNameSafe, preRemoveSideEffects, problemPath, registerDebugValues, removeData, saveCustomOnly, saveCustomOnly, saveWithFullMetadata, saveWithFullMetadata, saveWithId, saveWithoutMetadata, saveWithoutMetadata, setBlockState, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, syncData, triggerEvent, typeHolderMethods 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 Container
canPlaceItem, canTakeItem, countItem, getContainerSize, getEntitiesWithContainerOpen, getMaxStackSize, getMaxStackSize, getSlot, hasAnyMatching, hasAnyOf, iterator, setChanged, startOpen, stopOpenMethods inherited from interface ContainerExtension
onTransferMethods inherited from interface IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdateMethods inherited from interface IMenuProviderExtension
shouldTriggerClientSideContainerClosingOnOpen, writeClientSideDataMethods inherited from interface Iterable
forEach, spliteratorMethods inherited from interface Nameable
getPlainTextName, hasCustomNameMethods inherited from interface SlotProvider
getSlotsFromRange
-
Field Details
-
lockKey
-
name
-
-
Constructor Details
-
BaseContainerBlockEntity
protected BaseContainerBlockEntity(BlockEntityType<?> type, BlockPos worldPosition, BlockState blockState)
-
-
Method Details
-
loadAdditional
- Overrides:
loadAdditionalin classBlockEntity
-
saveAdditional
- Overrides:
saveAdditionalin classBlockEntity
-
getName
-
getDisplayName
- Specified by:
getDisplayNamein interfaceMenuProvider- Specified by:
getDisplayNamein interfaceNameable
-
getCustomName
- Specified by:
getCustomNamein interfaceNameable
-
getDefaultName
-
canOpen
-
sendChestLockedNotifications
-
isLocked
public boolean isLocked() -
getItems
-
setItems
-
isEmpty
-
getItem
-
removeItem
Description copied from interface:ContainerRemoves up to a specified number of items from an inventory slot and returns them in a new stack.- Specified by:
removeItemin interfaceContainer
-
removeItemNoUpdate
Description copied from interface:ContainerRemoves a stack from the given slot and returns it.- Specified by:
removeItemNoUpdatein interfaceContainer
-
setItem
-
setItem
Description copied from interface:ContainerExtensionAn extension ofContainer.setItem(int, ItemStack)that allows non-transactional side-effects to be skipped. Non-transactional side-effects include for example callingsetChangedor making changes to the world.- Specified by:
setItemin interfaceContainerExtension- Parameters:
insideTransaction- Whentrue, non-transactional actions should be deferred. Whenfalse, non-transactional actions can be performed immediately.- See Also:
-
stillValid
Description copied from interface:ContainerDon't rename this method to canInteractWith due to conflicts with Container- Specified by:
stillValidin interfaceContainer
-
clearContent
public void clearContent()- Specified by:
clearContentin interfaceClearable
-
createMenu
public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory inventory, Player player) - Specified by:
createMenuin interfaceMenuConstructor
-
createMenu
-
applyImplicitComponents
- Overrides:
applyImplicitComponentsin classBlockEntity
-
collectImplicitComponents
- Overrides:
collectImplicitComponentsin classBlockEntity
-
removeComponentsFromTag
- Overrides:
removeComponentsFromTagin classBlockEntity
-