Double Trouble

- Fixed an item duplication issue with belts
- Spectators can no longer interact with contraptions
This commit is contained in:
simibubi 2022-07-07 13:18:03 +02:00
parent c55cdd2bac
commit c36c4e756e
5 changed files with 10 additions and 0 deletions

View file

@ -75,6 +75,8 @@ public class ContraptionHandlerClient {
if (player == null) if (player == null)
return; return;
if (player.isSpectator())
return;
if (mc.level == null) if (mc.level == null)
return; return;
if (!event.isUseItem()) if (!event.isUseItem())

View file

@ -428,6 +428,8 @@ public class BeltInventory {
Function<TransportedItemStack, TransportedResult> processFunction) { Function<TransportedItemStack, TransportedResult> processFunction) {
boolean dirty = false; boolean dirty = false;
for (TransportedItemStack transported : items) { for (TransportedItemStack transported : items) {
if (toRemove.contains(transported))
continue;
ItemStack stackBefore = transported.stack.copy(); ItemStack stackBefore = transported.stack.copy();
if (Math.abs(position - transported.beltPosition) >= maxDistanceToPosition) if (Math.abs(position - transported.beltPosition) >= maxDistanceToPosition)
continue; continue;

View file

@ -511,6 +511,8 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
@Override @Override
public boolean startControlling(BlockPos controlsLocalPos, Player player) { public boolean startControlling(BlockPos controlsLocalPos, Player player) {
if (player == null || player.isSpectator())
return false;
if (carriage == null) if (carriage == null)
return false; return false;
if (carriage.train.derailed) if (carriage.train.derailed)

View file

@ -79,6 +79,8 @@ public class TrainRelocator {
LocalPlayer player = mc.player; LocalPlayer player = mc.player;
if (player == null) if (player == null)
return; return;
if (player.isSpectator())
return;
if (!player.position() if (!player.position()
.closerThan(relocatingOrigin, 24) || player.isSteppingCarefully()) { .closerThan(relocatingOrigin, 24) || player.isSteppingCarefully()) {

View file

@ -28,6 +28,8 @@ public class ScheduleItemRetrieval {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (player == null || entity == null) if (player == null || entity == null)
return; return;
if (player.isSpectator())
return;
Entity rootVehicle = entity.getRootVehicle(); Entity rootVehicle = entity.getRootVehicle();
if (!(rootVehicle instanceof CarriageContraptionEntity)) if (!(rootVehicle instanceof CarriageContraptionEntity))