pcal43 / quicksort

Minecraft mod. Low-effort item sorting to keep your workshop organized.
https://modrinth.com/mod/quicksort
MIT License
7 stars 3 forks source link

Simple duplication bug on multiplayer server #33

Closed griffin4cats closed 1 year ago

griffin4cats commented 1 year ago

A duplication glitch is easy to cause with quicksort. It works by turning the ghost items into real items via logging out from the server (and thus unloading the chunks). I did this on 1.19.4 quilt, but I bet this would work on any version.

Recreating it is simple:

  1. Load the mod into a new or existing server with the default config (or any config that has animations on)
  2. Find somewhere that won't be loaded when you disconnect from the server (as in, don't do this in spawn chunks or anywhere in the world that's forceloaded)
  3. Create a sorting chest that's in range of a destination chest
  4. Put a single item into the destination chest and a stack of that item in the sorting chest
  5. Disconnect from the server as the chest is sorting
  6. Wait the amount of time that it would take for the items to be fully sorted
  7. Reconnect to the server. The duplicated items should be sitting on the ground right next to the destination chest, while the real, original items will be inside the destination chest as intended.

Other information I've gathered from testing:

For server owners, the best fix is to just disable animations in the config. Disabling animation when there's no player nearby is probably the best fix and would fix almost all of the problem, as well as adding some performance improvement to the mod. Items in transit would still end up duplicated, so in addition to disabling animation, killing all ghost items upon player disconnect would likely fix the entire problem.

pcal43 commented 1 year ago

Right, related to #23, which I identified in single-player. My sense is that the simplest way to fix this would be to disable serialization of ghost entities when the chunk is getting unloaded. Haven't really dug in to figure out exactly how to do that.

pcal43 commented 1 year ago

...oh, actually yeah, I think it might be a trivial fix...