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 container, ItemEntity item) private static booleancanMergeItems(ItemStack stack1, ItemStack stack2) private static booleancanPlaceItemInContainer(Container container, ItemStack stack, int slot, Direction direction) private static booleancanTakeItemFromContainer(Container source, Container destination, ItemStack stack, int slot, Direction direction) private static int[]createFlatSlots(int size) protected AbstractContainerMenucreateMenu(int id, Inventory player) private static booleanejectItems(Level level, BlockPos pos, HopperBlockEntity blockEntity) static voidentityInside(Level level, BlockPos pos, BlockState state, Entity entity, HopperBlockEntity blockEntity) private static ContainergetAttachedContainer(Level level, BlockPos pos, HopperBlockEntity blockEntity) private static ContainergetBlockContainer(Level level, BlockPos pos, BlockState state) static ContainergetContainerAt(Level level, BlockPos pos) private static ContainergetContainerAt(Level level, BlockPos pos, BlockState state, double x, double y, double z) intprotected Componentprivate static 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 ContainergetSourceContainer(Level level, Hopper hopper, BlockPos pos, BlockState state) private booleanprivate static booleanisFullContainer(Container container, Direction direction) booleanprivate booleanbooleanprotected voidloadAdditional(CompoundTag tag, HolderLookup.Provider registries) static voidpushItemsTick(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 voidsaveAdditional(CompoundTag tag, HolderLookup.Provider registries) voidsetBlockState(BlockState blockState) voidsetCooldown(int cooldownTime) 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(Container source, Container destination, ItemStack stack, int slot, Direction direction) private static booleantryMoveItems(Level level, BlockPos pos, BlockState state, HopperBlockEntity blockEntity, BooleanSupplier validator) 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.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, 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, setDataMethods 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 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:
falseif thecontainerhas 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:
trueif 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:
isGridAlignedin interfaceHopper
-
setCooldown
public void setCooldown(int cooldownTime) -
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 state, Entity entity, HopperBlockEntity blockEntity) -
createMenu
- Specified by:
createMenuin classBaseContainerBlockEntity
-
getLastUpdateTime
public long getLastUpdateTime()
-