Machine Inventory Manager mismapped inventories and tanks.
Restingsound opened this issue · 37 comments
Hello I'm playing on a server with FTB Interactions with SFM updated to version 1.12.2-2.0.23
I created a huge system over many days linking dozens of gregtech machines and Thermal Expansion portable tanks to create a beautiful automated factory. However after a server reboot yesterday 90% of my programs broke (i thought the reboot was the cause, a friend was also on for a couple hours after the reboot but says he didn't touch and SFM blocks). Seemingly depending on how far a block was from the MIM the Inventories and Tanks used were offset by 1-4 inventories. So for instance the output of my ore washer was going to my gems chest and the output of my pulverizer was trying to go to cache full of logs, etc. This was really upsetting and frustrating but we don't reboot the server often so I went through and reset over 2500 commands to fix the system.
When I signed back on today everything was working fine, I added some new features and kept building. Then I went out looking for ore elsewhere in the same dimension probably far enough from the base to generate new chunks, and when I came back all the programs are broken again. I don't see any reports of this bug or it being fixed. Let me know if there are any files or other information I can give you to help reproduce the issue.
I can confirm this bug. I have a setup that exists entirely inside one chunk—even all the blocks it connects to. Each day since I set it up, four of the program tiles have their inventory selections completely cleared, while all of the others are just wrong. Either inventories have been removed or they've been added. There's definitely something scrambling the associates of tile to inventory selection. None of the other settings seem to be affected by this bug.
I'm going to try breaking the Manager block and completely re-do the programs, as there isn't too much in this case. I'm curious if the problem will persist or if it's more sporadic. With the current setup, this is consistently repeatable—the bug always manifests with the same changes to the tiles.
Of course, if the problem continues, I'll have to remove the mod from the pack until it can be fixed. I don't anyone to suffer what Restingsound up above went through with a very large setup getting scrambled.
Please let me know if there's anything I can do to help diagnose this problem! This has been one of my favorite mods, starting with the original. I'd really like to see it fixed.
I can confirm this issue as well. Two things cause a remap:
- Restarting the server causes items to remap, any items like tanks, inv, redstone, etc, sometimes one or two physical locations off, sometimes completely random.
- Sometimes adding or moving inventory cables cause the same thing to happen.
I have broken and replaced my managers, moved them, and copied settings and built new ones, and the exact same problem keeps happening.
Easier to Reset, I tried to set variables for all my repeated machines, that way I could just come in after the reset and reset the machines that way, but we are limited to only 16 variables, and when machines are already receiving materials they should not be, it makes a huge mess sometimes to clean up, to a varying degree, as the map can be completely randomized, seemingly.
I am hoping this gets fixed soon, as it is extremely frustrating, and makes the mod almost unusable. I have not tested this in single player, but I only play on servers, and a daily reset for lag purposes is needed.
I agree with @Nonsanity, that it does not mess up other settings like quantities or white or black lists, it only messes up the location and set blocks attached to cables.
Currently using SFM 2.0.23, in vanilla FTB Interactions 2.0.6 + 2.0.7.
As a final note, it appears that cable clusters can also complete reset to clusters without things like emitters and receives inside, which means all redstone circuits break.
while I have not personally experienced this I can definitely say several people have reported this
I'm going to try breaking the Manager block and completely re-do the programs, as there isn't too much in this case. I'm curious if the problem will persist or if it's more sporadic. With the current setup, this is consistently repeatable—the bug always manifests with the same changes to the tiles.
Hello @Nonsanity, were you able to find any fix or something to avoid to solve to this issue?
Another way this happens, adding an inventory to the network, without altering any cables at all caused a lot of my storage and machines to remap. I did just restart my client, but I doubt that would have caused them to remap, given that neither my server nor its chunks reloaded.
A temporary work around is to right click on the factory manager before walking away from the chunk or saving the world / server restarting.
Doing this causes the factory manager to update the attached inventories and recalculate the internal IDs it uses.
If this isn't done before saving, when the manager is loaded, it'll map the IDs to the wrong inventories.
I demonstrate the workaround and how to reproduce the bug in this video
Edit: I'm not sure if the workaround works in all situations though, and for really large networks it might be quite hard to keep track of like if you have some cables passing by a place where you may place additional inventories/tiles in the future.
https://www.curseforge.com/minecraft/mc-mods/super-factory-manager/files/3049126
Uploaded Blue's fix, hopefully this works.
Major thanks to Blue!
Will keep this issue open for a bit, please call back here telling if it does or does not fix the issue.
Tried the update - I received this client side crash, running Interactions 2.0.9: https://pastebin.com/vdBVbh1K
Here is the server side crash report: https://pastebin.com/VNTLtSXY
So far, first tests seem positive, no remapping even after chunk loading, restarting and changing dimensions. Once I have added all my managers, I will update, and let you know if it is still perfect. I am assuming it is.
https://www.curseforge.com/minecraft/mc-mods/super-factory-manager/files/3050275
This should have fixed the mapping issue, please call back if it does/doesn't work.
Okay, there is still a little error which I do not think may be the same issue, but an issue with the WIP Memory Disk. Copying from one manager to another mismaps the inventories, again.
There is another repeatable mismapping error happening, and a few interesting mechanics, that happen every single time this is repeated:
Here is my set up, with storage in a different part of the world: https://imgur.com/a/hcljo3n
All images have a description explaining exactly what happens.
The most telling and very interesting is the very last image: when a conduit, in this example, a fluid conduit from enderio has an insert/export face, meaning not just the cable, but the node actually open allowing inserts and exports, the entire network does as all my images described. However, the moment the network has no conduit with export/import faces open, it no longer mismaps when adding or removing, and all image descriptions no longer happen!
https://www.curseforge.com/minecraft/mc-mods/super-factory-manager/files/3050275
This should have fixed the mapping issue, please call back if it does/doesn't work.
I didn't touch the memory disk in my PR. That likely needs to store the positions as well if I had to guess. Probably position relative to the manager instead of absolute position like what is currently saved to the tile. If you copy it from a manager, break and replace at the same position then paste to the same manager does it map correctly?
As for the conduit thing, that's pretty interesting. I'm not sure how that might result. Do you think you could come up with a minimal setup using just Ender IO + SFM?
Okay, I did some further testing:
-
WIP Copy: yes, it is a relative positioning, not absolute, issue. Copying and pasting to the exact same spot after breaking keeps the exact same map.
-
Conduits touching cables: every fluid conduit causes the shift of further SELECTED items in the line down by one, and removing the fluid conduit causes them to shift up one spot. This works on all axis, and only does this with fluid conduits of all levels, basic, pressurized and ender. Also, if you break a selected container while a fluid conduit touches the network, it does not deselect, it just moves the selection to the next acceptable connection.
As for minimal, just sfm and enderio, give me a quick moment, ill comment below.
Here are the photos, and it is repeatable every single time, in every single set up. https://imgur.com/a/yc1qzb6
Although, one of my smaller networks did remap just recently, and I am not sure why. I will be watching it closely, and will let you know if I find anything. I removed all conduits except for the energy ones, which in my testing does not cause a remap to happen.
Okay, a setup with only enderio and sfm. The exact same thing happens. Here are the photos: I actually made them public this time, I think I forgot to hit post last time: https://imgur.com/a/Ehsacbd
For 1: Not sure what the desired behaviour is.
Should the mapping use the original positions of the tiles, or should it be relative to the new manager?
Currently if you paste with exactly the same setup (cables and tiles touching the cables relative to the manager) elsewhere, it should map over properly. This could still be improved by storing the relative positions though, so that you can miss some tiles or add a couple more as long as the ones at the expected positions exist.
If I was to change it to absolute position for that then it would break the situation where you want to move a whole setup or dupilcate it multiple times elsewhere.
However, it would allow you to move the manager relative to the original cables and tiles and maintain the mappings. I feel like the former behaviour is more useful. This has always been kind of a problem with copying and pasting programs with SFM even back in 1.7.10 when such functionality was provided by Steve's Addons.
As for 2: Will try to find some time to take a look at it. Not really sure what's up though. I'm curious if the behaviour was around before my PR as well.
For 1, perhaps an option, like a shift clicking in the air to change between relative and absolute copy. I have several managers set up different production lines, separating the production from the storage, so they do not connect, except through the managers, absolute would be best, but, If I do an array of lets say lightwells from Astral Sorcery, and want to copy the array many times for many different light well fluids, then relative would be best.
For 2, I am not sure if it was happening before the merge, however, I do know that I had conduits around the cables beforehand, so, it is possible that was the cause.
I have seen two different instances now of 1, managers forgetting one or two positions, and 2, remapping, but very rare, and unknown as to why.
This morning I started my server, and found that some inventories had been added to the managers, but none were removed. Unknown as to why this happened, I can not seem to duplicate it again.
Also, I found this a bit cumbersome, is this related to your merge?
When I broke a single SFM cable by accident, and then replaced it, every single linked inventory/emitted/etc that would have been down the line was destroyed in the manager. So, I have a line with storage, and then a line with production, and the manager in between. I broke the line by mistake coming off of the manager towards the storage, and every single link disappeared in my manager, even though none of my storage or manager changed locations, or were removed. So, basically, the code says: if link broken, destroy relationship. Before the merge, I had accidentally done this a couple of times, I do not remember it breaking like this.
EDIT: It appears to be time based, but it took me only maybe 10 seconds to replace the cable. To recreate this, I had a manager, 3 cables and then an emitter: I select the emitter as part of a variable in the manager, and then break the middle cable. In a matter of a few seconds, I replace the cable, and check the selection, and it is gone.
Yeah, after another mismap, and extreme rage, hahah, jk, I decided to removed all enderio conduit bundles, meaning all cables in a 100 block radius using a command to make sure they we all gone, and the system seemingly no longer remaps anything on a restart. The only conduits that were still touching the inventory cables were power and redstone. So, something is broken and funky with enderio and SFM touching each other.
Edit: No fluid conduits were touching in this case. I restarted it 5 times, and checked one variable that kept remapping, and not once with no conduits around of any type did they remap. I decided to check this, so I loaded a back up with conduits still there, and sure enough, every single restart, it added another .selected. I am going to keep restarting to see if it is isolated to this. If it changes, I will update you.
Edit 2: this is not 100%. Hmmm.
With every single enderio thing in my world removed, I am still getting remapping issues. And, this time, it is happening randomly, which I assume is a result of removing selected inventories or adding them to the inventory cables. It happens without a restart or reloading chunks. It is clear that something in the code is either preventing the data from storing absolute position values, which causes the selection to change relative to the manager and not to the maintain its absolute positioning, or some other line of code is overriding the absolute values stored when either saving the value, or retrieving it.
If I understand the process correctly, it should, when selected, take the abs position of the selected object, and store the x, y and z of the selected object, and then when retrieving it, it should gather the x y and z of the stored position, and put it into the machine as selected. But, what is happening is one of two things: when putting it back into the machine when updating, it sets it wrong, and then saves it wrong. Or, when it is saved, it is saving the wrong position. And, adding and removing objects from the inventory cables is causing it to shift.
It case it helps: all of my remaps are syncing backwards, or close to the manager by 1 position in the array, when it happens, and it is pretty common for the remaps to fall on the exact same cable, but a different side, as I have 4 sides of each cable with an inventory.
Alright, finally found some time to come back and revisit this. Was having a bunch of trouble getting Ender Core to not crash in dev (one if the libraries Ender IO depends on). But sorted out the issue after revisiting it this evening. (Needed to get the libraries packaged within Ender Core, the maven Ender Core does not seem to include them as dependencies).
Also, tested the fluid conduit shift bug and older version of SFM and it is present in v2.0.23 which was released before my PR. (Maybe you can confirm this as well?).
The change in my PR to save positions only applies when the tile is saved to disk then loaded again, from either a server restart or a leaving the area and coming back.
That, combined with the fact that it occurs on older versions of SFM leads me to believe that the conduit bug is unrelated to the saving and loading of the tile, but something broken with the remapping during the operation of the tile entity. They do share a lot of the same code though.
From the stuff looked at so far, the issue may be within the getNewSelection
method or the addInventory
method. Suspect it has something to do with TileEntities that don't have an associated ConnectionBlockType
. More testing will have to wait for another time, it's bed time for me rn.
Was going to wait till the bug was found a fixed before posting, but thought you might want an update before then.
Edit: With the cable breaking and the inventories immediately being unlinked, I don't think my PR should have changed the ability to quickly replace it back without issue, it targets the mapping breaking on save and reload specifically. You actually have an indefinite amount of time to replace the cable, the manager can run just fine with the cable being broken as long as certain things don't happen.
What can cause it to unlink after you break the cable, just off the top of my head and from experience, is anything that causes it to run updateInventories()
. Typically this happens if any of the tiles that were touching (or part of) the cable is removed or unloaded (specifically if the tile is invalidated, newly added is okay though), tile is cable is placed adjacent to the manager, or right clicking on the manager (or saving and loading ofc). I may have missed a few situations.
To help with identifying what bug is already present before my PR and what was introduced by my PR it would be good if you could see if a bug is both not present in the old version of SFM (v2.0.23) and only exists in the version just after that includes the changes (v2.0.24).
Edit Edit: Actually, if you wouldn't mind it, I could compile a version of SFM with some of my debug code installed and send it to you to use? It'll send messages to chat with what changed in a manager's network when it updates (but if it updates and nothing changed it won't). You can find me on the Modded Minecraft discord, send me a DM and I'll check in the morning.
Sorry for the delay. I will try to download and install the mods and see if it is present with just both of them installed. As for the debug code, that would be perfect, as then I could see exactly what is changing and when it changes. As in, if I break a cable, or add an inventory or remove one. Thank you. Very much appreciated.
And, yes, the bug with enderio absolutely existed before hand. I tested with .23
Any comment from @TeamDman on the random remapping happening when adding or removing selected inventories on inventory cables, or adding cables, without restarts, and the touching enderio fluid conduits, etc? Is there anything I can do to help solve this? As it stands right now, this mod is unusable in its current state when interacting with multiple mods and having big setups. @BlueAgent Having a debugging ability would greatly help out. If there was a way for chat or the log to tell me every time a manager updated its positions, I could tell you exactly what is happening, and when it is happening.
@desagas I have looked into this a bit more but kinda stuck as to what to do.
What's going on is Ender IO exposes a fluid handler capability, but only on the server side. On the clientside it does not expose said capability.... SFM assumes that the capabilities exposed by tiles match up on both sides.
So a proper fix would be, I suppose, to synchronize the inventory / connection data to the client, which might be challenging.
And alternative, more hacky, fix would be to just add all tiles into the inventories (tiles that the manager can interact with) list. I have tried this and it does fix the conduits shifting, but they don't appear in the list.
Technically we should be able to see fluid conduits appear in the manager since they implement IFluidHandler. The manager does have a limit of 1023 inventories, so if we start including all tiles touching the cables we might need to bump that up? (but note that they are already being included, on the server side, we just don't see that reflected clientside).
I'm not really sure what to do tbh. Conduits don't seem like something that should be appearing in the manager but if they really do implement IFluidHandler then they probably should appear and allow you to select and insert fluid into them.
But yeah, in summary, server side tiles don't match up with client side tiles.
As for the debug version, maybe send over your Discord tag and I'll add you, or if you don't wanna post it here then join the Modded Minecraft Discord and find me on there. The problem for the conduit bug has been identified but it would be interesting to see if anything else does something similar to what ender io does (expose different capabilities on the server vs client side) it would also inform you exactly when an inventory update is occuring (on the server side, it doesn't print out the client inventory updates rn, otherwise there would be duplicate messages). I'm thinking I could send you the "hacky" fix for you to try (make sure to back up your world ofc) and see how it behaves.
Any comment from @TeamDman on the random remapping happening when adding or removing selected inventories on inventory cables, or adding cables, without restarts, and the touching enderio fluid conduits, etc?
The 1.12 version of the mod is a port of a port of the original VSWE one. Personally, I have only had to deal with the code that executes the flowchart, I haven't had the pleasure of touching the the code that handles registering inventories or whatever else happens when cables are placed/broken.
From what I can tell, the main part of the issue has been addressed, and an edge case with EnderIO conduits still remains to be fixed. The mismapping issues also seem to be inherited by the manager program copier.
I suppose that means that the workaround for now is "don't have conduits adjacent to SFM cables", which isn't the prettiest solution, but if it means that things keep working after a world reloads then it's better than nothing.
I will continue leave this and other issues open for discussion and as a public documentation of the known bugs, I just can't guarantee that I personally will have the motivation/time to work on the 1.12 version. It's 3 years old, there's no support from the Forge team for the version anymore, and it takes a huge amount of time to try and diagnose VSWE's old code when instead the 1.16 version could be getting attention.
Is there anything I can do to help solve this?
I'll totally accept any pull requests that solve issues. Just make sure to not do something silly like change tabs to spaces or anything that causes a large diff for no reason. I still have to vet the changes after all.
Videos that help with reproduction steps are also helpful.
Commenting back when changes are made to confirm/deny that the fix helped is also helpful.
Documenting known workarounds for bugs is also very good for people who stumble across threads looking for help.
Understandable, an old release, other new things happening, I understand. There are other mismappings happing, however, aside from enderio and the fixed one, that is why I asked for the debug option. I am hoping to look into it, and share as much as possible, even if at least I know just what to avoid, without having to fix anything in code. As 1.12 packs are still very popular, at least I can inform other users on what might help them prevent the same chaos I have experienced.
https://www.curseforge.com/minecraft/mc-mods/super-factory-manager/files/3061425
Alpha build with an attempted fix from BlueAgent
It will let the manager identify inventories more aggressively, hopefully fixing issues where the client does/doesn't recognize certain tiles causing a desync.
@TeamDman, the link does not work.