From a636440d136300f12ccbbfb0b4eb833ab3dcd26f Mon Sep 17 00:00:00 2001 From: George Paton Date: Thu, 28 Aug 2025 15:47:22 +1000 Subject: [PATCH] rotate to always show controller at bottom right --- .../blocks/machine/MachinePWRController.java | 2 +- .../inventory/gui/GUIScreenSlicePrinter.java | 25 ++++++++++++++++--- .../com/hbm/items/machine/ItemPWRPrinter.java | 7 ++++-- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/hbm/blocks/machine/MachinePWRController.java b/src/main/java/com/hbm/blocks/machine/MachinePWRController.java index 61b9930dc..68007db4d 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePWRController.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePWRController.java @@ -56,7 +56,7 @@ public class MachinePWRController extends BlockContainer implements ITooltipProv @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int side, int metadata) { - return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon); + return metadata == 0 && side != 0 && side != 1 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon); } @Override diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java b/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java index f26624082..915f99b1c 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java @@ -18,12 +18,14 @@ import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ChatComponentText; +import net.minecraftforge.common.util.ForgeDirection; public class GUIScreenSlicePrinter extends GuiScreen { private final int x1, y1, z1; private final int x2, y2, z2; private final int sizeX, sizeY, sizeZ; + private final ForgeDirection dir; private HashSet whitelist; @@ -34,7 +36,7 @@ public class GUIScreenSlicePrinter extends GuiScreen { private String dirname; private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); - public GUIScreenSlicePrinter(int x1, int y1, int z1, int x2, int y2, int z2) { + public GUIScreenSlicePrinter(int x1, int y1, int z1, int x2, int y2, int z2, ForgeDirection dir) { this.x1 = Math.min(x1, x2); this.y1 = Math.min(y1, y2); this.z1 = Math.min(z1, z2); @@ -42,6 +44,8 @@ public class GUIScreenSlicePrinter extends GuiScreen { this.y2 = Math.max(y1, y2); this.z2 = Math.max(z1, z2); + this.dir = dir; + this.sizeX = this.x2 - this.x1 + 1; this.sizeY = this.y2 - this.y1 + 1; this.sizeZ = this.z2 - this.z1 + 1; @@ -49,8 +53,8 @@ public class GUIScreenSlicePrinter extends GuiScreen { dirname = dateFormat.format(new Date()).toString(); } - public GUIScreenSlicePrinter(int x1, int y1, int z1, int x2, int y2, int z2, HashSet whitelist) { - this(x1, y1, z1, x2, y2, z2); + public GUIScreenSlicePrinter(int x1, int y1, int z1, int x2, int y2, int z2, ForgeDirection dir, HashSet whitelist) { + this(x1, y1, z1, x2, y2, z2, dir); this.whitelist = whitelist; } @@ -121,7 +125,20 @@ public class GUIScreenSlicePrinter extends GuiScreen { GL11.glRotated(-30, 1, 0, 0); GL11.glRotated(-45, 0, 1, 0); - GL11.glTranslated(sizeX / -2D, -sizeY / 2D, sizeZ / -2D); + + if(dir == ForgeDirection.WEST) { + GL11.glRotated(180, 0, 1, 0); + } else if(dir == ForgeDirection.NORTH) { + GL11.glRotated(-90, 0, 1, 0); + } else if(dir == ForgeDirection.SOUTH) { + GL11.glRotated(90, 0, 1, 0); + } + + if(dir == ForgeDirection.WEST || dir == ForgeDirection.EAST) { + GL11.glTranslated(sizeX / -2D, -sizeY / 2D, sizeZ / -2D); + } else { + GL11.glTranslated(sizeZ / -2D, -sizeY / 2D, sizeX / -2D); + } } } diff --git a/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java b/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java index d7c3f5ee7..1ef5ec736 100644 --- a/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java +++ b/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java @@ -29,6 +29,7 @@ public class ItemPWRPrinter extends Item implements IGUIProvider { private static int x1, y1, z1; private static int x2, y2, z2; private static Block[] blockSync; + private static ForgeDirection dir; private HashSet fill = new HashSet<>(); private static HashSet whitelist = new HashSet() {{ @@ -44,6 +45,7 @@ public class ItemPWRPrinter extends Item implements IGUIProvider { buf.writeInt(x2); buf.writeInt(y2); buf.writeInt(z2); + buf.writeInt(dir.ordinal()); for(Block block : blockSync) { buf.writeInt(Block.getIdFromBlock(block)); @@ -59,6 +61,7 @@ public class ItemPWRPrinter extends Item implements IGUIProvider { x2 = buf.readInt(); y2 = buf.readInt(); z2 = buf.readInt(); + dir = ForgeDirection.values()[buf.readInt()]; for(int x = x1; x <= x2; x++) { for(int y = y1; y <= y2; y++) { @@ -121,7 +124,7 @@ public class ItemPWRPrinter extends Item implements IGUIProvider { } public void findBounds(World world, TileEntityPWRController pwr) { - ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(pwr.xCoord, pwr.yCoord, pwr.zCoord)).getOpposite(); + dir = ForgeDirection.getOrientation(world.getBlockMetadata(pwr.xCoord, pwr.yCoord, pwr.zCoord)).getOpposite(); fill.clear(); fill.add(new BlockPos(pwr.xCoord, pwr.yCoord, pwr.zCoord)); @@ -161,7 +164,7 @@ public class ItemPWRPrinter extends Item implements IGUIProvider { @Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { - return new GUIScreenSlicePrinter(x1, y1, z1, x2, y2, z2, whitelist); + return new GUIScreenSlicePrinter(x1, y1, z1, x2, y2, z2, dir, whitelist); } @SuppressWarnings({ "unchecked", "rawtypes" })