RustTip

OnItemCraftFinished

OxideCarbonItem

Called when an item craft finishes.

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

Parameters

task
ItemCraftTask
local1
Item
itemCrafter
ItemCrafter

Return value

voidThe return value is ignored — the hook only notifies.

Example

private void OnItemCraftFinished(ItemCraftTask task, Item local1, ItemCrafter itemCrafter)
{
    Puts("OnItemCraftFinished");
}

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

Injection point

Rust.opj (Oxide)
void ItemCrafter.FinishCrafting(ItemCraftTask)

Passes: ItemCraftTask task, Item local1, ItemCrafter itemCrafter

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

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

// …
		{
			break;
		}
	}
}
task.takenItems?.RemoveAll((Item item2) => item2.amount == 0);
Analytics.Azure.OnCraftItem(item.info.shortname, item.amount, baseEntity, task.workbenchEntity, inSafezone, item.skin);
owner.Command("note.craft_done", task.taskUID, 1, task.amount);
Interface.CallHook("OnItemCraftFinished", task, item, this);
if (task.instanceData != null)
{
	item.instanceData = task.instanceData;
}
if (!string.IsNullOrEmpty(task.blueprint.UnlockAchievment))
{
	owner.GiveAchievement(task.blueprint.UnlockAchievment);
}
// …

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.