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 pContainer, ItemEntity pItem) private static boolean
canMergeItems
(ItemStack pStack1, ItemStack pStack2) private static boolean
canPlaceItemInContainer
(Container pContainer, ItemStack pStack, int pSlot, Direction pDirection) private static boolean
canTakeItemFromContainer
(Container pSource, Container pDestination, ItemStack pStack, int pSlot, Direction pDirection) private static int[]
createFlatSlots
(int pSize) protected AbstractContainerMenu
createMenu
(int pId, Inventory pPlayer) private static boolean
ejectItems
(Level pLevel, BlockPos pPos, HopperBlockEntity pBlockEntity) static void
entityInside
(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity, HopperBlockEntity pBlockEntity) private static Container
getAttachedContainer
(Level pLevel, BlockPos pPos, HopperBlockEntity pBlockEntity) private static Container
getBlockContainer
(Level pLevel, BlockPos pPos, BlockState pState) static Container
getContainerAt
(Level pLevel, BlockPos pPos) private static Container
getContainerAt
(Level pLevel, BlockPos pPos, BlockState pState, double pX, double pY, double pZ) int
protected Component
private static Container
getEntityContainer
(Level pLevel, double pX, double pY, double pZ) protected NonNullList
<ItemStack> getItems()
static List
<ItemEntity> getItemsAtAndAbove
(Level pLevel, Hopper pHopper) long
double
double
double
private static int[]
private static Container
getSourceContainer
(Level pLevel, Hopper pHopper, BlockPos pPos, BlockState pState) private boolean
private static boolean
isFullContainer
(Container pContainer, Direction pDirection) boolean
private boolean
boolean
protected void
loadAdditional
(CompoundTag pTag, HolderLookup.Provider pRegistries) static void
pushItemsTick
(Level pLevel, BlockPos pPos, BlockState pState, HopperBlockEntity pBlockEntity) removeItem
(int pIndex, int pCount) Removes up to a specified number of items from an inventory slot and returns them in a new stack.protected void
saveAdditional
(CompoundTag pTag, HolderLookup.Provider pRegistries) void
setBlockState
(BlockState pBlockState) void
setCooldown
(int pCooldownTime) void
Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).protected void
setItems
(NonNullList<ItemStack> pItems) static boolean
suckInItems
(Level pLevel, Hopper pHopper) private static ItemStack
tryMoveInItem
(Container pSource, Container pDestination, ItemStack pStack, int pSlot, Direction pDirection) private static boolean
tryMoveItems
(Level pLevel, BlockPos pPos, BlockState pState, HopperBlockEntity pBlockEntity, BooleanSupplier pValidator) private static boolean
tryTakeInItemFromSlot
(Hopper pHopper, Container pContainer, int pSlot, Direction pDirection) 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 pLevel, BlockPos pPos, BlockState pState, HopperBlockEntity pBlockEntity) -
tryMoveItems
private static boolean tryMoveItems(Level pLevel, BlockPos pPos, BlockState pState, HopperBlockEntity pBlockEntity, BooleanSupplier pValidator) -
inventoryFull
private boolean inventoryFull() -
ejectItems
-
getSlots
-
createFlatSlots
private static int[] createFlatSlots(int pSize) -
isFullContainer
- Returns:
false
if thecontainer
has any room to place items in
-
suckInItems
-
tryTakeInItemFromSlot
private static boolean tryTakeInItemFromSlot(Hopper pHopper, Container pContainer, int pSlot, Direction pDirection) 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 pSource, Container pDestination, ItemStack pStack, @Nullable Direction pDirection) 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 pLevel, BlockPos pPos, HopperBlockEntity pBlockEntity) -
getSourceContainer
@Nullable private static Container getSourceContainer(Level pLevel, Hopper pHopper, BlockPos pPos, BlockState pState) -
getItemsAtAndAbove
-
getContainerAt
-
getContainerAt
@Nullable private static Container getContainerAt(Level pLevel, BlockPos pPos, BlockState pState, double pX, double pY, double pZ) -
getBlockContainer
@Nullable private static Container getBlockContainer(Level pLevel, BlockPos pPos, BlockState pState) -
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 pCooldownTime) -
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 pLevel, BlockPos pPos, BlockState pState, Entity pEntity, HopperBlockEntity pBlockEntity) -
createMenu
- Specified by:
createMenu
in classBaseContainerBlockEntity
-
getLastUpdateTime
public long getLastUpdateTime()
-