Перейти до вмісту

Interactions

Цей контент ще не доступний вашою мовою.

A mod has a say before the game lets a player interact with an entity. load.on_interaction runs a filter with an Interaction: what the player does (kind), the player, the target, and the item the target was placed from and where it stands, when the platform could read them. Returning false refuses it.

use enshwick::interactions::Kind;
fn init(load: &mut enshwick::Load<'_>) -> Result<(), enshwick::Off> {
const LOCKED_CHEST: enshwick::ItemId = enshwick::ItemId::new(0x5e01);
load.on_interaction(|i| !(i.item == Some(LOCKED_CHEST) && matches!(i.kind, Kind::Open | Kind::Move | Kind::Sort)))
}
KindWhen it is askedWhat a refusal does
OpenThe game is about to offer the Open promptNo prompt
MoveItems move out of or into the target, or one of its slotsThe move is undone on the client
SortThe target’s inventory is sortedNothing is sorted
StockThe target lends its stock to crafting or building nearbyIt is left out of the stock
DismantleThe cursor offers to pick up or tear down the targetNo pick-up or tear-down
QuickStashThe player flips the target’s Quick Stash switchThe switch stays
UpgradeThe player upgrades the target into another pieceNothing is upgraded

Each refusal takes the game’s own path for a refused action, so nothing moves and nothing is lost. Stock is asked without the target’s item or position: answer it from what the mod has already seen of the target.

An interaction without a player’s character or without a target is allowed without asking. The filters run in the server’s world only, in the dedicated server or a hosting client, on the thread of the system that checks the interaction: keep them quick and never block. Several mods may filter; any refusal wins.