I’ve created a custom item in my plugin.
It’s based on a normal rf.detonator, but it has an attached ItemContainer so players can insert “drives” into it (basically small access key items).
The item works fine while it’s in a player’s inventory, but if a player drags it off their hotbar/inventory to drop it, the server immediately throws a NullReferenceException and crashes.
Here’s what I’ve observed:
The crash happens even if I try to handle it in
CanDropItem,CanMoveItem,OnDropItem, orOnItemRemovedFromContainer.None of those hooks are triggered before the crash — it seems the problem occurs inside Rust’s internal
DroppedItemcreation logic.It only happens when the custom
ItemContaineron the item has contents (the “drives”).Empty communicators can be dropped without issue.
Setting
ItemDefinition.Flag.NoDroppingordef.flags |= ...makes it undroppable in theory, but doesn’t help if the player is already holding an instance and tries to drag/drop it — still crashes.
Question:
Has anyone run into this before? Is there a way to completely prevent Rust from trying to spawn a dropped entity for an item, or to intercept the drag/drop action earlier than the existing item hooks?
I’m fine with blocking dropping entirely if there’s a reliable way to do it that works before DroppedItem spawns.