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

# scripting/scriptPlayerActions

## Interfaces

### ScriptPlayerActions

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L37)

What a level's scripts reach of its players' item use and block breaking.

#### Methods

##### events()

> **events**(`listener`): () => `void`

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:51](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L51)

Calls `listener` with each block a player of the level broke, each item one used and each
click on a block or an entity that did something.

###### Parameters

###### listener

(`event`) => `void`

###### Returns

A function that stops it.

() => `void`

##### guardBlockBreak()

> **guardBlockBreak**(`guard`): () => `void`

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:39](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L39)

###### Parameters

###### guard

[`VetoGuard`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#vetoguard)\<[`BlockBreakIntent`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#blockbreakintent)\>

###### Returns

A function that removes the guard.

() => `void`

##### guardBlockInteract()

> **guardBlockInteract**(`guard`): () => `void`

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:43](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L43)

###### Parameters

###### guard

[`VetoGuard`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#vetoguard)\<[`BlockInteractIntent`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#blockinteractintent)\>

###### Returns

A function that removes the guard.

() => `void`

##### guardEntityInteract()

> **guardEntityInteract**(`guard`): () => `void`

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:45](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L45)

###### Parameters

###### guard

[`VetoGuard`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#vetoguard)\<[`EntityInteractIntent`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#entityinteractintent)\>

###### Returns

A function that removes the guard.

() => `void`

##### guardItemUse()

> **guardItemUse**(`guard`): () => `void`

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:41](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L41)

###### Parameters

###### guard

[`VetoGuard`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#vetoguard)\<[`ItemUseIntent`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#itemuseintent)\>

###### Returns

A function that removes the guard.

() => `void`

## Type Aliases

### ScriptPlayerActionEvent

> **ScriptPlayerActionEvent** = `Extract`\<[`ScriptWorldEvent`](https://jsprismarine.dev/api/@jsprismarine/script-host/host/world/index.md#scriptworldevent), \{ `type`: `"playerBreakBlock"` \| `"itemUse"` \| `"playerInteractWithBlock"` \| `"playerInteractWithEntity"`; \}\>

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:31](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L31)

The after-events of a player's actions.

## Functions

### levelPlayerActions()

> **levelPlayerActions**(`server`, `level`): [`ScriptPlayerActions`](#scriptplayeractions)

Defined in: [packages/prismarine/src/scripting/scriptPlayerActions.ts:62](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/scripting/scriptPlayerActions.ts#L62)

Builds the player actions of one level's scripts.

#### Parameters

##### server

[`Server`](https://jsprismarine.dev/api/@jsprismarine/prismarine/Server/classes/Server.md)

The server whose events carry the actions.

##### level

[`Level`](https://jsprismarine.dev/api/@jsprismarine/prismarine/world/Level/classes/Level.md)

The level whose players the scripts see.

#### Returns

[`ScriptPlayerActions`](#scriptplayeractions)
