Skip to content

Commit

Permalink
min length tubes
Browse files Browse the repository at this point in the history
  • Loading branch information
M-W-K committed Sep 9, 2024
1 parent 90d40b6 commit 6440b0c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Vector3f, Vector3f> 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<RecolorableBakedQuad> buildPrototypeInternal() {
List<RecolorableBakedQuad> quads = super.buildPrototypeInternal();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 6440b0c

Please sign in to comment.