Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inventory peripherals invalidate all the time #1817

Open
SquidDev opened this issue May 4, 2024 · 0 comments
Open

Inventory peripherals invalidate all the time #1817

SquidDev opened this issue May 4, 2024 · 0 comments
Labels
area-Minecraft This affects CC's Minecraft-specific content. bug A problem or unexpected behaviour with the mod.

Comments

@SquidDev
Copy link
Member

SquidDev commented May 4, 2024

Minecraft Version

1.20.6

Version

1.110.3

Details

When a block or block entity changes in the world, CC refetches the peripheral from the adjacent block. If the peripheral has changed, CC detaches the current peripheral, and attaches the new one.

On NeoForge for Minecraft 1.20.4 or later, a new inventory object is returned every time we query the item storage capability. This means the new generic peripheral is not considered equal to the previous one, and so the peripheral is reattached.

This problem is made worse by 04900dc, as now peripheral methods will frequently return nil due to the peripheral frequently attaching and reattaching.

I can think of a couple of options here, but none of them feel especially good:

  • Add a custom equality for IItemHandlers, which checks for InvWrapper and CompoundContainers. This is sort of what we did in 9b63cc8 for Fabric, but it feels like we're papering over the cracks rather than doing something sensible.

  • Refetch the capability on each method call. So instead of storing the inventory itself, we store the block capability. We'd have to have some special handling to check whether a particular method is still appropriate (so if the underlying class of the inventory has changed), and then somehow invalidate the peripheral then and requeue the method on the new peripheral?!

    We'd also require all generic peripheral methods to be called on the main thread, which isn't a big restriction (it's the case anyway), but is annoying.

  • Some way to update the peripheral in-place. So when the peripheral is refetched, we swap out the existing target in the saturated methods. We'd need to then make the generic peripheral provider stateful, which I don't feel good about.

@SquidDev SquidDev added the bug A problem or unexpected behaviour with the mod. label May 4, 2024
@SquidDev SquidDev added this to the Minecraft 1.20.6 milestone May 4, 2024
@SquidDev SquidDev added the area-Minecraft This affects CC's Minecraft-specific content. label May 4, 2024
@SquidDev SquidDev changed the title Inventory peripherals invalidate too often Inventory peripherals invalidate all the time May 4, 2024
schindlershadow added a commit to schindlershadow/ComputerCraft-Item-Storage-System that referenced this issue Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-Minecraft This affects CC's Minecraft-specific content. bug A problem or unexpected behaviour with the mod.
Projects
None yet
Development

No branches or pull requests

1 participant