1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2026-06-02 10:52:08 +00:00

Clear turtle player inventory when syncing

Fixes #2332.

I *think* what's going on here is:
 - When we place a block with the turtle, we copy items between the
   turtle's inventory and the fake player's inventory. We *don't* clear
   items from the fake player's inventory after placing, as we'll do it
   next time we use the fake player.

 - At the start of the next tick, Stack Refill then loops over the
   fake player's inventory and moves some items around. However, because
   we just set the items directly (rather than using .copy()), this
   mutates the items in the turtle's inventory too!

To fix this, we just clear the player's inventory after finishing with
it, so Stack Refill never sees these items.
This commit is contained in:
Jonathan Coates
2025-12-15 20:44:00 +00:00
parent a2ed5c385c
commit 1ea84fe7d7
@@ -129,6 +129,7 @@ public final class TurtlePlayer {
// Load up the fake inventory
inventory.selected = 0;
inventory.clearContent();
for (var i = 0; i < slots; i++) {
inventory.setItem(i, turtleInventory.getItem((currentSlot + i) % slots));
}
@@ -154,7 +155,8 @@ public final class TurtlePlayer {
TurtleUtil.storeItemOrDrop(turtle, inventory.getItem(i));
}
inventory.setChanged();
inventory.clearContent();
turtleInventory.setChanged();
}
public boolean isBlockProtected(ServerLevel level, BlockPos pos) {