Fix potential item duplicating (Block like bell)

This commit is contained in:
Snownee 2020-05-16 01:55:52 +08:00
parent 1578a2ac68
commit 6ed79de6c7

View file

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -519,16 +520,20 @@ public abstract class Contraption {
glueToRemove.forEach(SuperGlueEntity::remove); glueToRemove.forEach(SuperGlueEntity::remove);
for (boolean brittles : Iterate.trueAndFalse) { for (boolean brittles : Iterate.trueAndFalse) {
for (BlockInfo block : blocks.values()) { for (Iterator<BlockInfo> iterator = blocks.values().iterator(); iterator.hasNext();) {
BlockInfo block = iterator.next();
if (brittles != BlockMovementTraits.isBrittle(block.state)) if (brittles != BlockMovementTraits.isBrittle(block.state))
continue; continue;
BlockPos add = block.pos.add(anchor).add(offset); BlockPos add = block.pos.add(anchor).add(offset);
if (customRemoval.test(add, block.state)) if (customRemoval.test(add, block.state))
continue; continue;
Block blockIn = world.getBlockState(add).getBlock();
if (block.state.getBlock() != blockIn)
iterator.remove();
world.getWorld().removeTileEntity(add); world.getWorld().removeTileEntity(add);
int flags = 67; int flags = 67;
if (world.getBlockState(add).getBlock() instanceof DoorBlock) if (blockIn instanceof DoorBlock)
flags = flags | 32 | 16; flags = flags | 32 | 16;
world.setBlockState(add, Blocks.AIR.getDefaultState(), flags); world.setBlockState(add, Blocks.AIR.getDefaultState(), flags);
} }