aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/gui/modularui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/gui/modularui')
-rw-r--r--src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java12
-rw-r--r--src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java31
2 files changed, 19 insertions, 24 deletions
diff --git a/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java b/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java
index 62a933cfa6..20586b9c48 100644
--- a/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java
+++ b/src/main/java/gregtech/api/gui/modularui/GT_CoverUIBuildContext.java
@@ -1,6 +1,7 @@
package gregtech.api.gui.modularui;
import net.minecraft.entity.player.EntityPlayer;
+import net.minecraftforge.common.util.ForgeDirection;
import com.gtnewhorizons.modularui.api.screen.UIBuildContext;
import gregtech.api.interfaces.tileentity.ICoverable;
@@ -9,7 +10,7 @@ public class GT_CoverUIBuildContext extends UIBuildContext {
// cover data is not synced to client, while ID is
private final int coverID;
- private final byte side;
+ private final ForgeDirection side;
private final ICoverable tile;
private final boolean anotherWindow;
private final int guiColorization;
@@ -22,8 +23,8 @@ public class GT_CoverUIBuildContext extends UIBuildContext {
* @param anotherWindow If cover UI is shown on top of another window
* @param guiColorization The color used to render machine's GUI
*/
- public GT_CoverUIBuildContext(EntityPlayer player, int coverID, byte side, ICoverable tile, boolean anotherWindow,
- int guiColorization) {
+ public GT_CoverUIBuildContext(EntityPlayer player, int coverID, ForgeDirection side, ICoverable tile,
+ boolean anotherWindow, int guiColorization) {
super(player);
this.coverID = coverID;
this.side = side;
@@ -39,7 +40,8 @@ public class GT_CoverUIBuildContext extends UIBuildContext {
* @param tile Tile this cover is attached to
* @param anotherWindow If cover GUI is shown in opened on top of another window
*/
- public GT_CoverUIBuildContext(EntityPlayer player, int coverID, byte side, ICoverable tile, boolean anotherWindow) {
+ public GT_CoverUIBuildContext(EntityPlayer player, int coverID, ForgeDirection side, ICoverable tile,
+ boolean anotherWindow) {
this(player, coverID, side, tile, anotherWindow, tile.getGUIColorization());
}
@@ -47,7 +49,7 @@ public class GT_CoverUIBuildContext extends UIBuildContext {
return coverID;
}
- public byte getCoverSide() {
+ public ForgeDirection getCoverSide() {
return side;
}
diff --git a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java
index b132f33d63..afa60e5583 100644
--- a/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java
+++ b/src/main/java/gregtech/api/gui/modularui/GT_UIInfos.java
@@ -40,23 +40,16 @@ public class GT_UIInfos {
.of()
.container((player, world, x, y, z) -> {
TileEntity te = world.getTileEntity(x, y, z);
- if (te instanceof ITileWithModularUI) {
- return createTileEntityContainer(
- player,
- ((ITileWithModularUI) te)::createWindow,
- te::markDirty,
- containerConstructor);
+ if (te instanceof ITileWithModularUI mui) {
+ return createTileEntityContainer(player, mui::createWindow, te::markDirty, containerConstructor);
}
return null;
})
.gui(((player, world, x, y, z) -> {
if (!world.isRemote) return null;
TileEntity te = world.getTileEntity(x, y, z);
- if (te instanceof ITileWithModularUI) {
- return createTileEntityGuiContainer(
- player,
- ((ITileWithModularUI) te)::createWindow,
- containerConstructor);
+ if (te instanceof ITileWithModularUI mui) {
+ return createTileEntityGuiContainer(player, mui::createWindow, containerConstructor);
}
return null;
}))
@@ -64,18 +57,17 @@ public class GT_UIInfos {
private static final UIInfo<?, ?> GTTileEntityDefaultUI = GTTileEntityUIFactory.apply(ModularUIContainer::new);
- private static final Map<Byte, UIInfo<?, ?>> coverUI = new HashMap<>();
+ private static final Map<ForgeDirection, UIInfo<?, ?>> coverUI = new HashMap<>();
static {
- for (byte i = 0; i < ForgeDirection.VALID_DIRECTIONS.length; i++) {
- final byte side = i;
+ for (final ForgeDirection side : ForgeDirection.VALID_DIRECTIONS) {
coverUI.put(
side,
UIBuilder.of()
.container((player, world, x, y, z) -> {
final TileEntity te = world.getTileEntity(x, y, z);
if (!(te instanceof ICoverable gtTileEntity)) return null;
- GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side);
+ final GT_CoverBehaviorBase<?> cover = gtTileEntity.getCoverBehaviorAtSideNew(side);
return createCoverContainer(
player,
cover::createWindow,
@@ -116,7 +108,7 @@ public class GT_UIInfos {
/**
* Opens cover UI, created by {@link GT_CoverBehaviorBase#createWindow}.
*/
- public static void openCoverUI(ICoverable tileEntity, EntityPlayer player, byte side) {
+ public static void openCoverUI(ICoverable tileEntity, EntityPlayer player, ForgeDirection side) {
if (tileEntity.isClientSide()) return;
GT_Values.NW.sendToPlayer(
@@ -167,8 +159,8 @@ public class GT_UIInfos {
}
private static ModularUIContainer createCoverContainer(EntityPlayer player,
- Function<GT_CoverUIBuildContext, ModularWindow> windowCreator, Runnable onWidgetUpdate, int coverID, byte side,
- ICoverable tile) {
+ Function<GT_CoverUIBuildContext, ModularWindow> windowCreator, Runnable onWidgetUpdate, int coverID,
+ ForgeDirection side, ICoverable tile) {
final GT_CoverUIBuildContext buildContext = new GT_CoverUIBuildContext(player, coverID, side, tile, false);
final ModularWindow window = windowCreator.apply(buildContext);
if (window == null) return null;
@@ -177,7 +169,8 @@ public class GT_UIInfos {
@SideOnly(Side.CLIENT)
private static ModularGui createCoverGuiContainer(EntityPlayer player,
- Function<GT_CoverUIBuildContext, ModularWindow> windowCreator, int coverID, byte side, ICoverable tile) {
+ Function<GT_CoverUIBuildContext, ModularWindow> windowCreator, int coverID, ForgeDirection side,
+ ICoverable tile) {
final ModularUIContainer container = createCoverContainer(player, windowCreator, null, coverID, side, tile);
if (container == null) {
return null;