diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/block/be/PipeBlockEntity.java b/src/main/java/org/violetmoon/quark/addons/oddities/block/be/PipeBlockEntity.java index 41336ea0b5..f75c7568ec 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/block/be/PipeBlockEntity.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/block/be/PipeBlockEntity.java @@ -11,6 +11,7 @@ import java.util.Random; import java.util.function.Predicate; +import net.minecraft.world.level.block.*; import org.jetbrains.annotations.NotNull; import org.joml.Vector3f; import org.violetmoon.quark.addons.oddities.block.pipe.BasePipeBlock; @@ -36,8 +37,6 @@ import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.LevelEvent; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.ChestBlockEntity; import net.minecraft.world.level.block.state.BlockState; @@ -418,7 +417,8 @@ public static ConnectionType computeConnectionTo(BlockGetter world, BlockPos pos private static ConnectionType computeConnectionTo(BlockGetter world, BlockPos pos, Direction face, boolean recursed) { BlockPos truePos = pos.relative(face); - if(world.getBlockState(truePos).getBlock() instanceof WorldlyContainerHolder) + BlockState state = world.getBlockState(truePos); + if(state.getBlock() instanceof WorldlyContainerHolder) return ConnectionType.TERMINAL; BlockEntity tile = world.getBlockEntity(truePos); @@ -427,7 +427,7 @@ private static ConnectionType computeConnectionTo(BlockGetter world, BlockPos po if(tile instanceof PipeBlockEntity) return ConnectionType.PIPE; else if(tile instanceof Container || tile.getCapability(ForgeCapabilities.ITEM_HANDLER, face.getOpposite()).isPresent()) - return tile instanceof ChestBlockEntity ? ConnectionType.TERMINAL_OFFSET : ConnectionType.TERMINAL; + return canHaveOffset(state, pos, world, face) ? ConnectionType.TERMINAL_OFFSET : ConnectionType.TERMINAL; } checkSides: if(!recursed) { @@ -447,6 +447,13 @@ else if(tile instanceof Container || tile.getCapability(ForgeCapabilities.ITEM_H return ConnectionType.NONE; } + private static boolean canHaveOffset(BlockState state, BlockPos pos, BlockGetter world, Direction dir) { + var shape = state.getCollisionShape( world,pos); + if(dir.getAxisDirection() == Direction.AxisDirection.NEGATIVE){ + return shape.max(dir.getAxis())<1; + }else return shape.min(dir.getAxis())>0; + } + public static class PipeItem { private static final String TAG_TICKS = "ticksInPipe"; diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java b/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java index a980091c2a..e462797adc 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/BasePipeBlock.java @@ -158,8 +158,16 @@ public BlockState mirror(@NotNull BlockState state, @NotNull Mirror mirror) { @Override public BlockState updateShape(BlockState state, Direction direction, BlockState neighbor, LevelAccessor level, BlockPos pos, BlockPos neighborPos) { - PipeBlockEntity.ConnectionType type = PipeBlockEntity.computeConnectionTo(level, pos, direction); - state = state.setValue(MiscUtil.directionProperty(direction), allowsFullConnection(type)); + for(var d : Direction.values()) { + // Very ugly. I'm too lazy to figure out a better solution. Checking the given dir would work for normal pipes but not for encased ones + PipeBlockEntity.ConnectionType type = PipeBlockEntity.computeConnectionTo(level, pos, d); + boolean fullConnection = allowsFullConnection(type); + state = state.setValue(MiscUtil.directionProperty(d), fullConnection); + } + // This also shouldn't be here but again gives issues with encased pipes + if(level.getBlockEntity(pos) instanceof PipeBlockEntity tile) { + tile.refreshVisualConnections(); + } return state; } diff --git a/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/EncasedPipeBlock.java b/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/EncasedPipeBlock.java index 9f045ce354..7bd946147c 100644 --- a/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/EncasedPipeBlock.java +++ b/src/main/java/org/violetmoon/quark/addons/oddities/block/pipe/EncasedPipeBlock.java @@ -26,7 +26,7 @@ public EncasedPipeBlock(@Nullable ZetaModule module) { @Override public boolean allowsFullConnection(ConnectionType conn) { - return conn.isFlared || conn.isSolid; + return conn.isSolid || conn.isFlared; } @Override