MSchmoecker / No-Chest-Block

Allows multiple players to interact with the same chest at the same time
MIT License
3 stars 0 forks source link

Suddenly can't pick up items #5

Closed mevolu closed 1 year ago

mevolu commented 1 year ago

I use MUC (version 0.4.2) together with the Mod Quick Stack Store Sort Trash Restock by Goldenrevolver (version 1.3.4) . I'm playing on a server (MUC is also installed there). I use the quick stack hotkey and the items in my inventory get stored in the chests near by. After that i destroy something like a pile of wood and suddenly i can't pick up items anymore. They just hovering at my chars feet. I can't pick them up with E. I have to log out and in again to make it work again. The problem not always happen. Can't make out any consistency on that.

When this Problem occurs i got the following red Errors in the BepInEx Log Window:

[Error  : Unity Log] NullReferenceException: Object reference not set to an instance of an object
Stack trace:
MultiUserChest.InventoryHandler.GetInventory (ZDOID targetId, System.Int32 hash) (at D:/Projects/No-Chest-Block/MultiUserChest/InventoryHandler.cs:190)
MultiUserChest.InventoryHandler+<>c.<RPC_RequestItemAddResponse>b__0_0 (MultiUserChest.RequestChestAddResponse p) (at D:/Projects/No-Chest-Block/MultiUserChest/InventoryHandler.cs:9)
MultiUserChest.InventoryHandler+<>c__DisplayClass7_0`1[T].<HandleRPC>b__0 () (at D:/Projects/No-Chest-Block/MultiUserChest/InventoryHandler.cs:42)
MultiUserChest.InventoryHandler.CallRPC (System.String timerName, MultiUserChest.IPackage package, System.Action action) (at D:/Projects/No-Chest-Block/MultiUserChest/InventoryHandler.cs:55)
MultiUserChest.InventoryHandler.HandleRPC[T] (T package, System.Func`2[T,TResult] inventory, System.Action`2[T1,T2] handle) (at D:/Projects/No-Chest-Block/MultiUserChest/InventoryHandler.cs:42)
MultiUserChest.InventoryHandler.RPC_RequestItemAddResponse (System.Int64 sender, ZPackage package) (at D:/Projects/No-Chest-Block/MultiUserChest/InventoryHandler.cs:9)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Delegate.DynamicInvokeImpl (System.Object[] args) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Delegate.DynamicInvoke (System.Object[] args) (at <695d1cc93cca45069c528c15c9fdd749>:0)
RoutedMethod`1[T].Invoke (System.Int64 rpc, ZPackage pkg) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZNetView.HandleRoutedRPC (ZRoutedRpc+RoutedRPCData rpcData) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZRoutedRpc.HandleRoutedRPC (ZRoutedRpc+RoutedRPCData data) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZRoutedRpc.InvokeRoutedRPC (System.Int64 targetPeerID, ZDOID targetZDO, System.String methodName, System.Object[] parameters) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZNetView.InvokeRPC (System.Int64 targetID, System.String method, System.Object[] parameters) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
MultiUserChest.ContainerRPCHandler.HandleRPC[TResponse,TInput] (Container container, System.Int64 target, System.String rpcInvoke, System.Func`3[T1,T2,TResult] message, System.Func`1[TResult] input) (at D:/Projects/No-Chest-Block/MultiUserChest/ContainerRPCHandler.cs:38)
MultiUserChest.ContainerRPCHandler.RPC_RequestItemAdd (Container container, System.Int64 sender, ZPackage package) (at D:/Projects/No-Chest-Block/MultiUserChest/ContainerRPCHandler.cs:9)
MultiUserChest.Patches.ContainerPatch+<>c__DisplayClass13_0.<RegisterRPCs>b__1 (System.Int64 l, ZPackage package) (at D:/Projects/No-Chest-Block/MultiUserChest/Patches/ContainerPatch.cs:41)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Delegate.DynamicInvokeImpl (System.Object[] args) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.MulticastDelegate.DynamicInvokeImpl (System.Object[] args) (at <695d1cc93cca45069c528c15c9fdd749>:0)
System.Delegate.DynamicInvoke (System.Object[] args) (at <695d1cc93cca45069c528c15c9fdd749>:0)
RoutedMethod`1[T].Invoke (System.Int64 rpc, ZPackage pkg) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZNetView.HandleRoutedRPC (ZRoutedRpc+RoutedRPCData rpcData) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZRoutedRpc.HandleRoutedRPC (ZRoutedRpc+RoutedRPCData data) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZRoutedRpc.InvokeRoutedRPC (System.Int64 targetPeerID, ZDOID targetZDO, System.String methodName, System.Object[] parameters) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
ZNetView.InvokeRPC (System.String method, System.Object[] parameters) (at <0a1a436be26b421bb46752e573a7aa2f>:0)
MultiUserChest.ContainerHandler.AddItemToChest (Container container, ItemDrop+ItemData item, Inventory targetInventory, Vector2i to, ZDOID sender, System.Int32 dragAmount) (at D:/Projects/No-Chest-Block/MultiUserChest/ContainerHandler.cs:50)
MultiUserChest.Patches.InventoryPatch.InterceptAddItem (Inventory inventory, ItemDrop+ItemData item, System.Int32 amount, Vector2i pos, System.Boolean& successfulAdded) (at D:/Projects/No-Chest-Block/MultiUserChest/Patches/InventoryPatch.cs:108)
MultiUserChest.Patches.InventoryPatch.AddItem2Prefix (Inventory __instance, System.Boolean& __runOriginal, ItemDrop+ItemData item, System.Boolean& __result) (at D:/Projects/No-Chest-Block/MultiUserChest/Patches/InventoryPatch.cs:37)
(wrapper dynamic-method) Inventory.DMD<Inventory::AddItem>(Inventory,ItemDrop/ItemData)
QuickStackStore.QuickStackModule.QuickStackIntoThisContainer (System.Collections.Generic.List`1[T] trophies, System.Collections.Generic.List`1[T] nonTrophies, Inventory playerInventory, Inventory container, System.Boolean callPlayerInvChanged) (at <7ec99f9c70414338b85984142fc0c704>:0)
QuickStackStore.QuickStackModule.QuickStackIntoMultipleContainers (System.Collections.Generic.List`1[T] trophies, System.Collections.Generic.List`1[T] nonTrophies, Player player, System.Collections.Generic.List`1[T] containers) (at <7ec99f9c70414338b85984142fc0c704>:0)
QuickStackStore.QuickStackModule.DoQuickStack (Player player, System.Boolean QuickStackOnlyToCurrentContainerOverride) (at <7ec99f9c70414338b85984142fc0c704>:0)
QuickStackStore.KeybindChecker+Player_Update_Patch.HandleGenericKeys (Player player) (at <7ec99f9c70414338b85984142fc0c704>:0)
QuickStackStore.KeybindChecker+Player_Update_Patch.Postfix_Patch (Player __instance) (at <7ec99f9c70414338b85984142fc0c704>:0)
(wrapper dynamic-method) Player.DMD<Player::Update>(Player)
MSchmoecker commented 1 year ago

Thanks for the report. After some testing, I was able to reproduce this and tracked it down to be caused by distant containers that were partially loaded but don't have a player that's responsible of managing it's inventory. Just to counter check, do you have set a big quick stack are in QSSTR? I will push and update that will prevent this error shortly and @Goldenrevolver will also include a fix in QSSTR that unmanaged containers are not touched by QSSTR, so no items are potentially lost if two players use quickstack in short succession on unmanged distant containers.

mevolu commented 1 year ago

Excellent. Thank you for your time and upcoming patch for the bug!

I had the values for QuickStackToNearbyRange and RestockFromNearbyRange set to 30. In the meantime, however, I have reduced QuickStackToNearbyRange to 15 and RestockFromNearbyRange to 20. With these values I have not had the error yet. But as far as I remember, I was always near my storage boxes. Will reduce the values to their default values (10) and hope that the error no longer occurs.

MSchmoecker commented 1 year ago

Fixed in MUC 0.4.3