OnItemStacked
OxideItemvoid OnItemStacked(Item item, Item item, ItemContainer newcontainer, int int32)
void OnItemStacked(Item item, Item item, ItemContainer newcontainer)Method changed — check — the game method differs from the one the hook is recorded for in Oxide. The hook is still called, but its place may have shifted — worth checking after an update.
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
Method changed — checkReturnBehavior: 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
Method changed — checkReturnBehavior: ContinueArgumentBehavior: UseArgumentString (l23, this, a0)Assembly-CSharp.dll
Where it is called (this branch's game code)
// …
}
return false;
}
if (newcontainer.maxStackSize > 0 && newcontainer.maxStackSize < amount)
{
Item item2 = SplitItem(newcontainer.maxStackSize);
if (item2 != null && !item2.MoveToContainer(newcontainer, iTargetPos, allowStack: false, ignoreStackLimit: false, sourcePlayer) && (itemContainer == null || !item2.MoveToContainer(itemContainer, -1, allowStack: true, ignoreStackLimit: false, sourcePlayer)))
{
Interface.CallHook("OnItemStacked", item2, this, newcontainer);
DroppedItem droppedItem = item2.Drop(newcontainer.dropPosition, newcontainer.dropVelocity) as DroppedItem;
if (droppedItem != null)
{
droppedItem.DroppedBy = sourcePlayer?.userID ?? ((EncryptedValue<ulong>)0uL);
}
}
return true;
}
// …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.