Jump to content

Recommended Posts

Posted (edited)
On 3/30/2026 at 12:40 AM, The_Architect1 said:

So, I've made this client-side mod but i can't seam to make it work everything passes it shows up in the mod list but it won't do anything. ill put the file on he if anyone can help me or just publish it i would love that.

If this was a test to see if someone could point out all the issues then you certainly did a good job 😅, I probably missed some things but here are my findings:

1. The `assets` folder and `modinfo.json` file should be directly in the zip and not in a sub folder, otherwise the game will complain.
2. You say it's a `client-side` mod but `Side` is not set to `Client` inside the `modinfo.json`, currently the game would see it as a universal mod that is required both on server and client.
3. You appear to be using the `World.Config` but not only is this global for all players, it's also server leading so changing it from the client side won't persist. Consider using a local config file with `api.LoadModConfig` and `api.StoreModConfig`.
4. HotKeys are handled client side so your sorting of the inventory is happening client side.... but inventories are server leading, so if you want this to be done client side you need to send the actual packets for opening the inventory and moving stuff to the server (just moving the `ItemStack` between slots on the client is not enough).

Testing shows that the slots indeed only appear sorted but go back to normal once you try to interact (as the server sync overrides the local changes)
image.png.39d72544f436e6ff3009d4343a0c9157.pngimage.png.9f7c5a553ee30a7b3c04007ca5d120e7.png
*as for why it ignored the first 6 slots, see point 6. 

5. Would recommend calling `MarkDirty` after modifying the `ItemSlot` manually even on client as this calls the `OnItemSlotModified` event.
6. The `SortyInventory` (and `ApplySorted`) is starting at index 10? This doesn't seem right to me... in the base game everything after slot 4 would be the actual backup content (1 to 4 being the slots for the actual backpacks themselves), also rather then using a hard coded number, check the actual slot types as mods might change the amount you have. (`ItemSlotBackpack` for the backpack slots and `ItemSlotBagContent` for the actual content of the bags)

7. `MergeStacks` is wrong, it assumes that all ItemStacks are equivelant as long as the `Code` is the same but this just isn't true, not only does this ignore transitions such as rotting (this requires extra logic for merging the transition progress) but some items like for instance clutter uses the attributes to differentiate meaning this will merge multiple different kinds of clutter into 1. The `StackSize` calculation is also wrong: the `ItemSlot` can also put a limit on the `StackSize` so `Collectible.MaxStackSize` is not enough, you need the actual `ItemSlot` to check the limit.

(btw there was no need to call `ToString` on the code here as `AssetLocation` properly implements equality methods, meaning this is just unnecessary overhead)

8. In `SortInventory` you pass a sorting method that either calls `GetTypePriority` or `GetSmartPriority` depending on the `currentMode`, consider just passing the`GetTypePriority` or `GetSmartPriority` method based on `currentMode` that way it doesn't need to constantly compare `currentMode` (and you avoid the risk of it ever changing mid sort

9. Not necessarily wrong but your secondary sorting is using the `Collectible.Code.ToString()` which means you are for starters indirectly sorting on Mod since the Code exists of `Domain` (generally ModID) + `Path`, secondarily the code could be the same for multiple items if they are using attributes to differentiate so consider using `GetHeldItemName` instead.

10. `GetSmartPriority` and `GetTypePriority` checks for hard coded words to check the tool/material, which  is very prone to error. Instead use `Collectible.Tool` which contains a nullable enum that can be matched to check for tool types and `Collectible` and if a `Block` use `GetBlockMaterial` to check the material instead.

11. Not very relevant since it shouldn't be stored in the world config in the first place but rather then storing locked slots as "lockedSlot" + slotNumber, you could have just stored a `BoolArrayAttribute` (it doesn't have a fluent method for it though)

12. `lockedSlots` has a max size of 40 but depending on the mods present you might have more so this size should really be increased at runtime if the backpack inventory ever go's over 40.

Edited by The Insanity God
fixed some typos in point 12
  • Like 1
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.