Fix breaking piston pole making piston base unusable

This commit is contained in:
reidbhuntley 2021-05-23 15:08:43 -04:00
parent 5ec8312322
commit b0a84a9bc1
3 changed files with 23 additions and 9 deletions

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -43,11 +43,11 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<Pulle
private static void onRopeBroken(World world, BlockPos pulleyPos) {
TileEntity te = world.getTileEntity(pulleyPos);
if (!(te instanceof PulleyTileEntity))
return;
PulleyTileEntity pulley = (PulleyTileEntity) te;
pulley.offset = 0;
pulley.sendData();
if (te instanceof PulleyTileEntity) {
PulleyTileEntity pulley = (PulleyTileEntity) te;
pulley.initialOffset = 0;
pulley.onLengthBroken();
}
}
@Override
@ -98,7 +98,7 @@ public class PulleyBlock extends HorizontalAxisKineticBlock implements ITE<Pulle
super(properties);
setDefaultState(super.getDefaultState().with(BlockStateProperties.WATERLOGGED, false));
}
@Override
public boolean allowsMovement(BlockState state, IBlockReader reader, BlockPos pos, PathType type) {
return false;