Skip to content

API reference / @jsprismarine/prismarine / world/hopper

world/hopper ​

Interfaces ​

HopperBlock ​

Defined in: packages/prismarine/src/world/hopper.ts:139

A hopper block, as its block state and block entity describe it.

Properties ​

container ​

readonly container: HopperContainer & object

Defined in: packages/prismarine/src/world/hopper.ts:146

Its five slots and its timers.

Type Declaration ​
clock ​

readonly clock: HopperClock

enabled ​

readonly enabled: boolean

Defined in: packages/prismarine/src/world/hopper.ts:144

Java's enabled, which redstone power clears.

facing ​

readonly facing: HopperFace

Defined in: packages/prismarine/src/world/hopper.ts:142

Java's facing, which is never up.

position ​

readonly position: ContentPosition

Defined in: packages/prismarine/src/world/hopper.ts:140


HopperClock ​

Defined in: packages/prismarine/src/world/hopper.ts:69

A hopper's timers, which Java keeps on the block entity: the cooldown it counts down, and the game tick it last ran, which a hopper passing an item to another reads.

Properties ​

cooldown ​

cooldown: number

Defined in: packages/prismarine/src/world/hopper.ts:71

Java's cooldownTime.

tickedGameTime ​

tickedGameTime: number

Defined in: packages/prismarine/src/world/hopper.ts:73

Java's tickedGameTime.


HopperContainer ​

Defined in: packages/prismarine/src/world/hopper.ts:80

A container a hopper reads from or writes into, Java's Container, with what WorldlyContainer adds for a container whose faces lead to different slots.

Properties ​

clock? ​

readonly optional clock?: HopperClock

Defined in: packages/prismarine/src/world/hopper.ts:100

The timers of a container that is a hopper, which an item moving into it can set.

size ​

readonly size: number

Defined in: packages/prismarine/src/world/hopper.ts:82

How many slots it has.

Methods ​

canPlaceItem() ​

canPlaceItem(slot, item, face): boolean

Defined in: packages/prismarine/src/world/hopper.ts:96

Whether a stack may go into a slot through a face, Java's canPlaceItem and, for a worldly container given a face, canPlaceItemThroughFace.

Parameters ​
slot ​

number

item ​

ItemDrop

face ​

HopperFace | undefined

Returns ​

boolean

canTakeItem() ​

canTakeItem(slot, item, face): boolean

Defined in: packages/prismarine/src/world/hopper.ts:98

Whether a stack may leave a slot through a face, Java's canTakeItemThroughFace.

Parameters ​
slot ​

number

item ​

ItemDrop

face ​

HopperFace

Returns ​

boolean

item() ​

item(slot): ItemDrop | undefined

Defined in: packages/prismarine/src/world/hopper.ts:84

The stack in a slot, or undefined for an empty one.

Parameters ​
slot ​

number

Returns ​

ItemDrop | undefined

setItem() ​

setItem(slot, item): void

Defined in: packages/prismarine/src/world/hopper.ts:86

Puts a stack in a slot, or empties it.

Parameters ​
slot ​

number

item ​

ItemDrop | undefined

Returns ​

void

slotsForFace() ​

slotsForFace(face): readonly number[]

Defined in: packages/prismarine/src/world/hopper.ts:91

The slots a face leads to, in order, Java's getSlotsForFace; every slot for a container that is not worldly.

Parameters ​
face ​

HopperFace

Returns ​

readonly number[]


HopperItemEntity ​

Defined in: packages/prismarine/src/world/hopper.ts:104

A dropped stack a hopper can take.

Properties ​

id ​

readonly id: number

Defined in: packages/prismarine/src/world/hopper.ts:105

item ​

readonly item: ItemDrop

Defined in: packages/prismarine/src/world/hopper.ts:106


HopperWorld ​

Defined in: packages/prismarine/src/world/hopper.ts:110

What a hopper asks about the world around it.

Properties ​

gameTime ​

readonly gameTime: number

Defined in: packages/prismarine/src/world/hopper.ts:116

The game tick now.

Java See ​

LevelAccessor.getGameTime

Methods ​

blocksPickup() ​

blocksPickup(at): boolean

Defined in: packages/prismarine/src/world/hopper.ts:128

Whether the block at a position keeps items from the hopper under it: a block whose collision shape fills it, unless it is in #minecraft:does_not_block_hoppers.

Parameters ​
at ​

ContentPosition

Returns ​

boolean

containerAt() ​

