Skip to content

Commit c50ba98

Browse files
authored
Merge pull request #8335 from danth/belt-duplication
Fix item duplication on belts
2 parents 70224e2 + 939fee0 commit c50ba98

File tree

4 files changed

+14
-18
lines changed

4 files changed

+14
-18
lines changed

src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltCrusherInteractionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public static boolean checkForCrushers(BeltInventory beltInventory, TransportedI
6363
remainder = ItemHandlerHelper.copyStackWithSize(currentItem.stack, notFilled);
6464

6565
currentItem.stack = remainder;
66-
beltInventory.belt.sendData();
66+
beltInventory.belt.notifyUpdate();
6767
return true;
6868
}
6969

src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltFunnelInteractionHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static boolean checkForFunnels(BeltInventory beltInventory, TransportedIt
116116
funnelBE.flap(true);
117117
funnelBE.onTransfer(toInsert);
118118
currentItem.stack = remainder;
119-
beltInventory.belt.sendData();
119+
beltInventory.belt.notifyUpdate();
120120
if (blocking)
121121
return true;
122122
}

src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltInventory.java

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ public void tick() {
6868
toInsert.clear();
6969
items.removeAll(toRemove);
7070
toRemove.clear();
71-
belt.setChanged();
72-
belt.sendData();
71+
belt.notifyUpdate();
7372
}
7473

7574
if (belt.getSpeed() == 0)
@@ -79,8 +78,7 @@ public void tick() {
7978
if (beltMovementPositive != belt.getDirectionAwareBeltMovementSpeed() > 0) {
8079
beltMovementPositive = !beltMovementPositive;
8180
Collections.reverse(items);
82-
belt.setChanged();
83-
belt.sendData();
81+
belt.notifyUpdate();
8482
}
8583

8684
// Assuming the first entry is furthest on the belt
@@ -154,11 +152,11 @@ public void tick() {
154152
ItemStack item = currentItem.stack;
155153
if (handleBeltProcessingAndCheckIfRemoved(currentItem, nextOffset, noMovement)) {
156154
iterator.remove();
157-
belt.sendData();
155+
belt.notifyUpdate();
158156
continue;
159157
}
160158
if (item != currentItem.stack)
161-
belt.sendData();
159+
belt.notifyUpdate();
162160
if (currentItem.locked)
163161
continue;
164162
}
@@ -217,7 +215,7 @@ public void tick() {
217215
currentItem.stack = remainder;
218216

219217
flapTunnel(this, lastOffset, movementFacing, false);
220-
belt.sendData();
218+
belt.notifyUpdate();
221219
continue;
222220
}
223221

@@ -228,7 +226,7 @@ public void tick() {
228226
eject(currentItem);
229227
iterator.remove();
230228
flapTunnel(this, lastOffset, movementFacing, false);
231-
belt.sendData();
229+
belt.notifyUpdate();
232230
continue;
233231
}
234232
}
@@ -248,7 +246,7 @@ protected boolean handleBeltProcessingAndCheckIfRemoved(TransportedItemStack cur
248246
return false;
249247
if (processingBehaviour == null) {
250248
currentItem.locked = false;
251-
belt.sendData();
249+
belt.notifyUpdate();
252250
return false;
253251
}
254252

@@ -259,7 +257,7 @@ protected boolean handleBeltProcessingAndCheckIfRemoved(TransportedItemStack cur
259257
return false;
260258

261259
currentItem.locked = false;
262-
belt.sendData();
260+
belt.notifyUpdate();
263261
return false;
264262
}
265263

@@ -292,7 +290,7 @@ protected boolean handleBeltProcessingAndCheckIfRemoved(TransportedItemStack cur
292290
if (result == ProcessingResult.HOLD) {
293291
currentItem.beltPosition = segment + .5f + (beltMovementPositive ? 1 / 512f : -1 / 512f);
294292
currentItem.locked = true;
295-
belt.sendData();
293+
belt.notifyUpdate();
296294
return false;
297295
}
298296
}
@@ -471,8 +469,7 @@ public void applyToEachWithin(float position, float maxDistanceToPosition,
471469
toRemove.add(transported);
472470
}
473471
if (dirty) {
474-
belt.setChanged();
475-
belt.sendData();
472+
belt.notifyUpdate();
476473
}
477474
}
478475

src/main/java/com/simibubi/create/content/kinetics/belt/transport/BeltTunnelInteractionHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public static boolean flapTunnelsAndCheckIfStuck(BeltInventory beltInventory, Tr
5656
if (onServer) {
5757
brassTunnel.setStackToDistribute(current.stack, movementFacing.getOpposite());
5858
current.stack = ItemStack.EMPTY;
59-
beltInventory.belt.sendData();
60-
beltInventory.belt.setChanged();
59+
beltInventory.belt.notifyUpdate();
6160
}
6261
removed = true;
6362
}
@@ -92,7 +91,7 @@ public static boolean flapTunnelsAndCheckIfStuck(BeltInventory beltInventory, Tr
9291
flapTunnel(beltInventory, upcomingSegment, d, false);
9392

9493
current.stack.shrink(1);
95-
beltInventory.belt.sendData();
94+
beltInventory.belt.notifyUpdate();
9695
if (current.stack.getCount() <= 1)
9796
break;
9897
}

0 commit comments

Comments
 (0)