-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix item duplication on belts #8335
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
Fix item duplication on belts #8335
Conversation
The language in this PR doesn't sound too convincing, although it sounds like a plausible explanation. Have you (somewhat consistently) reproduced the bug without the PR where you couldn't with? |
Yes, I can reproduce the bug as follows:
I did this experiment about 5-10 times, duplication happened all but once before this change and never happened after. I also had print statements at various places in #4526 does sound like the same issue, since going to the nether is another way to unload chunks - assuming that the |
I can reproduce #4526 only when the target inventory is in a different chunk, like this: This PR doesn't fix that issue, but I have a feeling its cause is similar. When the barrel is in the same chunk, the barrel presumably calls The patch below fixes it with a single item on the belt, but I have a feeling it doesn't cover all possible cases, such as the funnel only taking part of a stack. diff --git a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltInventory.java b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltInventory.java
index d1a870b70..964e861e6 100644
--- a/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltInventory.java
+++ b/src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltInventory.java
@@ -110,6 +110,7 @@ public class BeltInventory {
if (currentItem.stack.isEmpty()) {
iterator.remove();
currentItem = null;
+ belt.setChanged();
continue;
} |
Belts were not always saved after their inventory changed, leading to duplication of items when the chunk was reloaded.
Okay, this PR now fixes #4526 too, including when the funnel takes part of a stack. I also fixed a similar issue with tunnels: The inventory of the main belt wasn't saved after the stack passed through the tunnel, but the item which split off was, so the stack would pass through again after reloading the chunk. |
Thank you! |
When a belt points directly into another belt, the last item to cross the boundary may be duplicated when the chunk is unloaded. I believe this happens because the ending doesn't mark the inventory as changed after removing the item.
This is my first time contributing to a Minecraft mod, so please double check that I'm correct before merging.
Fixes #7242
Fixes #4526