From 2a6fbf6fa35d2f0767cf4851cdeb1a9d3440425c Mon Sep 17 00:00:00 2001 From: Wilhelm Schuster Date: Thu, 22 Jun 2023 12:49:46 +0200 Subject: Improve Long Distance Pipeline usability and rework textures slightly (#2094) * Improve Long Distance Pipe WAILA status Also addiotional information to the NEI item tooltip * Long Distance Pipeline texture improvements The side textures of the pipeline start/end blocks are now aligned with the axis through the input output face (most visible with the Item Pipeline). This is based on the Buffer texture code. In addition, the input and output face textures have received the typical blue/orange coding found on multiblock hatches and busses. --- ...GT_MetaTileEntity_LongDistancePipelineBase.java | 115 +++++++++++++++++---- ...T_MetaTileEntity_LongDistancePipelineFluid.java | 39 +++---- ...GT_MetaTileEntity_LongDistancePipelineItem.java | 35 ++++--- 3 files changed, 135 insertions(+), 54 deletions(-) (limited to 'src/main/java/gregtech/common/tileentities/machines/long_distance') diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java index 38007baba2..ff3048f4b2 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineBase.java @@ -19,6 +19,7 @@ */ package gregtech.common.tileentities.machines.long_distance; +import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; import static mcp.mobius.waila.api.SpecialChars.BLUE; import static mcp.mobius.waila.api.SpecialChars.GOLD; import static mcp.mobius.waila.api.SpecialChars.GREEN; @@ -57,7 +58,13 @@ import mcp.mobius.waila.api.IWailaDataAccessor; public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_MetaTileEntity_BasicHull_NonElectric { + protected static final int INPUT_INDEX = 0; + protected static final int OUTPUT_INDEX = 1; + protected static final int SIDE_UP_DOWN_INDEX = 2; + protected static final int SIDE_LEFT_RIGHT_INDEX = 3; + public static int minimalDistancePoints = 64; + protected GT_MetaTileEntity_LongDistancePipelineBase mTarget = null; // these two are updated by machine block update thread, so must be volatile protected volatile GT_MetaTileEntity_LongDistancePipelineBase mSender = null; @@ -74,6 +81,13 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta super(aName, aTier, aDescription, aTextures); } + @Override + public String[] getDescription() { + return new String[] { "Only one Input and Output are allowed per pipeline", + "Only Input and Output have to be chunkloaded", "Transfer rate is solely limited by input rate", + "Minimum distance: " + minimalDistancePoints + " blocks" }; + } + @Override public void saveNBTData(NBTTagCompound aNBT) { super.saveNBTData(aNBT); @@ -167,13 +181,13 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta final ChunkCoordinates coords = mSender.getCoords(); aList.addAll( Arrays.asList( - "Is the Target", - "Sender is at: X: " + coords.posX + " Y: " + coords.posY + " Z: " + coords.posZ)); + "Is Pipeline Output", + "Pipeline Input is at: X: " + coords.posX + " Y: " + coords.posY + " Z: " + coords.posZ)); } else { aList.addAll( Arrays.asList( - checkTarget() ? "Has Target" : "Has no loaded Target", - "Target should be around: X: " + mTargetPos.posX + checkTarget() ? "Is connected to Pipeline Output" : "Pipeline Output is not connected/chunkloaded", + "Pipeline Output should be around: X: " + mTargetPos.posX + " Y: " + mTargetPos.posY + " Z: " @@ -222,7 +236,7 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta ChunkCoordinates tCoords; tWires.add(aCoords); - // For each direction, if we haven't already visisted that coordinate, add it to the end of the + // For each direction, if we haven't already visited that coordinate, add it to the end of the // queue if (tVisited.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ))) tQueue.add(tCoords); @@ -292,41 +306,98 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta @Override public void onMachineBlockUpdate() { - // GT_Mod.GT_FML_LOGGER.info("You're dead to me"); mTargetPos = null; mSender = null; } + @Override + public boolean shouldTriggerBlockUpdate() { + return true; + } + + abstract public ITexture[] getTextureOverlays(); + @Override public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; + ITexture[][][] rTextures = new ITexture[4][17][]; + ITexture[] overlays = getTextureOverlays(); + for (int i = 0; i < rTextures[0].length; i++) { + rTextures[INPUT_INDEX][i] = new ITexture[] { MACHINE_CASINGS[mTier][i], overlays[INPUT_INDEX] }; + rTextures[OUTPUT_INDEX][i] = new ITexture[] { MACHINE_CASINGS[mTier][i], overlays[OUTPUT_INDEX] }; + rTextures[SIDE_UP_DOWN_INDEX][i] = new ITexture[] { MACHINE_CASINGS[mTier][i], + overlays[SIDE_UP_DOWN_INDEX] }; + rTextures[SIDE_LEFT_RIGHT_INDEX][i] = new ITexture[] { MACHINE_CASINGS[mTier][i], + overlays[SIDE_LEFT_RIGHT_INDEX] }; + } + return rTextures; } @Override - public boolean shouldTriggerBlockUpdate() { - return true; + public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, + ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { + colorIndex += 1; + if (sideDirection == facingDirection) return mTextures[INPUT_INDEX][colorIndex]; + else if (sideDirection == facingDirection.getOpposite()) return mTextures[OUTPUT_INDEX][colorIndex]; + else { + switch (facingDirection) { + case UP, DOWN -> { + return mTextures[SIDE_UP_DOWN_INDEX][colorIndex]; + } + case NORTH -> { + switch (sideDirection) { + case DOWN, UP -> { + return mTextures[SIDE_UP_DOWN_INDEX][colorIndex]; + } + case EAST, WEST -> { + return mTextures[SIDE_LEFT_RIGHT_INDEX][colorIndex]; + } + default -> {} + } + } + case SOUTH -> { + switch (sideDirection) { + case DOWN, UP -> { + return mTextures[SIDE_UP_DOWN_INDEX][colorIndex]; + } + case EAST, WEST -> { + return mTextures[SIDE_LEFT_RIGHT_INDEX][colorIndex]; + } + default -> {} + } + } + case EAST, WEST -> { + return mTextures[SIDE_LEFT_RIGHT_INDEX][colorIndex]; + } + default -> {} + } + } + return mTextures[INPUT_INDEX][colorIndex]; // dummy } @Override public void getWailaBody(ItemStack itemStack, List currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { - final NBTTagCompound tag = accessor.getNBTData(); final ForgeDirection facing = getBaseMetaTileEntity().getFrontFacing(); final ForgeDirection side = accessor.getSide(); + final NBTTagCompound tag = accessor.getNBTData(); + final boolean hasInput = tag.getBoolean("hasInput"); + final boolean hasInputTooClose = tag.getBoolean("hasInputTooClose"); + final boolean hasOutput = tag.getBoolean("hasOutput"); + final boolean hasOutputTooClose = tag.getBoolean("hasOutputTooClose"); + if (side == facing) currentTip.add(GOLD + "Pipeline Input" + RESET); else if (side == facing.getOpposite()) currentTip.add(BLUE + "Pipeline Output" + RESET); else currentTip.add("Pipeline Side"); - if (tag.getBoolean("hasSender")) currentTip.add("Other End of Input: " + GREEN + "distance" + RESET); - else if (tag.getBoolean("hasTooCloseSender")) - currentTip.add("Other End of Input: " + RED + "too close" + RESET); - else currentTip.add("Other End of Input: " + YELLOW + "cannot found(may need to update other end)" + RESET); + if (!hasInput && !hasInputTooClose && !hasOutput && !hasOutputTooClose) { + currentTip.add(YELLOW + "Not connected" + RESET); + } - if (tag.getBoolean("hasTarget")) currentTip.add("Other End of Output: " + GREEN + "distance" + RESET); - else if (tag.getBoolean("hasTooCloseTarget")) - currentTip.add("Other End of Output: " + RED + "too close" + RESET); - else currentTip.add("Other End of Output: " + YELLOW + "cannot found" + RESET); + if (hasInput) currentTip.add(GREEN + "Connected to " + GOLD + "Input" + RESET); + else if (hasInputTooClose) currentTip.add(RED + "Connected Input too close" + RESET); + else if (hasOutput) currentTip.add(GREEN + "Connected to " + BLUE + "Output" + RESET); + else if (hasOutputTooClose) currentTip.add(RED + "Connected Output too close" + RESET); super.getWailaBody(itemStack, currentTip, accessor, config); } @@ -336,9 +407,9 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta int z) { super.getWailaNBTData(player, tile, tag, world, x, y, z); - tag.setBoolean("hasSender", mSender != null); - tag.setBoolean("hasTooCloseSender", mTooCloseSender != null); - tag.setBoolean("hasTarget", mTarget != null && mTarget != this); - tag.setBoolean("hasTooCloseTarget", mTooCloseTarget != null); + tag.setBoolean("hasInput", mSender != null); + tag.setBoolean("hasInputTooClose", mTooCloseSender != null); + tag.setBoolean("hasOutput", mTarget != null && mTarget != this); + tag.setBoolean("hasOutputTooClose", mTooCloseTarget != null); } } diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java index 11e2680e31..70e295f3ad 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineFluid.java @@ -19,11 +19,12 @@ */ package gregtech.common.tileentities.machines.long_distance; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_BACK; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE_LEFT_RIGHT; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE_LEFT_RIGHT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE_UP_DOWN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_FLUID_SIDE_UP_DOWN_GLOW; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.util.ForgeDirection; @@ -102,21 +103,23 @@ public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEnti } @Override - public ITexture[][][] getTextureSet(ITexture[] aTextures) { - return new ITexture[0][0][0]; - } - - @Override - public ITexture[] getTexture(IGregTechTileEntity baseMetaTileEntity, ForgeDirection sideDirection, - ForgeDirection facingDirection, int colorIndex, boolean active, boolean redstoneLevel) { - if (sideDirection == facingDirection) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(OVERLAY_PIPELINE_FLUID_FRONT) }; - else if (sideDirection == facingDirection.getOpposite()) return new ITexture[] { - MACHINE_CASINGS[mTier][colorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_BACK) }; - else return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(OVERLAY_PIPELINE_FLUID_SIDE), TextureFactory.builder() - .addIcon(OVERLAY_PIPELINE_FLUID_SIDE_GLOW) + public ITexture[] getTextureOverlays() { + ITexture[] overlays = new ITexture[4]; + overlays[INPUT_INDEX] = TextureFactory.of(OVERLAY_PIPELINE_FLUID_FRONT); + overlays[OUTPUT_INDEX] = TextureFactory.of(OVERLAY_PIPELINE_FLUID_BACK); + overlays[SIDE_UP_DOWN_INDEX] = TextureFactory.of( + TextureFactory.of(OVERLAY_PIPELINE_FLUID_SIDE_UP_DOWN), + TextureFactory.builder() + .addIcon(OVERLAY_PIPELINE_FLUID_SIDE_UP_DOWN_GLOW) .glow() - .build() }; + .build()); + overlays[SIDE_LEFT_RIGHT_INDEX] = TextureFactory.of( + TextureFactory.of(OVERLAY_PIPELINE_FLUID_SIDE_LEFT_RIGHT), + TextureFactory.builder() + .addIcon(OVERLAY_PIPELINE_FLUID_SIDE_LEFT_RIGHT_GLOW) + .glow() + .build()); + + return overlays; } } diff --git a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java index 13cd231183..e1510f4d3d 100644 --- a/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java +++ b/src/main/java/gregtech/common/tileentities/machines/long_distance/GT_MetaTileEntity_LongDistancePipelineItem.java @@ -19,17 +19,17 @@ */ package gregtech.common.tileentities.machines.long_distance; -import static gregtech.api.enums.Textures.BlockIcons.MACHINE_CASINGS; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_BACK; import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_FRONT; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE; -import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE_LEFT_RIGHT; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE_LEFT_RIGHT_GLOW; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE_UP_DOWN; +import static gregtech.api.enums.Textures.BlockIcons.OVERLAY_PIPELINE_ITEM_SIDE_UP_DOWN_GLOW; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; -import net.minecraftforge.common.util.ForgeDirection; import gregtech.api.enums.GT_Values; import gregtech.api.interfaces.ITexture; @@ -192,16 +192,23 @@ public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntit } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, ForgeDirection side, - ForgeDirection facingDirection, int colorIndex, boolean aActive, boolean redstoneLevel) { - if (side == facingDirection) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(OVERLAY_PIPELINE_ITEM_FRONT) }; - else if (side == facingDirection.getOpposite()) return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(OVERLAY_PIPELINE_ITEM_BACK) }; - else return new ITexture[] { MACHINE_CASINGS[mTier][colorIndex + 1], - TextureFactory.of(OVERLAY_PIPELINE_ITEM_SIDE), TextureFactory.builder() - .addIcon(OVERLAY_PIPELINE_ITEM_SIDE_GLOW) + public ITexture[] getTextureOverlays() { + ITexture[] overlays = new ITexture[4]; + overlays[INPUT_INDEX] = TextureFactory.of(OVERLAY_PIPELINE_ITEM_FRONT); + overlays[OUTPUT_INDEX] = TextureFactory.of(OVERLAY_PIPELINE_ITEM_BACK); + overlays[SIDE_UP_DOWN_INDEX] = TextureFactory.of( + TextureFactory.of(OVERLAY_PIPELINE_ITEM_SIDE_UP_DOWN), + TextureFactory.builder() + .addIcon(OVERLAY_PIPELINE_ITEM_SIDE_UP_DOWN_GLOW) .glow() - .build() }; + .build()); + overlays[SIDE_LEFT_RIGHT_INDEX] = TextureFactory.of( + TextureFactory.of(OVERLAY_PIPELINE_ITEM_SIDE_LEFT_RIGHT), + TextureFactory.builder() + .addIcon(OVERLAY_PIPELINE_ITEM_SIDE_LEFT_RIGHT_GLOW) + .glow() + .build()); + + return overlays; } } -- cgit