containerAt(at): HopperContainer | undefined

Defined in: packages/prismarine/src/world/hopper.ts:123

The container in a block, or undefined for a block that is none, Java's getContainerAt reading the block alone. Both halves of a double chest are one container.

Parameters ​
at ​

ContentPosition

Returns ​

HopperContainer | undefined

itemsAbove() ​

itemsAbove(hopper): readonly HopperItemEntity[]

Defined in: packages/prismarine/src/world/hopper.ts:130

The dropped stacks in the hopper's suck box, in the order Java lists them.

Parameters ​
hopper ​

ContentPosition

Returns ​

readonly HopperItemEntity[]

maxStackOf() ​

maxStackOf(item): number

Defined in: packages/prismarine/src/world/hopper.ts:118

The most of one item a stack holds.

Parameters ​
item ​

ItemDrop

Returns ​

number

takeItem() ​

takeItem(id, count): ItemDrop | undefined

Defined in: packages/prismarine/src/world/hopper.ts:135

Takes up to count items from a dropped stack, removing the entity when none are left.

Parameters ​
id ​

number

count ​

number

Returns ​

ItemDrop | undefined

What was taken, or undefined when the entity is gone.

Type Aliases ​

HopperFace ​

HopperFace = "down" | "up" | "north" | "south" | "west" | "east"

Defined in: packages/prismarine/src/world/hopper.ts:32

One of the six directions, as Java's Direction names them.

Variables ​

MOVE_ITEM_SPEED ​

const MOVE_ITEM_SPEED: 8 = 8

Defined in: packages/prismarine/src/world/hopper.ts:26

How many game ticks a hopper waits after it moved an item.

Java Source ​

HopperBlockEntity.MOVE_ITEM_SPEED


NO_COOLDOWN_TIME ​

const NO_COOLDOWN_TIME: -1 = -1

Defined in: packages/prismarine/src/world/hopper.ts:29

A hopper's cooldown before it has ever moved anything, Java's NO_COOLDOWN_TIME.

Functions ​

addItem() ​

addItem(world, from, to, stack, face): ItemDrop | undefined

Defined in: packages/prismarine/src/world/hopper.ts:238

Puts a stack into a container, slot by slot: the slots the face leads to when there is a face, every slot otherwise.

Parameters ​

world ​

HopperWorld

from ​

HopperContainer | undefined

to ​

HopperContainer

stack ​

ItemDrop

face ​

HopperFace | undefined

Returns ​

ItemDrop | undefined

What did not fit, or undefined when all of it went in.

Java Source ​

HopperBlockEntity.addItem(Lnet/minecraft/world/Container;Lnet/minecraft/world/Container;Lnet/minecraft/world/item/ItemStack;Lnet/minecraft/core/Direction;)Lnet/minecraft/world/item/ItemStack;


ejectItems() ​

ejectItems(world, hopper): boolean

Defined in: packages/prismarine/src/world/hopper.ts:329

Pushes one item, from the first slot whose item fits, into the container the hopper faces.

Parameters ​

world ​

HopperWorld

hopper ​

HopperBlock

Returns ​

boolean

Java Source ​

HopperBlockEntity.ejectItems


offsetTo() ​

offsetTo(at, face): ContentPosition

Defined in: packages/prismarine/src/world/hopper.ts:53

The block one step from a position in a direction.

Parameters ​

at ​

ContentPosition

face ​

HopperFace

Returns ​

ContentPosition


oppositeOf() ​

oppositeOf(face): HopperFace

Defined in: packages/prismarine/src/world/hopper.ts:63

The opposite direction.

Parameters ​

face ​

HopperFace

Returns ​

HopperFace

Java Source ​

Direction.getOpposite


pushItemsTick() ​

pushItemsTick(world, hopper): boolean

Defined in: packages/prismarine/src/world/hopper.ts:371

One game tick of a hopper: the cooldown counts down, and a hopper off it tries to move.

Parameters ​

world ​

HopperWorld

hopper ​

HopperBlock

Returns ​

boolean

Whether it moved an item.

Java Source ​

HopperBlockEntity.pushItemsTick


suckInItems() ​

suckInItems(world, hopper): boolean

Defined in: packages/prismarine/src/world/hopper.ts:308

Pulls one item from the container above, or else takes a dropped stack lying in the suck box when the block above lets items through.

Parameters ​

world ​

HopperWorld

hopper ​

HopperBlock

Returns ​

boolean

Java Source ​

HopperBlockEntity.suckInItems