jayugg / SmithingPlus

Add bits when smithing and other tweaks
1 stars 0 forks source link

Crash with Wild Farming - Revival Recipe #1

Open Sythelux opened 1 week ago

Sythelux commented 1 week ago

Whenever I try to craft the shapeless seed crafting from Wild Farming Revival my game crashes with the error below. It seems that the issue is not with Wild farming, but with SmithingPlus checking for durability on an Item it doesn't support.

VintageStory-server_1.19  |    at SmithingPlus.ToolRecovery.Extensions.GetDurability(ItemStack itemStack) in /Users/jacopouggeri/workspace/VintageModding/SmithingPlus/SmithingPlus/ToolRecovery/Extensions.cs:line 16
VintageStory-server_1.19  |    at SmithingPlus.ToolRecovery.ItemDamagedPatches.Prefix_DamageItem(IWorldAccessor world, Entity byEntity, ItemSlot itemslot, Int32 amount, CollectibleObject __instance) in /Users/jacopouggeri/workspace/VintageModding/SmithingPlus/SmithingPlus/ToolRecovery/ItemDamagedPatches.cs:line 102
VintageStory-server_1.19  |    at Vintagestory.API.Common.CollectibleObject.DamageItem_Patch1(CollectibleObject this, IWorldAccessor world, Entity byEntity, ItemSlot itemslot, Int32 amount)
VintageStory-server_1.19  |    at Vintagestory.API.Common.GridRecipe.ConsumeInputShapeLess(IPlayer byPlayer, ItemSlot[] inputSlots) in VintagestoryApi\Common\Crafting\GridRecipe.cs:line 331
VintageStory-server_1.19  |    at Vintagestory.Common.InventoryCraftingGrid.ConsumeIngredients(ItemSlot outputSlot) in VintagestoryLib\Common\GameContent\Inventory\InventoryCraftingGrid.cs:line 206
VintageStory-server_1.19  |    at Vintagestory.Common.ItemSlotCraftingOutput.CraftSingle(ItemSlot sinkSlot, ItemStackMoveOperation& op) in VintagestoryLib\Common\GameContent\Inventory\ItemSlotCraftingOutput.cs:line 176
VintageStory-server_1.19  |    at Vintagestory.Common.ItemSlotCraftingOutput.TryPutInto(ItemSlot sinkSlot, ItemStackMoveOperation& op) in VintagestoryLib\Common\GameContent\Inventory\ItemSlotCraftingOutput.cs:line 60
VintageStory-server_1.19  |    at Vintagestory.API.Common.ItemSlotOutput.ActivateSlot(ItemSlot sourceSlot, ItemStackMoveOperation& op) in VintagestoryApi\Common\Inventory\ItemSlotOutput.cs:line 44
VintageStory-server_1.19  |    at Vintagestory.API.Common.InventoryBase.ActivateSlot(Int32 slotId, ItemSlot sourceSlot, ItemStackMoveOperation& op) in VintagestoryApi\Common\Inventory\InventoryBase.cs:line 436
VintageStory-server_1.19  |    at Vintagestory.Common.InventoryCraftingGrid.ActivateSlot(Int32 slotId, ItemSlot sourceSlot, ItemStackMoveOperation& op) in VintagestoryLib\Common\GameContent\Inventory\InventoryCraftingGrid.cs:line 130
VintageStory-server_1.19  |    at Vintagestory.Common.InventoryNetworkUtil.HandleClientPacket(IPlayer byPlayer, Int32 packetId, Packet_Client packet) in VintagestoryLib\Common\GameContent\Inventory\InventoryNetworkUtil.cs:line 228
VintageStory-server_1.19  |    at Vintagestory.Server.ServerSystemInventory.HandleActivateInventorySlot(Packet_Client packet, ConnectedClient client) in VintagestoryLib\Server\Systems\Inventory.cs:line 493
VintageStory-server_1.19  |    at Vintagestory.Server.ServerMain.ProcessNetMessage(NetIncomingMessage msg, NetServer mainSocket) in VintagestoryLib\Server\ServerMainNetworking.cs:line 138

The recipe in question: grafik

jacopouggeri commented 4 days ago

The durability that is crashing check should only happen if the item is being destroyed, since that is when the repair features of the mod come into play. The issue is not that smithing plus doesn't support the item, but that wild farming does fancy stuff with pans. They normally have 1 durability so that's why this get triggered, any damage on it should break the item. I will have to check the wild farming code to see how it handles this, I doubt it just gives more durability to the pan since this code shouldn't run in that case. If it uses some patch that specifically detects this recipe then the issue might be with that specific unexpected interaction (base game never does that, so I never account for durability being different).

jacopouggeri commented 4 days ago

A weirder issue is that this should abort regardless because the is not made from metal... unless some mod adds some recipe that uses a smithed metal item (not a knife, but something like a chisel?) then my metal system might (?) detect it as metal?

Except I'm pretty sure it shouldn't since you have to manually specify tool types in the config and pan is not one of them, so none of this should run regardless...

jacopouggeri commented 4 days ago

Could you post the files client-debug.txt and server-debug.txt after the crash happens? I think those might hold some information on what could be going wrong. If it found a metal item in the pan somehow, it should appear there. If it didn't it should also say that.

Sythelux commented 1 day ago

I was able to do it in single player as well, since the single player also starts a server I have both logs. Interestingly enough it is not crashing, but the exception still occurs.

server-debug.txt client-debug.txt

Sythelux commented 1 day ago

I debugged it and indeed something is changing the item stack of the pan to have attributes, but no Item inside.

grafik

but a block!

Not sure if it would be enough to just make it a itemStack.Attributes.GetInt("durability", itemStack.Item?.Durability ?? itemStack.Block?.Durability ?? 0), though?