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:
Clearable
,Container
,MenuConstructor
,Hopper
,MenuProvider
,Nameable
,RandomizableContainer
,IAttachmentHolder
,IMenuProviderExtension
,IBlockEntityExtension
-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraft.world.level.block.entity.BlockEntity
BlockEntity.ComponentHelper, BlockEntity.DataComponentInput
Nested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[][]
private int
private Direction
static final int
private NonNullList
<ItemStack> static final int
private long
Fields inherited from class net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity
lootTable, lootTableSeed
Fields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPosition
Fields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEY
Fields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFER
Fields inherited from interface net.minecraft.world.RandomizableContainer
LOOT_TABLE_SEED_TAG, LOOT_TABLE_TAG
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemStack
Attempts to place the passed stack in the container, using as many slots as required.static boolean
addItem
(Container container, ItemEntity item) private static boolean
canMergeItems
(ItemStack stack1, ItemStack stack2) private static boolean
canPlaceItemInContainer
(Container container, ItemStack stack, int slot, Direction direction) private static boolean
canTakeItemFromContainer
(Container source, Container destination, ItemStack stack, int slot, Direction direction) private static int[]
createFlatSlots
(int size) protected AbstractContainerMenu
createMenu
(int id, Inventory player) private static boolean
ejectItems
(Level level, BlockPos pos, HopperBlockEntity blockEntity) static void
entityInside
(Level level, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) private static Container
getAttachedContainer
(Level level, BlockPos pos, HopperBlockEntity blockEntity) private static Container
getBlockContainer
(Level level, BlockPos pos, BlockState state) static Container
getContainerAt
(Level level, BlockPos pos) private static Container
getContainerAt
(Level level, BlockPos pos, BlockState state, double x, double y, double z) int
protected Component
private static Container
getEntityContainer
(Level level, double x, double y, double z) protected NonNullList
<ItemStack> getItems()
static List
<ItemEntity> getItemsAtAndAbove
(Level level, Hopper hopper) long
double
double
double
private static int[]
private static Container
getSourceContainer
(Level level, Hopper hopper, BlockPos pos, BlockState state) private boolean
private static boolean
isFullContainer
(Container container, Direction direction) boolean
private boolean
boolean
protected void
loadAdditional
(CompoundTag tag, HolderLookup.Provider registries) static void
pushItemsTick
(Level level, BlockPos pos, BlockState state, HopperBlockEntity blockEntity) removeItem
(int index, int count) Removes up to a specified number of items from an inventory slot and returns them in a new stack.protected void
saveAdditional
(CompoundTag tag, HolderLookup.Provider registries) void
setBlockState
(BlockState blockState) void
setCooldown
(int cooldownTime) void
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).protected void
setItems
(NonNullList<ItemStack> items) static boolean
suckInItems
(Level level, Hopper hopper) private static ItemStack
tryMoveInItem
(Container source, Container destination, ItemStack stack, int slot, Direction direction) private static boolean
tryMoveItems
(Level level, BlockPos pos, BlockState state, HopperBlockEntity blockEntity, BooleanSupplier validator) private static boolean
tryTakeInItemFromSlot
(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.Methods inherited from class net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity
applyImplicitComponents, canOpen, collectImplicitComponents, createMenu, getItem, getLootTable, getLootTableSeed, isEmpty, removeComponentsFromTag, removeItemNoUpdate, setLootTable, setLootTableSeed
Methods inherited from class net.minecraft.world.level.block.entity.BaseContainerBlockEntity
canUnlock, clearContent, getCustomName, getDisplayName, getName, stillValid
Methods inherited from class net.minecraft.world.level.block.entity.BlockEntity
addEntityType, applyComponents, applyComponentsFromItemStack, clearRemoved, collectComponents, components, fillCrashReportCategory, getBlockPos, getBlockState, getLevel, getPersistentData, getPosFromTag, getType, getUpdatePacket, getUpdateTag, hasLevel, isRemoved, isValidBlockState, loadCustomOnly, loadStatic, loadWithComponents, onlyOpCanSetNbt, parseCustomNameSafe, removeData, saveCustomAndMetadata, saveCustomOnly, saveToItem, saveWithFullMetadata, saveWithId, saveWithoutMetadata, setChanged, setChanged, setComponents, setData, setLevel, setRemoved, triggerEvent
Methods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachments
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.world.Clearable
clearContent
Methods inherited from interface net.minecraft.world.Container
canPlaceItem, canTakeItem, countItem, getItem, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, isEmpty, removeItemNoUpdate, setChanged, startOpen, stillValid, stopOpen
Methods inherited from interface net.minecraft.world.level.block.entity.Hopper
getSuckAabb
Methods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData
Methods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdate
Methods inherited from interface net.neoforged.neoforge.client.extensions.IMenuProviderExtension
shouldTriggerClientSideContainerClosingOnOpen, writeClientSideData
Methods inherited from interface net.minecraft.world.Nameable
hasCustomName
Methods inherited from interface net.minecraft.world.RandomizableContainer
getBlockPos, getLevel, setLootTable, tryLoadLootTable, trySaveLootTable, unpackLootTable
-
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 -
items
-
cooldownTime
private int cooldownTime -
tickedGameTime
private long tickedGameTime -
facing
-
-
Constructor Details
-
HopperBlockEntity
-
-
Method Details
-
loadAdditional
- Overrides:
loadAdditional
in classBaseContainerBlockEntity
-
saveAdditional
- Overrides:
saveAdditional
in classBaseContainerBlockEntity
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSize
in interfaceContainer
-
removeItem
Description copied from class:RandomizableContainerBlockEntity
Removes up to a specified number of items from an inventory slot and returns them in a new stack.- Specified by:
removeItem
in interfaceContainer
- Overrides:
removeItem
in classRandomizableContainerBlockEntity
-
setItem
Description copied from class:RandomizableContainerBlockEntity
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).- Specified by:
setItem
in interfaceContainer
- Overrides:
setItem
in classRandomizableContainerBlockEntity
-
setBlockState
- Overrides:
setBlockState
in classBlockEntity
-
getDefaultName
- Specified by:
getDefaultName
in classBaseContainerBlockEntity
-
pushItemsTick
public static void pushItemsTick(Level level, BlockPos pos, BlockState state, HopperBlockEntity blockEntity) -
tryMoveItems
private static boolean tryMoveItems(Level level, BlockPos pos, BlockState state, HopperBlockEntity blockEntity, BooleanSupplier validator) -
inventoryFull
private boolean inventoryFull() -
ejectItems
-
getSlots
-
createFlatSlots
private static int[] createFlatSlots(int size) -
isFullContainer
- Returns:
false
if thecontainer
has any room to place items in
-
suckInItems
-
tryTakeInItemFromSlot
private static boolean tryTakeInItemFromSlot(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.- Returns:
true
if the entire stack was moved.
-
addItem
-
addItem
public static ItemStack addItem(@Nullable Container source, Container destination, ItemStack stack, @Nullable Direction direction) Attempts to place the passed stack in the container, using as many slots as required.- Returns:
- any leftover stack
-
canPlaceItemInContainer
-
canTakeItemFromContainer
-
tryMoveInItem
-
getAttachedContainer
@Nullable private static Container getAttachedContainer(Level level, BlockPos pos, HopperBlockEntity blockEntity) -
getSourceContainer
@Nullable private static Container getSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) -
getItemsAtAndAbove
-
getContainerAt
-
getContainerAt
@Nullable private static Container getContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) -
getBlockContainer
-
getEntityContainer
-
canMergeItems
-
getLevelX
public double getLevelX() -
getLevelY
public double getLevelY() -
getLevelZ
public double getLevelZ() -
isGridAligned
public boolean isGridAligned()- Specified by:
isGridAligned
in interfaceHopper
-
setCooldown
public void setCooldown(int cooldownTime) -
isOnCooldown
private boolean isOnCooldown() -
isOnCustomCooldown
public boolean isOnCustomCooldown() -
getItems
- Specified by:
getItems
in classBaseContainerBlockEntity
-
setItems
- Specified by:
setItems
in classBaseContainerBlockEntity
-
entityInside
public static void entityInside(Level level, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) -
createMenu
- Specified by:
createMenu
in classBaseContainerBlockEntity
-
getLastUpdateTime
public long getLastUpdateTime()
-