Skip to content

ItemUseContext

Namespace Mc.Scripting.Content · Kind class (sealed)

public sealed class ItemUseContext

What a custom item’s use handler gets. Valid during the handler only.

Member Description
bool Cancelled { get; set; } Stops the vanilla behaviour of the base item and of the clicked block.
CustomItem Definition { get; } The definition of the item.
BlockFace Face { get; } The clicked face (only when ItemUseContext.HasBlock).
Hand Hand { get; } The hand holding the item.
bool HasBlock { get; } Whether the click was on a block.
ItemStack Item { get; } The stack that was used.
Player Player { get; } The player.
BlockPos Position { get; } The clicked block (only when ItemUseContext.HasBlock).
World World { get; } The dimension the player is in.
public bool Cancelled { get; set; }

Stops the vanilla behaviour of the base item and of the clicked block.

public CustomItem Definition { get; }

The definition of the item.

public BlockFace Face { get; }

The clicked face (only when ItemUseContext.HasBlock).

public Hand Hand { get; }

The hand holding the item.

public bool HasBlock { get; }

Whether the click was on a block.

public ItemStack Item { get; }

The stack that was used.

public Player Player { get; }

The player.

public BlockPos Position { get; }

The clicked block (only when ItemUseContext.HasBlock).

public World World { get; }

The dimension the player is in.

Member Description
void Consume(int count = 1) Uses up items of the stack that was used (nothing happens in creative mode).
public void Consume(int count = 1)

Uses up items of the stack that was used (nothing happens in creative mode).

Parameters

Name Type Description
count int = 1 How many.

BlockFace · BlockPos · CustomItem · Hand · ItemStack · Player · World