
Carry On and Sophisticated Storage
kiaen1 opened this issue · 4 comments
This was found in Darkosto's Sky factory 5 modpack.
1.20.1 - Minecraft
2.1.2.7 - CarryOn
1.0.1.809 - Sophisticated core
1.0.2.985 - Sophisticated Storage
When you pick up a sophisticated storage double chest(Seems to matter which side, I had the "best" luck with the left chest), put it down, pick it back up and place it again, it deletes the "second" half of the items in the chest. Vanilla chests work just fine. Darkosto recommended reporting this to you instead.
Showing Inventory
Showing double chest.
Showing probe of chest after picking up once.
Picking it up again and showing probe of lost items
Showing empty Inventory.
Possible solutions?
Maybe having the chest truly split when you pick it up, instead of this half split.
I will see if this can be solved somehow, but it's very likely the only "solution" will be to mark chests as immovable by carryon. Looks like Carryon doesn't give me a chance to move the items to the second half which logic actually is included in the code, but it's also super annoying to work out anything concrete here because I can't get Carryon running in my dev environment without revamping the whole thing and migrating back to forge and hoping that will make carryon not crash in there.
I will see if this can be solved somehow, but it's very likely the only "solution" will be to mark chests as immovable by carryon. Looks like Carryon doesn't give me a chance to move the items to the second half which logic actually is included in the code, but it's also super annoying to work out anything concrete here because I can't get Carryon running in my dev environment without revamping the whole thing and migrating back to forge and hoping that will make carryon not crash in there.
Fair enough! Thanks for being willing to look at it either way, sorry it sounds like such a pain in the butt.
Hey there, Carry On dev here. Can you explain how exactly your chests work and how they differ from vanilla chests? I'll explain what carry on does exactly:
Removing a block:
- It saves the block state as NBT using
NbtUtils#writeBlockState
- Then it calls
BlockEntity#saveWithId
and saves that NBT too - It removes the Block Entity
- It removes the Block
Removing the Block Entity before the Block causes most incompatibilities. However, it is also the only way (that I've found) to reliably prevent any Block Entities from dropping their contents or calling other break logic.
This is the root of the problem: I want to prevent certain break logic (like dropping the contents), but this can cause incompatibilities, like storage networks not updating or multiblocks breaking, etc.
Placing a block:
- Based on the saved blockstate and the rotation-adjusted blockstate, it constructs a new merged blockstate in the world
- It calls
BlockEntity#loadStatic
on the NBT tag that it saved earlier - It then places the block entity in the world
What could I offer?
I could offer a hook for mods to register a custom save, load, break and placement handler for their blocks, allowing mods to precisely specify the logic for their blocks.
Hey @Tschipp,
So the difference with the chests here is that double chests actually only store the contents in the left half.
The reason that is the case is primarily related to how upgrades are handled and that there only can be one unified set of these per double chest and upgrades can affect inventory so the inventory is also stored as a single one. I juggled the idea of potentially keeping it separate, but even though it would help in a few cases it would overcomplicate most of the other cases.
This however means that when just one half of the chest is broken/removed there needs to be handling that happens and it may not be just dropping items from that half of the chest and moving the rest to the second, but it may also be dropping part of the items from the right half if stack upgrades are getting dropped and the second half has stacks that are higher than vanilla maxstacksize.
Anyway I took a look at the implementation in Carry On and honestly didn't see of making this work well so I was leaning towards just adding a tag that makes Carry On not pickup chests.
But if you are able to add an API that mods could use that would be great. I would only need the break and possibly placement handlers (for something like joining chests together), I don't believe that I need save and load, but they could definitely be good for other mods.
Just one additional thing would be great - "pickup validation" canPickup
handler - the double chests can be packed similar to other storage, but unlike the other the packed double chest would always drop as a whole and if Carry on only picks up half of it I would have to drop items in some cases in a pretty ridiculous situation - packed storage is supposed to retain items and carry on is as well and yet there would be drops even in this case. I would much rather just let Carry on know to not pickup packed storage in that case, anyway the player can just break the packed storage and move it as it will retain its items so there should be no need for Carry on to get involved there.
I am also guessing this addition could be useful to other mods that could just prevent pickup in specific cases based on state rather than blanket banning carry on for the given block regardless of its state.