From f425b150bd7037e14d2178fe2346ec4fd917205c Mon Sep 17 00:00:00 2001 From: Snownee Date: Thu, 10 Dec 2020 22:15:56 +0800 Subject: [PATCH] Fix crash if mechanical piston pushes a bed --- .../structureMovement/TranslatingContraption.java | 10 ++++++++++ .../structureMovement/pulley/PulleyTileEntity.java | 3 +-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java index 062be299c..3f605dbb7 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/TranslatingContraption.java @@ -7,6 +7,7 @@ import java.util.Set; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IWorld; import net.minecraft.world.World; import net.minecraft.world.gen.feature.template.Template.BlockInfo; @@ -38,6 +39,15 @@ public abstract class TranslatingContraption extends Contraption { return cachedColliders; } + @Override + public void removeBlocksFromWorld(IWorld world, BlockPos offset) { + int count = blocks.size(); + super.removeBlocksFromWorld(world, offset); + if (count != blocks.size()) { + cachedColliders = null; + } + } + @Override protected boolean canAxisBeStabilized(Axis axis) { return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java index 44e2335e9..a416edadc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyTileEntity.java @@ -81,8 +81,7 @@ public class PulleyTileEntity extends LinearActuatorTileEntity { world.setBlockState(offset, Blocks.AIR.getDefaultState(), 66); } - if (contraption != null && !contraption.getBlocks() - .isEmpty()) { + if (!contraption.getBlocks().isEmpty()) { contraption.removeBlocksFromWorld(world, BlockPos.ZERO); movedContraption = ControlledContraptionEntity.create(world, this, contraption); movedContraption.setPosition(anchor.getX(), anchor.getY(), anchor.getZ());