From db51dd1d3d1723dd6716826000ace27a6fd80f2f Mon Sep 17 00:00:00 2001 From: xieve Date: Sun, 26 Mar 2023 15:08:04 +0200 Subject: [PATCH] Implemented ITransformableBlock for Fluid Pipes --- .../fluids/pipes/FluidPipeBlock.java | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java index 4b7c21137..b7d167a48 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/fluids/pipes/FluidPipeBlock.java @@ -7,6 +7,8 @@ import javax.annotation.Nullable; import com.simibubi.create.AllBlocks; import com.simibubi.create.AllTileEntities; +import com.simibubi.create.content.contraptions.components.structureMovement.ITransformableBlock; +import com.simibubi.create.content.contraptions.components.structureMovement.StructureTransform; import com.simibubi.create.content.contraptions.fluids.FluidPropagator; import com.simibubi.create.content.contraptions.fluids.FluidTransportBehaviour; import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileEntityBehaviour; @@ -53,7 +55,7 @@ import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.ticks.TickPriority; public class FluidPipeBlock extends PipeBlock - implements SimpleWaterloggedBlock, IWrenchableWithBracket, ITE, EncasableBlock { + implements SimpleWaterloggedBlock, IWrenchableWithBracket, ITE, EncasableBlock, ITransformableBlock { private static final VoxelShape OCCLUSION_BOX = Block.box(4, 4, 4, 12, 12, 12); @@ -357,4 +359,21 @@ public class FluidPipeBlock extends PipeBlock } return mirrored; } + + @Override + public BlockState transform(BlockState state, StructureTransform transform) { + if (transform.mirror != null) { + state = mirror(state, transform.mirror); + } + + if (transform.rotationAxis == Direction.Axis.Y) { + return rotate(state, transform.rotation); + } + + BlockState rotated = state; + for (Direction direction : Iterate.directionsInAxis(transform.rotationAxis)) { + rotated = rotated.setValue(PROPERTY_BY_DIRECTION.get(transform.rotateFacing(direction)), state.getValue(PROPERTY_BY_DIRECTION.get(direction))); + } + return rotated; + } }