RustTip

OnItemCraftCancelled

OxideCarbonItem

Called when an item craft is cancelled.

void OnItemCraftCancelled(ItemCraftTask local1, ItemCrafter itemCrafter)
Works — the game method in this build is the one the hook was written for.

Parameters

local1
ItemCraftTask
itemCrafter
ItemCrafter

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnItemCraftCancelled(ItemCraftTask local1, ItemCrafter itemCrafter)
{
    Puts("OnItemCraftCancelled");
}

Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.

Injection point

Rust.opj (Oxide)
bool ItemCrafter.CancelTask(int)

Passes: ItemCraftTask local1, ItemCrafter itemCrafter

WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l1,this)Assembly-CSharp.dll

Where it is called (this branch's game code)

// …
{
	return false;
}
itemCraftTask.cancelled = true;
if (owner == null)
{
	return true;
}
Interface.CallHook("OnItemCraftCancelled", itemCraftTask, this);
owner.Command("note.craft_done", itemCraftTask.taskUID, 0);
if (itemCraftTask.takenItems != null && itemCraftTask.takenItems.Count > 0)
{
	foreach (Item takenItem in itemCraftTask.takenItems)
	{
		if (takenItem != null && takenItem.amount > 0)
		{
			if (takenItem.IsBlueprint() && takenItem.blueprintTargetDef == itemCraftTask.blueprint.targetItem)
// …

Sources: Rust.opj from OxideMod/Oxide.Rust (MIT) and hook metadata of the Carbon documentation (MIT). Method code is decompiled from this branch's server.