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.DataComponentInputNested classes/interfaces inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
AttachmentHolder.AsField -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final int[][]private intprivate Directionstatic final intprivate NonNullList<ItemStack> static final intprivate longFields inherited from class net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity
lootTable, lootTableSeedFields inherited from class net.minecraft.world.level.block.entity.BlockEntity
level, remove, worldPositionFields inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
ATTACHMENTS_NBT_KEYFields inherited from interface net.minecraft.world.Container
DEFAULT_DISTANCE_BUFFERFields inherited from interface net.minecraft.world.RandomizableContainer
LOOT_TABLE_SEED_TAG, LOOT_TABLE_TAG -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemStackAttempts to place the passed stack in the container, using as many slots as required.static booleanaddItem(Container pContainer, ItemEntity pItem) private static booleancanMergeItems(ItemStack pStack1, ItemStack pStack2) private static booleancanPlaceItemInContainer(Container pContainer, ItemStack pStack, int pSlot, Direction pDirection) private static booleancanTakeItemFromContainer(Container pSource, Container pDestination, ItemStack pStack, int pSlot, Direction pDirection) private static int[]createFlatSlots(int pSize) protected AbstractContainerMenucreateMenu(int pId, Inventory pPlayer) private static booleanejectItems(Level pLevel, BlockPos pPos, HopperBlockEntity pBlockEntity) static voidentityInside(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity, HopperBlockEntity pBlockEntity) private static ContainergetAttachedContainer(Level pLevel, BlockPos pPos, HopperBlockEntity pBlockEntity) private static ContainergetBlockContainer(Level pLevel, BlockPos pPos, BlockState pState) static ContainergetContainerAt(Level pLevel, BlockPos pPos) private static ContainergetContainerAt(Level pLevel, BlockPos pPos, BlockState pState, double pX, double pY, double pZ) intprotected Componentprivate static ContainergetEntityContainer(Level pLevel, double pX, double pY, double pZ) protected NonNullList<ItemStack> getItems()static List<ItemEntity> getItemsAtAndAbove(Level pLevel, Hopper pHopper) longdoubledoubledoubleprivate static int[]private static ContainergetSourceContainer(Level pLevel, Hopper pHopper, BlockPos pPos, BlockState pState) private booleanprivate static booleanisFullContainer(Container pContainer, Direction pDirection) booleanprivate booleanbooleanprotected voidloadAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) static voidpushItemsTick(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 voidsaveAdditional(CompoundTag pTag, HolderLookup.Provider pRegistries) voidsetBlockState(BlockState pBlockState) voidsetCooldown(int pCooldownTime) voidSets the given item stack to the specified slot in the inventory (can be crafting or armor sections).protected voidsetItems(NonNullList<ItemStack> pItems) static booleansuckInItems(Level pLevel, Hopper pHopper) private static ItemStacktryMoveInItem(Container pSource, Container pDestination, ItemStack pStack, int pSlot, Direction pDirection) private static booleantryMoveItems(Level pLevel, BlockPos pPos, BlockState pState, HopperBlockEntity pBlockEntity, BooleanSupplier pValidator) private static booleantryTakeInItemFromSlot(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, setLootTableSeedMethods inherited from class net.minecraft.world.level.block.entity.BaseContainerBlockEntity
canUnlock, clearContent, getCustomName, getDisplayName, getName, stillValidMethods 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, syncData, triggerEventMethods inherited from class net.neoforged.neoforge.attachment.AttachmentHolder
deserializeAttachments, getData, getExistingDataOrNull, hasAttachments, hasData, serializeAttachmentsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.world.Clearable
clearContentMethods inherited from interface net.minecraft.world.Container
canPlaceItem, canTakeItem, countItem, getItem, getMaxStackSize, getMaxStackSize, hasAnyMatching, hasAnyOf, isEmpty, removeItemNoUpdate, setChanged, startOpen, stillValid, stopOpenMethods inherited from interface net.minecraft.world.level.block.entity.Hopper
getSuckAabbMethods inherited from interface net.neoforged.neoforge.attachment.IAttachmentHolder
getData, getExistingData, getExistingData, getExistingDataOrNull, hasData, removeData, setData, syncDataMethods inherited from interface net.neoforged.neoforge.common.extensions.IBlockEntityExtension
getModelData, handleUpdateTag, hasCustomOutlineRendering, invalidateCapabilities, onChunkUnloaded, onDataPacket, onLoad, requestModelDataUpdateMethods inherited from interface net.neoforged.neoforge.client.extensions.IMenuProviderExtension
shouldTriggerClientSideContainerClosingOnOpen, writeClientSideDataMethods inherited from interface net.minecraft.world.Nameable
hasCustomNameMethods 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:
loadAdditionalin classBaseContainerBlockEntity
-
saveAdditional
- Overrides:
saveAdditionalin classBaseContainerBlockEntity
-
getContainerSize
public int getContainerSize()- Specified by:
getContainerSizein interfaceContainer
-
removeItem
Description copied from class:RandomizableContainerBlockEntityRemoves 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 class:RandomizableContainerBlockEntitySets the given item stack to the specified slot in the inventory (can be crafting or armor sections).- Specified by:
setItemin interfaceContainer- Overrides:
setItemin classRandomizableContainerBlockEntity
-
setBlockState
- Overrides:
setBlockStatein classBlockEntity
-
getDefaultName
- Specified by:
getDefaultNamein 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:
falseif thecontainerhas 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:
trueif 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:
isGridAlignedin interfaceHopper
-
setCooldown
public void setCooldown(int pCooldownTime) -
isOnCooldown
private boolean isOnCooldown() -
isOnCustomCooldown
public boolean isOnCustomCooldown() -
getItems
- Specified by:
getItemsin classBaseContainerBlockEntity
-
setItems
- Specified by:
setItemsin classBaseContainerBlockEntity
-
entityInside
public static void entityInside(Level pLevel, BlockPos pPos, BlockState pState, Entity pEntity, HopperBlockEntity pBlockEntity) -
createMenu
- Specified by:
createMenuin classBaseContainerBlockEntity
-
getLastUpdateTime
public long getLastUpdateTime()
-