Sophisticated Storage

Sophisticated Storage

20M Downloads

[Void/Dupe Bug] Capabilities are not supporting 1.16+ features

Speiger opened this issue ยท 3 comments

commented

o/ It's me again

https://github.com/P3pp3rF1y/SophisticatedStorage/blob/954a958ed9/src/main/java/net/p3pp3rf1y/sophisticatedstorage/block/StorageBlockEntity.java#L319

Forge introduced with 1.14 I think Capability caching in Tile/BlockEntitites.
It is one of the major optimizations they started including.
Sadly Sophisticated Storage doesn't support this feature.

How to fix it:
Cache the LazyOptional and invalidate it when the capability should no longer be accessed.
invalidateCaps function in BlockEntity.class is the function you should use to invalidate it.
It is called with chunk unloading and block breaking.

This can lead to item voiding/duplicating, because the mods that trust to receive notifications if the inventory was invalidated can still access the "ghost" blocks inventory and effectively create new items out of thin air.

Thank you for reading.

commented

Thanks for letting me know about this. I had no idea that it's cool for other mods to cache the LazyOptional and there's a way to handle invalidation of those now.
I have added this in both storage and backpack for next release

commented

Thank you :)

Yeah it is one of the best optimizations forge did.

commented

Fixed in the latest version on CF