Class HopperBlockEntity
java.lang.Object
net.neoforged.neoforge.attachment.AttachmentHolder
net.minecraft.world.level.block.entity.BlockEntity
net.minecraft.world.level.block.entity.BaseContainerBlockEntity
net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity
net.minecraft.world.level.block.entity.HopperBlockEntity
- All Implemented Interfaces:
Iterable<ItemStack>, TypedInstance<BlockEntityType<?>>, DebugValueSource, Clearable, Container, SlotProvider, MenuConstructor, Hopper, MenuProvider, Nameable, RandomizableContainer, IAttachmentHolder, ContainerExtension, IBlockEntityExtension, IMenuProviderExtension
-
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
FieldsModifier and TypeFieldDescriptionprivate static final int[][]private intprivate final SnapshotJournal<Integer> private static final Componentprivate Directionstatic final intprivate NonNullList<ItemStack> static final intprivate static final intprivate longFields inherited from class RandomizableContainerBlockEntity
lootTable, lootTableSeedFields inherited from class BlockEntity
level, remove, worldPositionFields inherited from class AttachmentHolder
ATTACHMENTS_NBT_KEYFields inherited from interface Container
DEFAULT_DISTANCE_BUFFERFields inherited from interface RandomizableContainer
LOOT_TABLE_SEED_TAG, LOOT_TABLE_TAG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemStackaddItem(@Nullable Container from, Container container, ItemStack itemStack, @Nullable Direction direction) Attempts to place the passed stack in the container, using as many slots as required.static booleanaddItem(Container container, ItemEntity entity) private static booleancanMergeItems(ItemStack a, ItemStack b) private static booleancanPlaceItemInContainer(Container container, ItemStack itemStack, int slot, @Nullable Direction direction) private static booleancanTakeItemFromContainer(Container into, Container from, ItemStack itemStack, int slot, Direction direction) private static int[]createFlatSlots(int containerSize) protected AbstractContainerMenucreateMenu(int containerId, Inventory inventory) private static booleanejectItems(Level level, BlockPos blockPos, HopperBlockEntity self) static voidentityInside(Level level, BlockPos pos, BlockState blockState, Entity entity, HopperBlockEntity hopper) private static @Nullable ContainergetAttachedContainer(Level level, BlockPos blockPos, HopperBlockEntity self) private static @Nullable ContainergetBlockContainer(Level level, BlockPos pos, BlockState state) static @Nullable ContainergetContainerAt(Level level, BlockPos pos) Deprecated.Use IItemHandler capability instead.private static @Nullable ContainergetContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) static ContainerOrHandlergetContainerOrHandlerAt(Level level, BlockPos pos, @Nullable Direction side) private static ContainerOrHandlergetContainerOrHandlerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z, @Nullable Direction side) intprotected Componentprivate static @Nullable ContainergetEntityContainer(Level level, double x, double y, double z) protected NonNullList<ItemStack> getItems()static List<ItemEntity> getItemsAtAndAbove(Level level, Hopper hopper) longdoubledoubledoubleprivate static int[]private static @Nullable ContainergetSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) private static ContainerOrHandlergetSourceContainerOrHandler(Level level, Hopper hopper, BlockPos pos, BlockState state) private booleanprivate static booleanisFullContainer(Container container, Direction direction) booleanprivate booleanbooleanprotected voidloadAdditional(ValueInput input) voidonTransfer(int slot, int amountChange, TransactionContext transaction) Perform additional logic during the transaction, immediately after a successful transfer (i.e.static voidpushItemsTick(Level level, BlockPos pos, BlockState state, HopperBlockEntity entity) removeItem(int slot, int count) Removes up to a specified number of items from an inventory slot and returns them in a new stack.protected voidsaveAdditional(ValueOutput output) voidsetBlockState(BlockState blockState) voidsetCooldown(int time) voidSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).protected voidsetItems(NonNullList<ItemStack> items) static booleansuckInItems(Level level, Hopper hopper) private static ItemStacktryMoveInItem(@Nullable Container from, Container container, ItemStack itemStack, int slot, @Nullable Direction direction) private static booleantryMoveItems(Level level, BlockPos pos, BlockState state, HopperBlockEntity entity, BooleanSupplier action) private static booleantryTakeInItemFromSlot(Hopper hopper, Container container, int slot, Direction direction) Pulls from the specified slot in the container and places in any available slot in the hopper.private booleanwasEmpty(int slot, int amountChange) Methods inherited from class RandomizableContainerBlockEntity
applyImplicitComponents, canOpen, collectImplicitComponents, createMenu, getItem, getLootTable, getLootTableSeed, isEmpty, removeComponentsFromTag, removeItemNoUpdate, setLootTable, setLootTableSeedMethods inherited from class BaseContainerBlockEntity
clearContent, getCustomName, getDisplayName, getName, isLocked, sendChestLockedNotifications, setItem, stillValidMethods 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, 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 Clearable
clearContentMethods inherited from interface Container
canPlaceItem, canTakeItem, countItem, getEntitiesWithContainerOpen, getItem, getMaxStackSize, getMaxStackSize, getSlot, hasAnyMatching, hasAnyOf, isEmpty, iterator, removeItemNoUpdate, setChanged, startOpen, stillValid, stopOpenMethods inherited from interface ContainerExtension
setItemMethods inherited from interface Hopper
getSuckAabbMethods 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 RandomizableContainer
getBlockPos, getLevel, setLootTable, tryLoadLootTable, trySaveLootTable, unpackLootTableMethods inherited from interface SlotProvider
getSlotsFromRange
-
Field Details
-
MOVE_ITEM_SPEED
public static final int MOVE_ITEM_SPEED- See Also:
-
HOPPER_CONTAINER_SIZE
public static final int HOPPER_CONTAINER_SIZE- See Also:
-
CACHED_SLOTS
private static final int[][] CACHED_SLOTS -
NO_COOLDOWN_TIME
private static final int NO_COOLDOWN_TIME- See Also:
-
DEFAULT_NAME
-
items
-
cooldownTime
private int cooldownTime -
tickedGameTime
private long tickedGameTime -
facing
-
cooldownTimeJournal
-
-
Constructor Details
-
HopperBlockEntity
-
-
Method Details
-
loadAdditional
- Overrides:
loadAdditionalin classBaseContainerBlockEntity
-
saveAdditional
- Overrides:
saveAdditionalin classBaseContainerBlockEntity
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSizein interfaceContainer
-
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- Overrides:
removeItemin classRandomizableContainerBlockEntity
-
setItem
Description copied from interface:ContainerSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).- Specified by:
setItemin interfaceContainer- Overrides:
setItemin classRandomizableContainerBlockEntity
-
wasEmpty
private boolean wasEmpty(int slot, int amountChange) -
onTransfer
Description copied from interface:ContainerExtensionPerform additional logic during the transaction, immediately after a successful transfer (i.e. insert or extract with result > 0). Any logic performed by this method should be fully transactional, and support being rolled back. In other words, the transaction is still ongoing.- Specified by:
onTransferin interfaceContainerExtension- Parameters:
amountChange- If positive, the amount of items that were just inserted into this slot. If negative, minus the amount of items that were just extracted from this slot.
-
setBlockState
- Overrides:
setBlockStatein classBlockEntity
-
getDefaultName
- Specified by:
getDefaultNamein classBaseContainerBlockEntity
-
pushItemsTick
public static void pushItemsTick(Level level, BlockPos pos, BlockState state, HopperBlockEntity entity) -
tryMoveItems
private static boolean tryMoveItems(Level level, BlockPos pos, BlockState state, HopperBlockEntity entity, BooleanSupplier action) -
inventoryFull
private boolean inventoryFull() -
ejectItems
-
getSlots
-
createFlatSlots
private static int[] createFlatSlots(int containerSize) -
isFullContainer
-
suckInItems
-
tryTakeInItemFromSlot
-
addItem
-
addItem
-
canPlaceItemInContainer
-
canTakeItemFromContainer
-
tryMoveInItem
-
getAttachedContainer
private static @Nullable Container getAttachedContainer(Level level, BlockPos blockPos, HopperBlockEntity self) -
getSourceContainer
private static @Nullable Container getSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) -
getItemsAtAndAbove
-
getContainerAt
Deprecated.Use IItemHandler capability instead. To preserve Container-specific interactions, usegetContainerOrHandlerAt(Level, BlockPos, Direction)and handle both cases. -
getContainerAt
private static @Nullable Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) -
getBlockContainer
-
getEntityContainer
-
getSourceContainerOrHandler
private static ContainerOrHandler getSourceContainerOrHandler(Level level, Hopper hopper, BlockPos pos, BlockState state) -
getContainerOrHandlerAt
public static ContainerOrHandler getContainerOrHandlerAt(Level level, BlockPos pos, @Nullable Direction side) -
getContainerOrHandlerAt
private static ContainerOrHandler getContainerOrHandlerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z, @Nullable Direction side) -
canMergeItems
-
getLevelX
-
getLevelY
-
getLevelZ
-
isGridAligned
public boolean isGridAligned()- Specified by:
isGridAlignedin interfaceHopper
-
setCooldown
public void setCooldown(int time) -
isOnCooldown
private boolean isOnCooldown() -
isOnCustomCooldown
public boolean isOnCustomCooldown() -
getItems
- Specified by:
getItemsin classBaseContainerBlockEntity
-
setItems
- Specified by:
setItemsin classBaseContainerBlockEntity
-
entityInside
public static void entityInside(Level level, BlockPos pos, BlockState blockState, Entity entity, HopperBlockEntity hopper) -
createMenu
- Specified by:
createMenuin classBaseContainerBlockEntity
-
getLastUpdateTime
public long getLastUpdateTime()
-