OnItemStacked
OxideItemvoid OnItemStacked(Item item, Item item, ItemContainer newcontainer, int int32)
void OnItemStacked(Item item, Item item, ItemContainer newcontainer)Works — the game method in this build is the one the hook was written for.
Parameters
- item
- Item
- item
- Item
- newcontainer
- ItemContainer
- int32
- int
Return value
voidThe return value is ignored — the hook only notifies.
Example
private void OnItemStacked(Item item, Item item, ItemContainer newcontainer, int int32)
{
Puts("OnItemStacked");
}Works in both Oxide and Carbon: Carbon loads Oxide plugins as is.
Injection point 1
Rust.opj (Oxide)
bool Item.MoveToContainer(ItemContainer, int, bool, bool, BasePlayer, bool)
Passes: Item item, Item item, ItemContainer newcontainer, int int32
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l13, this, a0, l15)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
if (slot2.instanceData != null && instanceData != null && (bool)info.GetComponent<ItemModFoodSpoiling>())
{
slot2.instanceData.dataFloat = Mathf.Min(slot2.instanceData.dataFloat, instanceData.dataFloat);
slot2.instanceData.refrigeratedSeconds = Mathf.Min(slot2.instanceData.refrigeratedSeconds, instanceData.refrigeratedSeconds);
}
newcontainer.onItemAddedToStack?.Invoke(slot2, num2, sourcePlayer);
amount -= num2;
slot2.MarkDirty();
Interface.CallHook("OnItemStacked", slot2, this, newcontainer, num2);
MarkDirty();
MigrateItemOwnership(slot2, num2);
if (amount <= 0)
{
RemoveFromWorld();
RemoveFromContainer(sourcePlayer);
Remove();
return true;
// …Injection point 2
Rust.opj (Oxide)
bool Item.MoveToContainer(ItemContainer, int, bool, bool, BasePlayer, bool)
Passes: Item item, Item item, ItemContainer newcontainer
WorksReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l23, this, a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
{
droppedItem.DroppedBy = sourcePlayer?.userID ?? ((EncryptedValue<ulong>)0uL);
}
}
return true;
}
if (!newcontainer.CanAccept(this))
{
Interface.CallHook("OnItemStacked", item2, this, newcontainer);
return false;
}
BaseEntity entityOwner3 = GetEntityOwner();
RemoveFromContainer(sourcePlayer);
RemoveFromWorld();
RemoveConflictingSlots(newcontainer, entityOwner3, sourcePlayer);
position = iTargetPos;
SetParent(newcontainer, sourcePlayer);
// …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.