aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/gui/widgets
diff options
context:
space:
mode:
authorJason Mitchell <mitchej@gmail.com>2023-04-22 22:33:35 -0700
committerGitHub <noreply@github.com>2023-04-23 07:33:35 +0200
commit56f2269f4af6d2130bdb2b6e6ac6e13bce89e47b (patch)
tree745e6d92025ec4ef449fc59fa5fdd741200b0489 /src/main/java/gregtech/api/gui/widgets
parentac0b7a7da46646d325def36eed811941dbfc5950 (diff)
downloadGT5-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/api/gui/widgets')
-rw-r--r--src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java33
1 files changed, 18 insertions, 15 deletions
diff --git a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java
index 9694316bee..890e6298c9 100644
--- a/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java
+++ b/src/main/java/gregtech/api/gui/widgets/GT_GuiCoverTabLine.java
@@ -8,6 +8,7 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
+import net.minecraftforge.common.util.ForgeDirection;
import org.lwjgl.opengl.GL11;
@@ -66,10 +67,10 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
* Add a tab for each existing cover on this IGregTechTileEntity at creation time
*/
private void setupTabs() {
- for (byte tSide = 0; tSide < 6; tSide++) {
- final ItemStack cover = tile.getCoverItemAtSide(tSide);
+ for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
+ final ItemStack cover = tile.getCoverItemAtSide(side);
if (cover != null) {
- addCoverToTabs(tSide, cover);
+ addCoverToTabs(side, cover);
}
}
}
@@ -101,26 +102,27 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
/**
* Add the cover on this side of the IGregTechTileEntity to the tabs
- *
+ *
* @param side
* @param cover
*/
- private void addCoverToTabs(byte side, ItemStack cover) {
+ private void addCoverToTabs(ForgeDirection side, ItemStack cover) {
final boolean enabled = this.tile.getCoverBehaviorAtSideNew(side)
.hasCoverGUI();
- this.setTab(side, cover, null, getTooltipForCoverTab(side, cover, enabled));
- this.setTabEnabled(side, enabled);
+ final int ordinalSide = side.ordinal();
+ this.setTab(ordinalSide, cover, null, getTooltipForCoverTab(side, cover, enabled));
+ this.setTabEnabled(ordinalSide, enabled);
}
/**
* Decorate the cover's tooltips according to the side it's on and on whether the tab is enabled or not
- *
+ *
* @param side
* @param cover
* @param enabled
* @return This cover tab's tooltip
*/
- private String[] getTooltipForCoverTab(byte side, ItemStack cover, boolean enabled) {
+ private String[] getTooltipForCoverTab(ForgeDirection side, ItemStack cover, boolean enabled) {
final List<String> tooltip = cover.getTooltip(Minecraft.getMinecraft().thePlayer, true);
tooltip.set(
0,
@@ -132,16 +134,17 @@ public class GT_GuiCoverTabLine extends GT_GuiTabLine {
/**
* Get the translated name for a side of the IGregTechTileEntity
- *
+ *
* @param side
* @return translated name for a side of the IGregTechTileEntity
*/
- private String getSideDescription(byte side) {
- if (side < SIDES.length) {
- if (this.translatedSides[side] == null) {
- this.translatedSides[side] = StatCollector.translateToLocal(SIDES[side]);
+ private String getSideDescription(ForgeDirection side) {
+ final int ordinalSide = side.ordinal();
+ if (ordinalSide < SIDES.length) {
+ if (this.translatedSides[ordinalSide] == null) {
+ this.translatedSides[ordinalSide] = StatCollector.translateToLocal(SIDES[ordinalSide]);
}
- return this.translatedSides[side];
+ return this.translatedSides[ordinalSide];
}
return null;
}