From 53242df6bc7c7e177368a9640f4595b7f7fc966e Mon Sep 17 00:00:00 2001 From: sevenc-nanashi Date: Thu, 12 Jun 2025 19:53:00 +0900 Subject: [PATCH] fix: check canConnect when trying to connect to another pipe --- .../alexiil/mc/mod/pipes/pipe/PartSpPipe.java | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/main/java/alexiil/mc/mod/pipes/pipe/PartSpPipe.java b/src/main/java/alexiil/mc/mod/pipes/pipe/PartSpPipe.java index 894701b..19383ce 100644 --- a/src/main/java/alexiil/mc/mod/pipes/pipe/PartSpPipe.java +++ b/src/main/java/alexiil/mc/mod/pipes/pipe/PartSpPipe.java @@ -90,7 +90,7 @@ public class PartSpPipe extends AbstractPart implements ISimplePipe { ID_FLOW = NET_PARENT.idData("flow").toClientOnly(); ID_FLOW.setReceiver(PartSpPipe::receiveFlow); } - + public static void load() { // force the static initializer to run } @@ -174,18 +174,16 @@ public ItemStack getPickStack(@Nullable BlockHitResult hitResult) { @Environment(EnvType.CLIENT) protected void spawnBreakParticles() { spawnBreakParticles( - Blocks.STONE.getDefaultState(), - PipeBaseModelGenStandard.getCenterSprite(SpriteSupplier.NO_CONTEXT_SUPPLIER, definition) - ); + Blocks.STONE.getDefaultState(), + PipeBaseModelGenStandard.getCenterSprite(SpriteSupplier.NO_CONTEXT_SUPPLIER, definition)); } @Override @Environment(EnvType.CLIENT) public boolean spawnHitParticle(Direction side) { spawnHitParticle( - side, Blocks.STONE.getDefaultState(), - PipeBaseModelGenStandard.getCenterSprite(SpriteSupplier.NO_CONTEXT_SUPPLIER, definition) - ); + side, Blocks.STONE.getDefaultState(), + PipeBaseModelGenStandard.getCenterSprite(SpriteSupplier.NO_CONTEXT_SUPPLIER, definition)); return true; } @@ -200,10 +198,8 @@ public void addAllAttributes(AttributeList list) { } VoxelShape pipeShape = isConnected(pipeSide) ? FACE_CENTER_SHAPES[pipeSide.ordinal()] : CENTER_SHAPE; - if ( - definition.isExtraction && behaviour instanceof PipeSpBehaviourSided - && ((PipeSpBehaviourSided) behaviour).currentDirection() == pipeSide - ) { + if (definition.isExtraction && behaviour instanceof PipeSpBehaviourSided + && ((PipeSpBehaviourSided) behaviour).currentDirection() == pipeSide) { list.offer(getFlow().getInsertable(list.getSearchDirection()), pipeShape); } else { list.offer(definition.getEmptyExtractable(), pipeShape); @@ -241,7 +237,10 @@ private void updateConnections() { if (definition.isExtraction && oPipe != null && oPipe.getDefinition().isExtraction) { disconnect(dir); } else if (oPipe != null) { - if ((getFlow() instanceof PipeSpFlowItem) == (oPipe.getFlow() instanceof PipeSpFlowItem)) { + if ((getFlow() instanceof PipeSpFlowItem) == (oPipe.getFlow() instanceof PipeSpFlowItem) && + canConnect(dir) && + (!(oPipe instanceof PartSpPipe) + || ((PartSpPipe) oPipe).canConnect(dir.getOpposite()))) { connect(dir); } else { disconnect(dir); @@ -361,7 +360,8 @@ private void transformConnections(DirectionTransformation transform) { public void refreshModel() { if (holder.getContainer().isClientWorld()) { - // This can be called on the server too, but this way everything's done with a single packet + // This can be called on the server too, but this way everything's done with a + // single packet redrawIfChanged(); } else { sendNetworkUpdate(this, NET_RENDER_DATA);