From 6440b0c89708c9ac51f885c455a1f60732bf2199 Mon Sep 17 00:00:00 2001 From: M-W-K Date: Sun, 8 Sep 2024 22:24:21 -0600 Subject: [PATCH] min length tubes --- .../renderer/pipe/cache/BlockableSQC.java | 21 +++++++++++++++++-- .../renderer/pipe/cache/RestrictiveSQC.java | 9 ++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/main/java/gregtech/client/renderer/pipe/cache/BlockableSQC.java b/src/main/java/gregtech/client/renderer/pipe/cache/BlockableSQC.java index fea9003c5ad..3f759abcb6b 100644 --- a/src/main/java/gregtech/client/renderer/pipe/cache/BlockableSQC.java +++ b/src/main/java/gregtech/client/renderer/pipe/cache/BlockableSQC.java @@ -12,7 +12,10 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; +import org.apache.commons.lang3.tuple.ImmutablePair; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.lwjgl.util.vector.Vector3f; import java.util.EnumMap; import java.util.List; @@ -34,13 +37,27 @@ protected BlockableSQC(PipeQuadHelper helper, SpriteInformation endTex, SpriteIn public static @NotNull BlockableSQC create(PipeQuadHelper helper, SpriteInformation endTex, SpriteInformation sideTex, SpriteInformation blockedTex) { - helper.initialize((facing, x1, y1, z1, x2, y2, z2) -> QuadHelper.tubeOverlay(facing, x1, y1, z1, x2, y2, z2, - OVERLAY_DIST_1)); + helper.initialize((facing, x1, y1, z1, x2, y2, z2) -> minLengthTube(facing, x1, y1, z1, x2, y2, z2, + OVERLAY_DIST_1, 4)); BlockableSQC cache = new BlockableSQC(helper, endTex, sideTex, blockedTex); cache.buildPrototype(); return cache; } + public static ImmutablePair minLengthTube(@Nullable EnumFacing facing, float x1, float y1, + float z1, float x2, + float y2, float z2, float g, float minLength) { + if (facing == null) return QuadHelper.tubeOverlay(facing, x1, y1, z1, x2, y2, z2, g); + return switch (facing) { + case UP -> QuadHelper.tubeOverlay(facing, x1, Math.min(y1, y2 - minLength), z1, x2, y2, z2, g); + case DOWN -> QuadHelper.tubeOverlay(facing, x1, y1, z1, x2, Math.max(y2, y1 + minLength), z2, g); + case EAST -> QuadHelper.tubeOverlay(facing, Math.min(x1, x2 - minLength), y1, z1, x2, y2, z2, g); + case WEST -> QuadHelper.tubeOverlay(facing, x1, y1, z1, Math.max(x2, x1 + minLength), y2, z2, g); + case SOUTH -> QuadHelper.tubeOverlay(facing, x1, y1, Math.min(z1, z2 - minLength), x2, y2, z2, g); + case NORTH -> QuadHelper.tubeOverlay(facing, x1, y1, z1, x2, y2, Math.max(z2, z1 + minLength), g); + }; + } + @Override protected List buildPrototypeInternal() { List quads = super.buildPrototypeInternal(); diff --git a/src/main/java/gregtech/client/renderer/pipe/cache/RestrictiveSQC.java b/src/main/java/gregtech/client/renderer/pipe/cache/RestrictiveSQC.java index 91a08988745..8d986a0323e 100644 --- a/src/main/java/gregtech/client/renderer/pipe/cache/RestrictiveSQC.java +++ b/src/main/java/gregtech/client/renderer/pipe/cache/RestrictiveSQC.java @@ -3,7 +3,6 @@ import gregtech.api.util.GTUtility; import gregtech.client.renderer.pipe.quad.ColorData; import gregtech.client.renderer.pipe.quad.PipeQuadHelper; -import gregtech.client.renderer.pipe.quad.QuadHelper; import gregtech.client.renderer.pipe.quad.RecolorableBakedQuad; import gregtech.client.renderer.pipe.util.SpriteInformation; @@ -36,10 +35,10 @@ protected RestrictiveSQC(PipeQuadHelper helper, SpriteInformation endTex, Sprite SpriteInformation sideTex, SpriteInformation blockedTex, SpriteInformation restrictiveTex) { helper.initialize( - (facing, x1, y1, z1, x2, y2, z2) -> QuadHelper.tubeOverlay(facing, x1, y1, z1, x2, y2, z2, - OVERLAY_DIST_2), - (facing, x1, y1, z1, x2, y2, z2) -> QuadHelper.tubeOverlay(facing, x1, y1, z1, x2, y2, z2, - OVERLAY_DIST_1)); + (facing, x1, y1, z1, x2, y2, z2) -> minLengthTube(facing, x1, y1, z1, x2, y2, z2, + OVERLAY_DIST_2, 4), + (facing, x1, y1, z1, x2, y2, z2) -> minLengthTube(facing, x1, y1, z1, x2, y2, z2, + OVERLAY_DIST_1, 2)); RestrictiveSQC sqc = new RestrictiveSQC(helper, endTex, sideTex, blockedTex, restrictiveTex); sqc.buildPrototype(); return sqc;