From b0a84a9bc125acbe3b83ce0ab820f1180a4385e9 Mon Sep 17 00:00:00 2001 From: reidbhuntley Date: Sun, 23 May 2021 15:08:43 -0400 Subject: [PATCH] Fix breaking piston pole making piston base unusable --- .../piston/LinearActuatorTileEntity.java | 7 ++++++- .../piston/PistonExtensionPoleBlock.java | 13 +++++++++++-- .../structureMovement/pulley/PulleyBlock.java | 12 ++++++------ 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java index 6cb418ec2..300f17aab 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/LinearActuatorTileEntity.java @@ -288,6 +288,11 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity } } + public void onLengthBroken() { + offset = 0; + sendData(); + } + @Override public boolean isValid() { return !isRemoved(); @@ -311,4 +316,4 @@ public abstract class LinearActuatorTileEntity extends KineticTileEntity public BlockPos getBlockPosition() { return pos; } -} \ No newline at end of file +} diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java index b88ef5c3a..d42563d24 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/piston/PistonExtensionPoleBlock.java @@ -9,6 +9,7 @@ import java.util.function.Predicate; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonBlock.PistonState; +import com.simibubi.create.content.contraptions.components.structureMovement.pulley.PulleyTileEntity; import com.simibubi.create.content.contraptions.wrench.IWrenchable; import com.simibubi.create.foundation.block.ProperDirectionalBlock; import com.simibubi.create.foundation.utility.placement.IPlacementHelper; @@ -29,6 +30,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.pathfinding.PathType; import net.minecraft.state.StateContainer.Builder; import net.minecraft.state.properties.BlockStateProperties; +import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; @@ -71,7 +73,7 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements public boolean isToolEffective(BlockState state, ToolType tool) { return tool == ToolType.AXE || tool == ToolType.PICKAXE; } - + @Override public PushReaction getPushReaction(BlockState state) { return PushReaction.NORMAL; @@ -117,6 +119,13 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements .forEach(p -> worldIn.destroyBlock(p, !player.isCreative())); worldIn.setBlockState(basePos, worldIn.getBlockState(basePos) .with(MechanicalPistonBlock.STATE, PistonState.RETRACTED)); + + TileEntity te = worldIn.getTileEntity(basePos); + if (te instanceof MechanicalPistonTileEntity) { + MechanicalPistonTileEntity baseTE = (MechanicalPistonTileEntity) te; + baseTE.offset = 0; + baseTE.onLengthBroken(); + } } super.onBlockHarvested(worldIn, pos, state, player); @@ -168,7 +177,7 @@ public class PistonExtensionPoleBlock extends ProperDirectionalBlock implements } return state; } - + @Override public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) { return false; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java index 2aa7b6d13..8ec99fff0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/PulleyBlock.java @@ -43,11 +43,11 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE