Registry for custom behaviour with external storage for specific blocks#979
Registry for custom behaviour with external storage for specific blocks#979lucasser wants to merge 2 commits intorefinedmods:developfrom
Conversation
|
based |
|
Will let us integrate with QIO and AE2 very easily. |
|
"is rs2 or ae2 better" we're doing both now keep up |
|
I'm not sure that this will work properly. The external storage API is designed to just be active for all providers all the time, regardless of block type. We can't be block type dependant. The reason for this is: if we are block type dependant, that means you need to reload the storage if the connected block changes (this currently doesn't happen, by design). If you reload when the connected block changes, this causes 2 problems:
Listening to connected block changes isn't bad per se, but some blocks constantly send block updates. See #886 Regarding possible AE integration: Refined Storage shouldn't have integration with Applied Energistics, there is no use case for it and encourages people to create weird setups for no reason that create problems. |
|
If we were to merge this, only for QIO integration, |
|
I have two solutions. I changed the neighbourChanged method to re initialize if the changed block is in the registry. This might cause problems if the special block always sends updates. The other option is we store the block the storage is currently sitting on, and if it changes: if (savedBlock.getLootTable().registry() != newBlock.getLootTable().registry()) {
blockEntity.loadStorage(serverLevel);
} else...then we change the provider. |
|
I am trying to prevent hardcoded blocks/values so that if there is something else that need a custom provider, it'll be easy to integrate (for example create storage system) |
Yes, but that is less of a problem since we explicitly whitelist these blocks and can check them.
That is bound to cause issues: you have to deal with syncing world state & cache invalidation. |
|
I do not want to create more instability in a phase of development where we already have so many bugs. |
9fbc450 to
1834b02
Compare
|
Also, this doesn't have to be an urgent thing, I'm just submitting PRs as I finish working on them for you to review whenever you can. |
c8b592a to
1da3a0e
Compare
|
Is there a reason for updating external storage provider when an interface/special block is broken as opposed to just update when something is placed |
1da3a0e to
6cab5f0
Compare
|
I updated this PR to 2.0.0, and stress tested. It correctly updates the provider on world load, when a block gets placed, and when a block gets instant replaced in creative mode. The one thing that doesn't work is entangled blocks, since they will load the composite provider when you place it and not update the provider depending on what's inside (but they won't work with an interface either). To fix it there would have to be an EntangledBlockExternalStorageProvider which would correctly update it. Everything else works fine. |
Implements #976