From 6ed79de6c700365c8c2006f38a29364ffcd896f2 Mon Sep 17 00:00:00 2001 From: Snownee <1850986885@qq.com> Date: Sat, 16 May 2020 01:55:52 +0800 Subject: [PATCH] Fix potential item duplicating (Block like bell) --- .../components/contraptions/Contraption.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java index a509f2ba8..6602497c4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/Contraption.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; @@ -519,16 +520,20 @@ public abstract class Contraption { glueToRemove.forEach(SuperGlueEntity::remove); for (boolean brittles : Iterate.trueAndFalse) { - for (BlockInfo block : blocks.values()) { + for (Iterator iterator = blocks.values().iterator(); iterator.hasNext();) { + BlockInfo block = iterator.next(); if (brittles != BlockMovementTraits.isBrittle(block.state)) continue; BlockPos add = block.pos.add(anchor).add(offset); if (customRemoval.test(add, block.state)) continue; + Block blockIn = world.getBlockState(add).getBlock(); + if (block.state.getBlock() != blockIn) + iterator.remove(); world.getWorld().removeTileEntity(add); int flags = 67; - if (world.getBlockState(add).getBlock() instanceof DoorBlock) + if (blockIn instanceof DoorBlock) flags = flags | 32 | 16; world.setBlockState(add, Blocks.AIR.getDefaultState(), flags); }