[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / world/hopper

# world/hopper

## Interfaces

### HopperBlock

Defined in: [packages/prismarine/src/world/hopper.ts:139](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L139)

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

#### Properties

##### container

> `readonly` **container**: [`HopperContainer`](#hoppercontainer) & `object`

Defined in: [packages/prismarine/src/world/hopper.ts:146](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L146)

Its five slots and its timers.

###### Type Declaration

###### clock

> `readonly` **clock**: [`HopperClock`](#hopperclock)

##### enabled

> `readonly` **enabled**: `boolean`

Defined in: [packages/prismarine/src/world/hopper.ts:144](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L144)

Java's `enabled`, which redstone power clears.

##### facing

> `readonly` **facing**: [`HopperFace`](#hopperface)

Defined in: [packages/prismarine/src/world/hopper.ts:142](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L142)

Java's `facing`, which is never `up`.

##### position

> `readonly` **position**: [`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

Defined in: [packages/prismarine/src/world/hopper.ts:140](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L140)

***

### HopperClock

Defined in: [packages/prismarine/src/world/hopper.ts:69](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L69)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L71)

Java's `cooldownTime`.

##### tickedGameTime

> **tickedGameTime**: `number`

Defined in: [packages/prismarine/src/world/hopper.ts:73](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L73)

Java's `tickedGameTime`.

***

### HopperContainer

Defined in: [packages/prismarine/src/world/hopper.ts:80](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L80)

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`](#hopperclock)

Defined in: [packages/prismarine/src/world/hopper.ts:100](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L100)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L82)

How many slots it has.

#### Methods

##### canPlaceItem()

> **canPlaceItem**(`slot`, `item`, `face`): `boolean`

Defined in: [packages/prismarine/src/world/hopper.ts:96](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L96)

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`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)

###### face

[`HopperFace`](#hopperface) \| `undefined`

###### Returns

`boolean`

##### canTakeItem()

> **canTakeItem**(`slot`, `item`, `face`): `boolean`

Defined in: [packages/prismarine/src/world/hopper.ts:98](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L98)

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

###### Parameters

###### slot

`number`

###### item

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)

###### face

[`HopperFace`](#hopperface)

###### Returns

`boolean`

##### item()

> **item**(`slot`): [`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

Defined in: [packages/prismarine/src/world/hopper.ts:84](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L84)

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

###### Parameters

###### slot

`number`

###### Returns

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

##### setItem()

> **setItem**(`slot`, `item`): `void`

Defined in: [packages/prismarine/src/world/hopper.ts:86](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L86)

Puts a stack in a slot, or empties it.

###### Parameters

###### slot

`number`

###### item

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

###### Returns

`void`

##### slotsForFace()

> **slotsForFace**(`face`): readonly `number`[]

Defined in: [packages/prismarine/src/world/hopper.ts:91](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L91)

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

###### Parameters

###### face

[`HopperFace`](#hopperface)

###### Returns

readonly `number`[]

***

### HopperItemEntity

Defined in: [packages/prismarine/src/world/hopper.ts:104](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L104)

A dropped stack a hopper can take.

#### Properties

##### id

> `readonly` **id**: `number`

Defined in: [packages/prismarine/src/world/hopper.ts:105](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L105)

##### item

> `readonly` **item**: [`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)

Defined in: [packages/prismarine/src/world/hopper.ts:106](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L106)

***

### HopperWorld

Defined in: [packages/prismarine/src/world/hopper.ts:110](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L110)

What a hopper asks about the world around it.

#### Properties

##### gameTime

> `readonly` **gameTime**: `number`

Defined in: [packages/prismarine/src/world/hopper.ts:116](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L116)

The game tick now.

###### Java See

LevelAccessor.getGameTime

#### Methods

##### blocksPickup()

> **blocksPickup**(`at`): `boolean`

Defined in: [packages/prismarine/src/world/hopper.ts:128](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L128)

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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### Returns

`boolean`

##### containerAt()

> **containerAt**(`at`): [`HopperContainer`](#hoppercontainer) \| `undefined`

Defined in: [packages/prismarine/src/world/hopper.ts:123](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L123)

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`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### Returns

[`HopperContainer`](#hoppercontainer) \| `undefined`

##### itemsAbove()

> **itemsAbove**(`hopper`): readonly [`HopperItemEntity`](#hopperitementity)[]

Defined in: [packages/prismarine/src/world/hopper.ts:130](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L130)

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

###### Parameters

###### hopper

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

###### Returns

readonly [`HopperItemEntity`](#hopperitementity)[]

##### maxStackOf()

> **maxStackOf**(`item`): `number`

Defined in: [packages/prismarine/src/world/hopper.ts:118](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L118)

The most of one item a stack holds.

###### Parameters

###### item

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)

###### Returns

`number`

##### takeItem()

> **takeItem**(`id`, `count`): [`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

Defined in: [packages/prismarine/src/world/hopper.ts:135](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L135)

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

###### Parameters

###### id

`number`

###### count

`number`

###### Returns

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L32)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L26)

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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L29)

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

## Functions

### addItem()

> **addItem**(`world`, `from`, `to`, `stack`, `face`): [`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop) \| `undefined`

Defined in: [packages/prismarine/src/world/hopper.ts:238](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L238)

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`](#hopperworld)

##### from

[`HopperContainer`](#hoppercontainer) \| `undefined`

##### to

[`HopperContainer`](#hoppercontainer)

##### stack

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#itemdrop)

##### face

[`HopperFace`](#hopperface) \| `undefined`

#### Returns

[`ItemDrop`](https://jsprismarine.dev/api/@jsprismarine/block-behaviors/index.md#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L329)

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

#### Parameters

##### world

[`HopperWorld`](#hopperworld)

##### hopper

[`HopperBlock`](#hopperblock)

#### Returns

`boolean`

#### Java Source

HopperBlockEntity.ejectItems

***

### offsetTo()

> **offsetTo**(`at`, `face`): [`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

Defined in: [packages/prismarine/src/world/hopper.ts:53](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L53)

The block one step from a position in a direction.

#### Parameters

##### at

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

##### face

[`HopperFace`](#hopperface)

#### Returns

[`ContentPosition`](https://jsprismarine.dev/api/@jsprismarine/prismarine/content/world/adapter/index.md#contentposition)

***

### oppositeOf()

> **oppositeOf**(`face`): [`HopperFace`](#hopperface)

Defined in: [packages/prismarine/src/world/hopper.ts:63](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L63)

The opposite direction.

#### Parameters

##### face

[`HopperFace`](#hopperface)

#### Returns

[`HopperFace`](#hopperface)

#### Java Source

Direction.getOpposite

***

### pushItemsTick()

> **pushItemsTick**(`world`, `hopper`): `boolean`

Defined in: [packages/prismarine/src/world/hopper.ts:371](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L371)

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

#### Parameters

##### world

[`HopperWorld`](#hopperworld)

##### hopper

[`HopperBlock`](#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](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/world/hopper.ts#L308)

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`](#hopperworld)

##### hopper

[`HopperBlock`](#hopperblock)

#### Returns

`boolean`

#### Java Source

HopperBlockEntity.suckInItems
