Generates NullRefernceExceptions

seems to really kick off when the Bradley event starts.  (you may want to look into this or... you might not care) but... here is what I found:

BuriedItem.Create(Item item...)
NullReferenceException: Object reference not set to an instance of an object

The plugin directly edits ItemDefinition.stackable at runtime. Facepunch themselves warn that modifying definitions while entities exist can create invalid items.  This is a snippet from the .cs file:

itemDefinition.stackable = Mathf.Clamp(GetStackSize(...), 1, int.MaxValue);

If this happens when an item already exists in inventory or in-world, Rust may fail to resolve that item’s definition pointer during burial.

If this fails at any point, the plugin logs it but the item may already be invalid. Rust then tries to destroy that item later ---> volia:  NullReference in BuriedItem.Create. 

private int GetStackSize(ItemDefinition itemDefinition)
{
    try { ... }
    catch (Exception ex)
    {
        LogError("Exception encountered during GetStackSize. Item: " + itemDefinition.shortname + " Ex:" + ex.ToString());
        return GetVanillaStackSize(itemDefinition);
    }
}

I can and probably am wrong but I thought maybe a look into this.  I had to find: [Info("StackSizeMultiplier", "Fujikura....  from ages ago.  His methodology works.  Really miss that guy he was an incredible coder / modder.  All my NullRefferenceExceptions vanished after moving over to Fuji's version of stacking.  I translated the .json from StackSizeController over to SSM without any issues. I always JSON valid too.  

 

BuriedItem.Create NREs is an old bug from when they started allowing droped items to be found via metal detector. I think I see it mostly with cargoship, but it should not be releated to this plugin. Your server's logfile will show the full NRE and will be more helpful

firingLaserz

BuriedItem.Create NREs is an old bug from when they started allowing droped items to be found via metal detector. I think I see it mostly with cargoship, but it should not be releated to this plugin. Your server's logfile will show the full NRE and will be more helpful

The logs pointed to the stack controller. I even removed everything but this plugin before posting.   A few days later testing I think it might be something that was globally modified.  I've added basically this code:  (to black list certain known items that could cause issues).

 

 // Blacklist only items that definitely cause issues
            HashSet<string> blacklist = new HashSet<string>
            {
                // Water items with extreme max integer values
                "water",
                "water.salt",
                "water.radioactive"
            };

 I will update as needed.  We are probably the 1% that actually read forums lol.  I do appreciate your input.

Q7J5YGrJm3AamU2.jpg Gattaca

The logs pointed to the stack controller. I even removed everything but this plugin before posting.   A few days later testing I think it might be something that was globally modified.  I've added basically this code:  (to black list certain known items that could cause issues).

 

 // Blacklist only items that definitely cause issues
            HashSet<string> blacklist = new HashSet<string>
            {
                // Water items with extreme max integer values
                "water",
                "water.salt",
                "water.radioactive"
            };

 I will update as needed.  We are probably the 1% that actually read forums lol.  I do appreciate your input.

Hello, according to my assumptions, item.ownershipShares may sometimes be == null, which leads to this error. An error occurs when server trying to bury the item with a changed stacksize, such as weapon.mod.silencer.
For testing, I:
1) I changed the stacksize of weapon.mod.silencer via StackSizeController
2) through the DespawnConfig plugin, I changed the time of its disappearance so as not to wait a long time.
3) Made the chance of burying objects 100% ( burieditems.buryitemchance 1.0 )
4) Threw weapon.mod.silencer, no matter how much, to the ground and waited until the object tries to dig in, the object is not buried, and the error shown below occurs in the console.

 

NullReferenceException: Object reference not set to an instance of an object
at BuriedItem.Create (Item item, UnityEngine.Vector3 worldPosition, System.Int64 expiryTime) [0x000db] in <2349d3b01ac342c2b6545562216ac3e8>:0
at BuriedItems.Register (Item item, UnityEngine.Vector3 worldPosition) [0x0006d] in <2349d3b01ac342c2b6545562216ac3e8>:0
at DroppedItem.IdleDestroy () [0x00047] in <2349d3b01ac342c2b6545562216ac3e8>:0
at InvokeHandlerBase`1[T].DoTick () [0x00138] in <cddf7cb413194091a47148a30f3fc280>:0
at InvokeHandlerBase`1[T].LateUpdate () [0x0001f] in <cddf7cb413194091a47148a30f3fc280>:0
QYZliCdrNr9b1ry.jpg aimacak

Hello, according to my assumptions, item.ownershipShares may sometimes be == null, which leads to this error. An error occurs when server trying to bury the item with a changed stacksize, such as weapon.mod.silencer.
For testing, I:
1) I changed the stacksize of weapon.mod.silencer via StackSizeController
2) through the DespawnConfig plugin, I changed the time of its disappearance so as not to wait a long time.
3) Made the chance of burying objects 100% ( burieditems.buryitemchance 1.0 )
4) Threw weapon.mod.silencer, no matter how much, to the ground and waited until the object tries to dig in, the object is not buried, and the error shown below occurs in the console.

 

NullReferenceException: Object reference not set to an instance of an object
at BuriedItem.Create (Item item, UnityEngine.Vector3 worldPosition, System.Int64 expiryTime) [0x000db] in <2349d3b01ac342c2b6545562216ac3e8>:0
at BuriedItems.Register (Item item, UnityEngine.Vector3 worldPosition) [0x0006d] in <2349d3b01ac342c2b6545562216ac3e8>:0
at DroppedItem.IdleDestroy () [0x00047] in <2349d3b01ac342c2b6545562216ac3e8>:0
at InvokeHandlerBase`1[T].DoTick () [0x00138] in <cddf7cb413194091a47148a30f3fc280>:0
at InvokeHandlerBase`1[T].LateUpdate () [0x0001f] in <cddf7cb413194091a47148a30f3fc280>:0

100% I agree.  I am going to add in a despawn timer.  I already removed any stacking of certain objects that might cause this: weapons, etc that have maybe due to one of the stacked items having "damage" and maybe causing this error to trigger.

Thank you for sharing! I am going to do as you did