diff options
| author | Jason Mitchell <mitchej@gmail.com> | 2023-04-22 22:33:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-23 07:33:35 +0200 |
| commit | 56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b (patch) | |
| tree | 745e6d92025ec4ef449fc59fa5fdd741200b0489 /src/main/java/gregtech/common/tileentities/machines/long_distance | |
| parent | ac0b7a7da46646d325def36eed811941dbfc5950 (diff) | |
| download | GT5-Unofficial-56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b.tar.gz GT5-Unofficial-56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b.tar.bz2 GT5-Unofficial-56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b.zip | |
Forge direction (#1895)
* ForgeDirection
Also refactor the clusterfuck that was `getCoordinateScan`
Co-authored by: Jason Mitchell <mitchej@gmail.com>
* Fix rendering of Frame Boxes
Frame boxes needed their own implementation of getTexture with int connexion mask,
which is returning an error texture for the MetaTileEntity, because pipes (FrameBox
**is** a pipe) do use this method to return different textures based on connexion
status.
---------
Co-authored-by: Léa Gris <lea.gris@noiraude.net>
Diffstat (limited to 'src/main/java/gregtech/common/tileentities/machines/long_distance')
3 files changed, 37 insertions, 36 deletions
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 b868d151f2..70270996f3 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 @@ -279,11 +279,11 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta + Math.abs(getBaseMetaTileEntity().getZCoord() - aCoords.posZ); } - public ChunkCoordinates getFacingOffset(IGregTechTileEntity gt_tile, byte aSide) { + public ChunkCoordinates getFacingOffset(IGregTechTileEntity gt_tile, ForgeDirection side) { return new ChunkCoordinates( - gt_tile.getOffsetX(aSide, 1), - gt_tile.getOffsetY(aSide, 1), - gt_tile.getOffsetZ(aSide, 1)); + gt_tile.getOffsetX(side, 1), + gt_tile.getOffsetY(side, 1), + gt_tile.getOffsetZ(side, 1)); } public ChunkCoordinates getCoords() { @@ -312,12 +312,11 @@ public abstract class GT_MetaTileEntity_LongDistancePipelineBase extends GT_Meta public void getWailaBody(ItemStack itemStack, List<String> currentTip, IWailaDataAccessor accessor, IWailaConfigHandler config) { final NBTTagCompound tag = accessor.getNBTData(); - final int facing = getBaseMetaTileEntity().getFrontFacing(); - final int side = (byte) accessor.getSide() - .ordinal(); + final ForgeDirection facing = getBaseMetaTileEntity().getFrontFacing(); + final ForgeDirection side = accessor.getSide(); if (side == facing) currentTip.add(GOLD + "Pipeline Input" + RESET); - else if (side == ForgeDirection.OPPOSITES[facing]) currentTip.add(BLUE + "Pipeline Output" + 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); 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 6b95d20d5c..11e2680e31 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 @@ -35,7 +35,6 @@ import gregtech.api.interfaces.ITexture; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Utility; public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEntity_LongDistancePipelineBase { @@ -68,33 +67,32 @@ public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEnti } @Override - public FluidTankInfo[] getTankInfo(ForgeDirection aSide) { + public FluidTankInfo[] getTankInfo(ForgeDirection side) { if (checkTarget()) { final IFluidHandler tankTile = getTank(); - if (tankTile != null) return tankTile.getTankInfo(aSide); + if (tankTile != null) return tankTile.getTankInfo(side); } return emptyTank; } @Override - public int fill(ForgeDirection aSide, FluidStack aFluid, boolean aDoFill) { + public int fill(ForgeDirection side, FluidStack aFluid, boolean aDoFill) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); final IFluidHandler tankTile = getTank(); - if (tankTile != null) - return tankTile.fill(ForgeDirection.getOrientation(tTile.getFrontFacing()), aFluid, aDoFill); + if (tankTile != null) return tankTile.fill(tTile.getFrontFacing(), aFluid, aDoFill); } return 0; } @Override - public FluidStack drain(ForgeDirection aSide, FluidStack aFluid, boolean aDoDrain) { + public FluidStack drain(ForgeDirection side, FluidStack aFluid, boolean aDoDrain) { return null; } @Override - public FluidStack drain(ForgeDirection aSide, int aMaxDrain, boolean aDoDrain) { + public FluidStack drain(ForgeDirection side, int aMaxDrain, boolean aDoDrain) { return null; } @@ -109,13 +107,13 @@ public class GT_MetaTileEntity_LongDistancePipelineFluid extends GT_MetaTileEnti } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + 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 (aSide == GT_Utility.getOppositeSide(aFacing)) return new ITexture[] { - MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_FLUID_BACK) }; - else return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + 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) .glow() 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 dc3956d2a6..13cd231183 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 @@ -29,13 +29,13 @@ 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; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; import gregtech.api.interfaces.tileentity.IGregTechTileEntity; import gregtech.api.render.TextureFactory; -import gregtech.api.util.GT_Utility; public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntity_LongDistancePipelineBase { @@ -149,12 +149,13 @@ public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntit // @Override - public int[] getAccessibleSlotsFromSide(int aSide) { + public int[] getAccessibleSlotsFromSide(int ordinalSide) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); final IInventory iInventory = getInventory(); - if (iInventory instanceof ISidedInventory) - return ((ISidedInventory) iInventory).getAccessibleSlotsFromSide(tTile.getFrontFacing()); + if (iInventory instanceof ISidedInventory inv) return inv.getAccessibleSlotsFromSide( + tTile.getFrontFacing() + .ordinal()); if (iInventory != null) { final int[] tReturn = new int[iInventory.getSizeInventory()]; for (int i = 0; i < tReturn.length; i++) tReturn[i] = i; @@ -166,19 +167,22 @@ public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntit } @Override - public boolean canInsertItem(int aSlot, ItemStack aStack, int aSide) { + public boolean canInsertItem(int aSlot, ItemStack aStack, int ordinalSide) { if (checkTarget()) { final IGregTechTileEntity tTile = mTarget.getBaseMetaTileEntity(); IInventory iInventory = getInventory(); - if (iInventory instanceof ISidedInventory) - return ((ISidedInventory) iInventory).canInsertItem(aSlot, aStack, tTile.getFrontFacing()); + if (iInventory instanceof ISidedInventory iSidedInventory) return iSidedInventory.canInsertItem( + aSlot, + aStack, + tTile.getFrontFacing() + .ordinal()); return iInventory != null; } return false; } @Override - public boolean canExtractItem(int aSlot, ItemStack aStack, int aSide) { + public boolean canExtractItem(int aSlot, ItemStack aStack, int ordinalSide) { return false; } @@ -188,13 +192,13 @@ public class GT_MetaTileEntity_LongDistancePipelineItem extends GT_MetaTileEntit } @Override - public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, - boolean aActive, boolean aRedstone) { - if (aSide == aFacing) return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + 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 (aSide == GT_Utility.getOppositeSide(aFacing)) return new ITexture[] { - MACHINE_CASINGS[mTier][aColorIndex + 1], TextureFactory.of(OVERLAY_PIPELINE_ITEM_BACK) }; - else return new ITexture[] { MACHINE_CASINGS[mTier][aColorIndex + 1], + 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) .glow() |
