th3w4rd3n Posted October 30, 2025 Report Posted October 30, 2025 (edited) SOLUTION: the command to force-restock a trader is /entity cmd l[] setattr string lastRefreshTotalDays 1 you can set the number at the end to however many times you want them to restock, up to a maximum of 10. note that doing this with the trade interface open will crash the game. using the command on the same trader twice in a session also crashes the game, so make sure to save and quit, then reload, after each use. you can change the l[] to another selector if you like. this will refresh the trader you're currently looking at. ORIGINAL POST: (this may or may not be better off in a bugs report on the github, but i wanna see if it's possible to solve the problem on my own first.) is there any kind of command or feature or mod out there that can allow you to cycle a trader's stock? sometimes i'm just straight up unable to work on projects for ages because a trader won't restock (usually luxuries traders and glass), and while sometimes i have side projects to work on while i wait, it can be annoying to have my momentum stopped dead due to lack of building materials. however the thing that pushed me to finally ask this question is when i got to the Village. the villagers spawned in just fine (unlike my first time), but their trades are... odd. the baker is selling uranium ore (which im pretty sure isnt bread), the tailor is selling random animals (as in, the creative item). and, additionally, their restock timer is one and a half years, which i'm certain isn't intended behaviour. this is likely in part due to mods i'm running interfering with object ids, which is part of why i'm not making a bug report, and i think maybe if i force them to restock it'll fix their trades. i can't seem to find any command that will work, however, so im reaching out to yall in hope that somebody knows how to fix things. MODLIST: Antlers & Horns, Attribute Rendering Library, Auto Config Lib, Backpacks Plus Plus Expanded, Balanced Stick Recipe, Bear Armour Repair, Better Firepit, Better Forest, Better Ruins, Blood Trail, Butchering Extra, Butchering, Buzzwords, Carry On, Chicken Feed, Chisel Tools, Trader Camps, Common Lib, Config Lib, Configurable Room Size, Configure Everything, Truth and Beauty: Detailed Animals, Drifter Aim Nerf, Enhanced Handbook, Expanded Matter, Extra Info, Flee Exhaustion, Food Shelves, From Golden Combs, Genelib, Interesting Ore Gen, Long Term Food, Manual Scraping, Mobs Radar, Monster Spawn Nerf, More Map Icons, Natural Fertilizer, Overhaul Library, Pig Feed, Player Corpse, Player Model Library, Primitive Survival, Purposeful Storage, Quivers and Sheathes, Recycle Backpacks, Seed Harvesting, Shear Lib, Shelf Obsessed, Slow Tox, Status Hud, Step Fix Elk, Stone Quarry, Substrate, Toolsmith, Useful Shears, Vanilla Plus World Gen, Dear ImGUI, Wool & More, Yet Another Cheese Buff, Zippy's Cattail Stew TEST RESULTS TO ISOLATE ISSUE: i did some testing on both a vanilla world and a control test (basically same worldgen options and all mods enables). neither have the broken trades, even when i regenerate with /wgen. so it must be some kind of other issue. i also ran a test with a world with the exact seed i have on my affected world, and the trades are also all normal there. so i officially have not a clue what could be causing this. some kind of random bug with item IDs COULD be the cause, but then why does it affect restock times too? Edited November 9, 2025 by th3w4rd3n adding solution and command to the post
Professor Dragon Posted October 30, 2025 Report Posted October 30, 2025 (edited) I don't know if the information from this post in 2021 is still true, but it likely is: Assuming it is true, all you can do is set the time forward with commands . . . by more than 506 days. This will, of course, have big impacts on your world. All your stored food for one will likely rot, or at least lose a lot of its freshness. Saplings will grow etc etc. Still, time moving forward - apart from that - is not usually a problem. Sure, your game year will be in the future, but what of it? I'd almost be inclined if I were you to: Backup your current world. Take a copy of the world Remove the likely offending mods Work on the copy, not the original world Regenerate the structures which house the above traders. Creative Mode, of course. See if they get the right trades in. In which case, happy dance. Apply the same to your world. It's a bit of a "hammer to a walnut" approach, but it should work. And/or contact the mod authors. The thing is, if it has happened once, what if it happens again? It won't matter if they restock if they are still selling you . . . Uranium??? Who are these guys??? You could also try an Issue Tracker request, but maybe make it the same question you asked here "Is there/can I have a command to restock a Trader?" Professor Dragon. Edited October 30, 2025 by Professor Dragon 1
Professor Dragon Posted October 30, 2025 Report Posted October 30, 2025 Hello @th3w4rd3n, I should have thought to check the Issue Tracker earlier . . . There is actually a similar issue there. Nadinya villagers randomised trade #5469 "Nadinyan villagers either dont trade or have randomized trade giving things like uranium chunks or creative items such as moving water." You should add your comments to that thread. Professor Dragon. 1
th3w4rd3n Posted October 30, 2025 Author Report Posted October 30, 2025 10 hours ago, Professor Dragon said: Nadinya villagers randomised trade #5469 You should add your comments to that thread. i dont know why i didnt think to check the tracker earlier. i think i did but i only skimmed the list. either way i've gone ahead and left a comment on the thread. i'll also mirror part of what i posted on the issue here 1
th3w4rd3n Posted November 8, 2025 Author Report Posted November 8, 2025 giving this a little bump. i tried to use /entity to maybe edit the trader's values so they restock and reset their trades, however i cant even begin to figure out how the command works or what to do to tweak those values. if anybody knows if traders can be edited with /entity and knows the command for it, i will mail you flowers with my mind
Solution Bumber Posted November 9, 2025 Solution Report Posted November 9, 2025 I looked at the source code for EntityTradingHumanoid.cs a bit, and it looks like the value you'd want to tweak is called lastRefreshTotalDays. From what I can tell, it triggers a restock if this value is more than 7 days behind the current game day, then adds 7 to it. This can trigger multiple restocks (max 10, i.e., 70 days since last visit) if the value is low enough. (There's a 200 tick delay between each restock, probably for performance reasons.) If you don't want to figure out what the current day is, it looks like deleting the value will set it to the current day -10, triggering 2 restocks. Or you can set it to 0, triggering 10 restocks. (This sets lastRefreshTotalDays to 1-6 days in the future. I.e., restocking will take longer than usual if you were away for a long time. I wonder if that's a bug?) 2
th3w4rd3n Posted November 9, 2025 Author Report Posted November 9, 2025 7 hours ago, Bumber said: I looked at the source code for EntityTradingHumanoid.cs a bit, and it looks like the value you'd want to tweak is called lastRefreshTotalDays. From what I can tell, it triggers a restock if this value is more than 7 days behind the current game day, then adds 7 to it. This can trigger multiple restocks (max 10, i.e., 70 days since last visit) if the value is low enough. (There's a 200 tick delay between each restock, probably for performance reasons.) i owe you my life. this doesnt fully fix them stocking unusual items from time to time, as well as the fact they seem to have no money, but this lets me at least force them to cycle the goods until something normal comes up ill add the command i used to the top of the post. thank you SO much yall for helping me look into this 1 1
Bumber Posted November 10, 2025 Report Posted November 10, 2025 (edited) Weird that it crashes. It's supposed to wait for the interface to close before doing anything. (If you're farther than 2.24 units (blocks?) away, it tries to force the interface to close.) Edited November 10, 2025 by Bumber
th3w4rd3n Posted November 12, 2025 Author Report Posted November 12, 2025 On 11/10/2025 at 5:27 AM, Bumber said: Weird that it crashes. It's supposed to wait for the interface to close before doing anything. (If you're farther than 2.24 units (blocks?) away, it tries to force the interface to close.) i can only come up with the idea it has to do with my mods and some kind of resulting lag from having to tick over all the trades at once. i can do some tests on a vanilla world when i get the time. also i saw the unedited message in my email before coming here and i was actually curious about what would happen if i changed what datatype it was. bool causes instant crashes (with System.IO.EndOfStreamException: Unable to read beyond the end of the stream.), but int, string, and float all work for it, though they also crash from time to time with the same 'unable to read beyond the end of the stream' error. no matter which data value i use itll crash if i use it on the same trader twice or too quickly on another trader. something something the wonders of technology. the solution still technically works, though!
Recommended Posts