Fabricators-of-Create / Create

[Fabric Mod] Building Tools and Aesthetic Technology
MIT License
834 stars 188 forks source link

Vaults crossing chunk boundaries delete items when chunks containing them are (un)loaded #1471

Open James103 opened 2 weeks ago

James103 commented 2 weeks ago

Describe the Bug

When a vault crosses chunk boundaries and one of the chunks containing such a vault is unloaded, some of the items stored in that vault are deleted and/or the state of the items stored reverts to the last known save.

This can lead to mass voiding of valuable resources in large storage systems utilizing maximum-size vaults, as many such vaults will cross chunk boundaries. For example, a player inputs 1 million cobblestone into such a system, then leaves and comes back to find that only 500,000 cobblestone survived.

Reproduction Steps

  1. Create a new world.
  2. Place two vault blocks next to each other in different chunks to create a single vault.
  3. Place a smart chute on one of the vault blocks.
  4. Place a double chest on that chute.
  5. Fill the chest completely with stone.
  6. Wait until all stone has filtered through the chute into the vault. 41 stacks should be extracted (20 stacks in each of the two vault blocks, plus an extra stack in the chute).
  7. Save and reload the world.
  8. Fill the chest completely with stone again.
  9. Notice some more stone filters through, which can only be explained by the vault losing some of the items inside.

If the vault remains full even through a save and reload, one can try using a funnel to extract all items from said vault, then save and reload the world once it's empty. If after a reload additional items can be extracted, the vault's storage reverted to a previous state where it still had some items, which constitutes a duplication exploit.

Expected Result

Vaults should not delete or duplicate items when they are unloaded, even if they cross chunk boundaries.

Screenshots and Videos

Minimal reproduction setup: image

Crash Report or Log

No response

Operating System

Windows 10, 64-bit

Mod Version

0.5.1f

Minecraft Version

1.20.1

Other Mods

fabric-api-0.92.1+1.20.1
NoChatReports-FABRIC-1.20.1-v2.2.2

(though NoChatReports-FABRIC-1.20.1-v2.2.2 should not matter in reproducibility)

Additional Context

No response