From e5b29e3352caf7e79ac3853b0c84244ad060f6c8 Mon Sep 17 00:00:00 2001 From: George Paton Date: Wed, 27 Aug 2025 13:12:01 +1000 Subject: [PATCH 1/4] fix transparent pixel issue in wiki icon screenshitter --- .../inventory/gui/GUIScreenWikiRender.java | 93 ++++++++++--------- 1 file changed, 50 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java b/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java index 900e4e9b6..a183812dc 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java @@ -26,12 +26,12 @@ import net.minecraft.util.ResourceLocation; public class GUIScreenWikiRender extends GuiScreen { - // Basically the same thing as GUIScreenPreview, but will iterate through all provided preview stacks - // taking a screenshot of each, as fast as the game can render them + // Basically the same thing as GUIScreenPreview, but will iterate through all provided preview stacks + // taking a screenshot of each, as fast as the game can render them protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/nei/gui_nei.png"); protected ItemStack[] preview; - protected int index = 0; + protected int index = 0; protected int scale = 1; protected String saveLocation = "wiki-screenshots"; protected String prefix = ""; @@ -52,7 +52,7 @@ public class GUIScreenWikiRender extends GuiScreen { this.getStackName = getStackName; } - @Override + @Override public void drawScreen(int mouseX, int mouseY, float f) { if(this.mc.theWorld != null) { GuiScreen.drawRect(0, 0, this.width, this.height, 0xFFC6C6C6); @@ -60,57 +60,64 @@ public class GUIScreenWikiRender extends GuiScreen { this.drawBackground(0); } - // Once we've reached the end of the array, immedaitely close this GUI - if(index >= preview.length) { - this.mc.thePlayer.closeScreen(); - return; - } - + // Once we've reached the end of the array, immedaitely close this GUI + if(index >= preview.length) { + this.mc.thePlayer.closeScreen(); + return; + } + this.drawGuiContainerBackgroundLayer(); GL11.glDisable(GL11.GL_LIGHTING); this.drawGuiContainerForegroundLayer(preview[index]); GL11.glEnable(GL11.GL_LIGHTING); - + ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); int zoom = scale * res.getScaleFactor(); - try { - String slotName = getStackName.apply(preview[index]).replaceAll("§.", "").replaceAll("[^\\w ().-]+", ""); - if(!slotName.endsWith(".name")) { - saveScreenshot(Minecraft.getMinecraft().mcDataDir, saveLocation, prefix + slotName + ".png", zoom, zoom, zoom * 16, zoom * 16, 0xFF8B8B8B); - } - } catch (Exception ex) { - // Just skip any failures caused by display name or rendering - } + try { + String slotName = getStackName.apply(preview[index]).replaceAll("§.", "").replaceAll("[^\\w ().-]+", ""); + if(!slotName.endsWith(".name")) { + saveScreenshot(Minecraft.getMinecraft().mcDataDir, saveLocation, prefix + slotName + ".png", zoom, zoom, zoom * 16, zoom * 16, 0xFFFF00FF); + } + } catch (Exception ex) { + // Just skip any failures caused by display name or rendering + } - index++; - } + index++; + } protected void drawGuiContainerBackgroundLayer() { GL11.glPushMatrix(); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.mc.getTextureManager().bindTexture(texture); - ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - GL11.glScaled(scale, scale, scale); - this.drawTexturedModalRect(0, res.getScaledHeight_double() / scale - 18D, 5, 87, 18, 18); - GL11.glPopMatrix(); - } + { - public void drawTexturedModalRect(double x, double y, int sourceX, int sourceY, int sizeX, int sizeY) { - double f = 0.00390625D; - double f1 = 0.00390625D; - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertexWithUV((double) (x + 0), (double) (y + sizeY), (double) this.zLevel, (double) ((float) (sourceX + 0) * f), (double) ((float) (sourceY + sizeY) * f1)); - tessellator.addVertexWithUV((double) (x + sizeX), (double) (y + sizeY), (double) this.zLevel, (double) ((float) (sourceX + sizeX) * f), (double) ((float) (sourceY + sizeY) * f1)); - tessellator.addVertexWithUV((double) (x + sizeX), (double) (y + 0), (double) this.zLevel, (double) ((float) (sourceX + sizeX) * f), (double) ((float) (sourceY + 0) * f1)); - tessellator.addVertexWithUV((double) (x + 0), (double) (y + 0), (double) this.zLevel, (double) ((float) (sourceX + 0) * f), (double) ((float) (sourceY + 0) * f1)); - tessellator.draw(); + ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); + + int size = 18; + double y = res.getScaledHeight_double() / scale - 18D; + + GL11.glScaled(scale, scale, scale); + + GL11.glColor4f(1.0F, 0.0F, 1.0F, 1.0F); + GL11.glDisable(GL11.GL_TEXTURE_2D); + + Tessellator tessellator = Tessellator.instance; + tessellator.startDrawingQuads(); + tessellator.addVertex((double) 0, (double) y + size, (double) this.zLevel); + tessellator.addVertex((double) size, (double) y + size, (double) this.zLevel); + tessellator.addVertex((double) size, (double) y, (double) this.zLevel); + tessellator.addVertex((double) 0, (double) y, (double) this.zLevel); + tessellator.draw(); + + GL11.glEnable(GL11.GL_TEXTURE_2D); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + + } + GL11.glPopMatrix(); } protected void drawGuiContainerForegroundLayer(ItemStack preview) { if(preview == null) return; - + GL11.glPushMatrix(); RenderHelper.enableGUIStandardItemLighting(); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240F, 240F); @@ -119,11 +126,11 @@ public class GUIScreenWikiRender extends GuiScreen { GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); - + GL11.glScaled(scale, scale, scale); - + ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - GL11.glTranslated(9D, res.getScaledHeight_double() / scale - 9D, -200); + GL11.glTranslated(9D, res.getScaledHeight_double() / scale - 9D, -200); this.zLevel = 200.0F; itemRender.zLevel = 200.0F; @@ -134,7 +141,7 @@ public class GUIScreenWikiRender extends GuiScreen { itemRender.zLevel = 0.0F; this.zLevel = 0.0F; - + GL11.glPopMatrix(); } From a00034787769fbf55972db0190c539ad524428fc Mon Sep 17 00:00:00 2001 From: George Paton Date: Wed, 27 Aug 2025 13:38:43 +1000 Subject: [PATCH 2/4] yeah I was overcomplicating that, this is much better --- .../inventory/gui/GUIScreenWikiRender.java | 37 +------------------ 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java b/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java index a183812dc..42b3c6b49 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java @@ -19,7 +19,6 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.TextureUtil; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -54,11 +53,7 @@ public class GUIScreenWikiRender extends GuiScreen { @Override public void drawScreen(int mouseX, int mouseY, float f) { - if(this.mc.theWorld != null) { - GuiScreen.drawRect(0, 0, this.width, this.height, 0xFFC6C6C6); - } else { - this.drawBackground(0); - } + GuiScreen.drawRect(0, 0, this.width, this.height, 0xFFFF00FF); // Once we've reached the end of the array, immedaitely close this GUI if(index >= preview.length) { @@ -66,7 +61,6 @@ public class GUIScreenWikiRender extends GuiScreen { return; } - this.drawGuiContainerBackgroundLayer(); GL11.glDisable(GL11.GL_LIGHTING); this.drawGuiContainerForegroundLayer(preview[index]); GL11.glEnable(GL11.GL_LIGHTING); @@ -86,35 +80,6 @@ public class GUIScreenWikiRender extends GuiScreen { index++; } - protected void drawGuiContainerBackgroundLayer() { - GL11.glPushMatrix(); - { - - ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - - int size = 18; - double y = res.getScaledHeight_double() / scale - 18D; - - GL11.glScaled(scale, scale, scale); - - GL11.glColor4f(1.0F, 0.0F, 1.0F, 1.0F); - GL11.glDisable(GL11.GL_TEXTURE_2D); - - Tessellator tessellator = Tessellator.instance; - tessellator.startDrawingQuads(); - tessellator.addVertex((double) 0, (double) y + size, (double) this.zLevel); - tessellator.addVertex((double) size, (double) y + size, (double) this.zLevel); - tessellator.addVertex((double) size, (double) y, (double) this.zLevel); - tessellator.addVertex((double) 0, (double) y, (double) this.zLevel); - tessellator.draw(); - - GL11.glEnable(GL11.GL_TEXTURE_2D); - GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - } - GL11.glPopMatrix(); - } - protected void drawGuiContainerForegroundLayer(ItemStack preview) { if(preview == null) return; From c978fa8955c6eddddce0f8d1e995ea626264fadb Mon Sep 17 00:00:00 2001 From: George Paton Date: Thu, 28 Aug 2025 15:01:39 +1000 Subject: [PATCH 3/4] PWR printing device, exports a built PWR as a series of slices to be edited together for posting --- .../blocks/machine/MachinePWRController.java | 2 + .../inventory/gui/GUIScreenSlicePrinter.java | 127 +++++++++++++ .../inventory/gui/GUIScreenWikiRender.java | 2 +- src/main/java/com/hbm/items/ModItems.java | 33 ++-- .../com/hbm/items/machine/ItemPWRPrinter.java | 173 ++++++++++++++++++ .../machine/TileEntityPWRController.java | 20 +- src/main/resources/assets/hbm/lang/en_US.lang | 1 + .../assets/hbm/textures/items/pwr_printer.png | Bin 0 -> 433 bytes 8 files changed, 341 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java create mode 100644 src/main/java/com/hbm/items/machine/ItemPWRPrinter.java create mode 100644 src/main/resources/assets/hbm/textures/items/pwr_printer.png diff --git a/src/main/java/com/hbm/blocks/machine/MachinePWRController.java b/src/main/java/com/hbm/blocks/machine/MachinePWRController.java index 0d27ea490..61b9930dc 100644 --- a/src/main/java/com/hbm/blocks/machine/MachinePWRController.java +++ b/src/main/java/com/hbm/blocks/machine/MachinePWRController.java @@ -4,6 +4,7 @@ import com.hbm.blocks.ITooltipProvider; import com.hbm.blocks.ModBlocks; import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR; import com.hbm.handler.threading.PacketThreading; +import com.hbm.items.ModItems; import com.hbm.lib.RefStrings; import com.hbm.main.MainRegistry; import com.hbm.packet.toclient.AuxParticlePacketNT; @@ -80,6 +81,7 @@ public class MachinePWRController extends BlockContainer implements ITooltipProv if(!controller.assembled) { assemble(world, x, y, z, player); } else { + if(player.getHeldItem() != null && player.getHeldItem().getItem() == ModItems.pwr_printer) return false; FMLNetworkHandler.openGui(player, MainRegistry.instance, 0, world, x, y, z); } diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java b/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java new file mode 100644 index 000000000..f26624082 --- /dev/null +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenSlicePrinter.java @@ -0,0 +1,127 @@ +package com.hbm.inventory.gui; + +import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashSet; + +import org.lwjgl.opengl.GL11; + +import com.hbm.blocks.machine.BlockPWR; +import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR; + +import net.minecraft.block.Block; +import net.minecraft.client.gui.GuiScreen; +import net.minecraft.client.renderer.RenderBlocks; +import net.minecraft.client.renderer.Tessellator; +import net.minecraft.client.renderer.texture.TextureMap; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatComponentText; + +public class GUIScreenSlicePrinter extends GuiScreen { + + private final int x1, y1, z1; + private final int x2, y2, z2; + private final int sizeX, sizeY, sizeZ; + + private HashSet whitelist; + + private int yIndex; + + private RenderBlocks renderer; + + 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) { + this.x1 = Math.min(x1, x2); + this.y1 = Math.min(y1, y2); + this.z1 = Math.min(z1, z2); + this.x2 = Math.max(x1, x2); + this.y2 = Math.max(y1, y2); + this.z2 = Math.max(z1, z2); + + this.sizeX = this.x2 - this.x1 + 1; + this.sizeY = this.y2 - this.y1 + 1; + this.sizeZ = this.z2 - this.z1 + 1; + + 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); + this.whitelist = whitelist; + } + + @Override + public void drawScreen(int mouseX, int mouseY, float f) { + if(renderer == null) { + this.renderer = new RenderBlocks(mc.theWorld); + } + + GuiScreen.drawRect(0, 0, width, height, 0xFFFF00FF); + + // Once we've reached the top slice, close the GUI + if(yIndex >= sizeY) { + mc.thePlayer.addChatMessage(new ChatComponentText("Slices saved to: .minecraft/printer/" + dirname)); + mc.thePlayer.closeScreen(); + return; + } + + GL11.glPushMatrix(); + { + + setupRotation(); + + mc.getTextureManager().bindTexture(TextureMap.locationBlocksTexture); + GL11.glShadeModel(GL11.GL_SMOOTH); + Tessellator.instance.startDrawingQuads(); + + for(int x = 0; x < sizeX; x++) { + for(int z = 0; z < sizeZ; z++) { + Block block = mc.theWorld.getBlock(x1 + x, y1 + yIndex, z1 + z); + if(whitelist != null && !whitelist.contains(block)) continue; + + // Revert PWR blocks to originals for slice rendering + if(block instanceof BlockPWR) { + TileEntity tile = mc.theWorld.getTileEntity(x1 + x, y1 + yIndex, z1 + z); + if(tile instanceof TileEntityBlockPWR) { + TileEntityBlockPWR pwr = (TileEntityBlockPWR) tile; + if(pwr.block != null) { + block = pwr.block; + } + } + } + + renderer.renderBlockByRenderType(block, x, 0, z); + } + } + + Tessellator.instance.draw(); + GL11.glShadeModel(GL11.GL_FLAT); + + } + GL11.glPopMatrix(); + + File printerDir = new File(mc.mcDataDir, "printer"); + printerDir.mkdir(); + + GUIScreenWikiRender.saveScreenshot(printerDir, dirname, "slice_" + yIndex + ".png", 0, 0, mc.displayWidth, mc.displayHeight, 0xFFFF00FF); + + yIndex++; + } + + private void setupRotation() { + double scale = -24; + + GL11.glTranslated(width / 2, height / 2 - 36, 400); + GL11.glScaled(scale, scale, scale); + GL11.glScaled(1, 1, 0.5); //incredible flattening power + + GL11.glRotated(-30, 1, 0, 0); + GL11.glRotated(-45, 0, 1, 0); + GL11.glTranslated(sizeX / -2D, -sizeY / 2D, sizeZ / -2D); + } + +} diff --git a/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java b/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java index 42b3c6b49..576f3bdf7 100644 --- a/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java +++ b/src/main/java/com/hbm/inventory/gui/GUIScreenWikiRender.java @@ -116,7 +116,7 @@ public class GUIScreenWikiRender extends GuiScreen { // This implementation is based directly on ScreenShotHelper.saveScreenshot() // But allows for defining a rect where you want to sample pixels from - private static void saveScreenshot(File dataDir, String ssDir, String fileName, int x, int y, int width, int height, int transparentColor) { + public static void saveScreenshot(File dataDir, String ssDir, String fileName, int x, int y, int width, int height, int transparentColor) { try { File screenshotDirectory = new File(dataDir, ssDir); screenshotDirectory.mkdir(); diff --git a/src/main/java/com/hbm/items/ModItems.java b/src/main/java/com/hbm/items/ModItems.java index f04a7218f..0bd86628a 100644 --- a/src/main/java/com/hbm/items/ModItems.java +++ b/src/main/java/com/hbm/items/ModItems.java @@ -64,7 +64,7 @@ import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidStack; public class ModItems { - + public static HashSet excludeNEI = new HashSet(); public static void mainRegistry() { @@ -645,7 +645,7 @@ public class ModItems { public static Item seg_10; public static Item seg_15; public static Item seg_20; - + public static Item combine_scrap; public static Item shimmer_head; @@ -1035,6 +1035,7 @@ public class ModItems { public static Item pwr_fuel; public static Item pwr_fuel_hot; public static Item pwr_fuel_depleted; + public static Item pwr_printer; public static Item rbmk_lid; public static Item rbmk_lid_glass; @@ -1476,7 +1477,7 @@ public class ModItems { public static Item gun_aberrator_eott; public static Item gun_double_barrel; public static Item gun_double_barrel_sacred_dragon; - + public static Item gun_charge_thrower; public static Item ammo_standard; @@ -2072,7 +2073,7 @@ public class ModItems { public static Item hazmat_paa_boots; public static Item rebar_placer; - + public static Item wand; public static Item wand_s; public static Item wand_d; @@ -2234,7 +2235,7 @@ public class ModItems { public static Item conveyor_wand; public static void initializeItem() { - + redstone_sword = new RedstoneSword(ToolMaterial.STONE).setUnlocalizedName("redstone_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":redstone_sword"); big_sword = new BigSword(ToolMaterial.EMERALD).setUnlocalizedName("big_sword").setCreativeTab(CreativeTabs.tabCombat).setTextureName(RefStrings.MODID + ":big_sword"); @@ -2966,7 +2967,7 @@ public class ModItems { gas_full = new ItemGasTank().setUnlocalizedName("gas_full").setCreativeTab(MainRegistry.controlTab).setContainerItem(ModItems.gas_empty).setTextureName(RefStrings.MODID + ":gas_empty"); ItemSimpleConsumable.init(); - + //TODO: move all this crap to ItemSimpleConsumable syringe_empty = new Item().setUnlocalizedName("syringe_empty").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_empty"); syringe_metal_empty = new Item().setUnlocalizedName("syringe_metal_empty").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_empty"); @@ -2976,7 +2977,7 @@ public class ModItems { syringe_metal_super = new ItemSyringe().setUnlocalizedName("syringe_metal_super").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_metal_super"); syringe_taint = new ItemSyringe().setUnlocalizedName("syringe_taint").setFull3D().setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":syringe_taint"); syringe_mkunicorn = new ItemSyringe().setUnlocalizedName("syringe_mkunicorn").setFull3D().setCreativeTab(null).setTextureName(RefStrings.MODID + ":syringe_mkunicorn"); - + med_bag = new ItemSyringe().setUnlocalizedName("med_bag").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":med_bag"); radx = new ItemPill(0).setUnlocalizedName("radx").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":radx"); siox = new ItemPill(0).setUnlocalizedName("siox").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":siox"); @@ -3181,6 +3182,7 @@ public class ModItems { pwr_fuel = new ItemPWRFuel().setUnlocalizedName("pwr_fuel").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel"); pwr_fuel_hot = new ItemEnumMulti(EnumPWRFuel.class, true, false).setUnlocalizedName("pwr_fuel_hot").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel_hot"); pwr_fuel_depleted = new ItemEnumMulti(EnumPWRFuel.class, true, false).setUnlocalizedName("pwr_fuel_depleted").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_fuel_depleted"); + pwr_printer = new ItemPWRPrinter().setUnlocalizedName("pwr_printer").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":pwr_printer"); rbmk_lid = new ItemRBMKLid().setUnlocalizedName("rbmk_lid").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid"); rbmk_lid_glass = new ItemRBMKLid().setUnlocalizedName("rbmk_lid_glass").setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":rbmk_lid_glass"); @@ -4512,7 +4514,7 @@ public class ModItems { .addAbility(IToolHarvestAbility.SMELTER, 0) .addAbility(IToolHarvestAbility.SILK, 0) .addAbility(IToolHarvestAbility.LUCK, 2).setUnlocalizedName("cmb_pickaxe").setTextureName(RefStrings.MODID + ":cmb_pickaxe"); - + cmb_axe = new ItemToolAbility(30F, 0, MainRegistry.tMatCMB, EnumToolType.AXE) .addAbility(IToolAreaAbility.RECURSION, 2) .addAbility(IToolHarvestAbility.SMELTER, 0) @@ -4537,7 +4539,7 @@ public class ModItems { .addAbility(IToolAreaAbility.RECURSION, 2) .addAbility(IToolHarvestAbility.SILK, 0) .addAbility(IToolHarvestAbility.LUCK, 1).setUnlocalizedName("elec_pickaxe").setTextureName(RefStrings.MODID + ":elec_drill_anim"); - + elec_axe = new ItemToolAbilityPower(10F, 0, MainRegistry.tMatElec, EnumToolType.AXE, 500000, 1000, 100) .addAbility(IToolAreaAbility.HAMMER, 1) .addAbility(IToolAreaAbility.HAMMER_FLAT, 1) @@ -4546,14 +4548,14 @@ public class ModItems { .addAbility(IToolHarvestAbility.LUCK, 1) .addAbility(IWeaponAbility.CHAINSAW, 0) .addAbility(IWeaponAbility.BEHEADER, 0).setShears().setUnlocalizedName("elec_axe").setTextureName(RefStrings.MODID + ":elec_chainsaw_anim"); - + elec_shovel = new ItemToolAbilityPower(5F, 0, MainRegistry.tMatElec, EnumToolType.SHOVEL, 500000, 1000, 100) .addAbility(IToolAreaAbility.HAMMER, 1) .addAbility(IToolAreaAbility.HAMMER_FLAT, 1) .addAbility(IToolAreaAbility.RECURSION, 2) .addAbility(IToolHarvestAbility.SILK, 0) .addAbility(IToolHarvestAbility.LUCK, 1).setUnlocalizedName("elec_shovel").setTextureName(RefStrings.MODID + ":elec_shovel_anim"); - + desh_sword = new ItemSwordAbility(12.5F, 0, MainRegistry.tMatDesh) .addAbility(IWeaponAbility.STUN, 0).setUnlocalizedName("desh_sword").setTextureName(RefStrings.MODID + ":desh_sword"); @@ -4563,7 +4565,7 @@ public class ModItems { .addAbility(IToolAreaAbility.RECURSION, 0) .addAbility(IToolHarvestAbility.SILK, 0) .addAbility(IToolHarvestAbility.LUCK, 1).setUnlocalizedName("desh_pickaxe").setTextureName(RefStrings.MODID + ":desh_pickaxe"); - + desh_axe = new ItemToolAbility(7.5F, -0.05, MainRegistry.tMatDesh, EnumToolType.AXE) .addAbility(IToolAreaAbility.HAMMER, 0) .addAbility(IToolAreaAbility.HAMMER_FLAT, 0) @@ -4978,9 +4980,9 @@ public class ModItems { } private static void registerItem() { - + excludeNEI.add(item_secret); - + //Weapons GameRegistry.registerItem(redstone_sword, redstone_sword.getUnlocalizedName()); GameRegistry.registerItem(big_sword, big_sword.getUnlocalizedName()); @@ -5687,7 +5689,7 @@ public class ModItems { GameRegistry.registerItem(fluid_barrel_empty, fluid_barrel_empty.getUnlocalizedName()); GameRegistry.registerItem(fluid_barrel_full, fluid_barrel_full.getUnlocalizedName()); GameRegistry.registerItem(fluid_barrel_infinite, fluid_barrel_infinite.getUnlocalizedName()); - + //Packaged fluids GameRegistry.registerItem(fluid_pack_empty, fluid_pack_empty.getUnlocalizedName()); GameRegistry.registerItem(fluid_pack_full, fluid_pack_full.getUnlocalizedName()); @@ -5994,6 +5996,7 @@ public class ModItems { GameRegistry.registerItem(pwr_fuel, pwr_fuel.getUnlocalizedName()); GameRegistry.registerItem(pwr_fuel_hot, pwr_fuel_hot.getUnlocalizedName()); GameRegistry.registerItem(pwr_fuel_depleted, pwr_fuel_depleted.getUnlocalizedName()); + GameRegistry.registerItem(pwr_printer, pwr_printer.getUnlocalizedName()); //RBMK parts GameRegistry.registerItem(rbmk_lid, rbmk_lid.getUnlocalizedName()); diff --git a/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java b/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java new file mode 100644 index 000000000..d7c3f5ee7 --- /dev/null +++ b/src/main/java/com/hbm/items/machine/ItemPWRPrinter.java @@ -0,0 +1,173 @@ +package com.hbm.items.machine; + +import java.util.HashSet; +import java.util.List; + +import com.hbm.blocks.ModBlocks; +import com.hbm.blocks.machine.BlockPWR; +import com.hbm.blocks.machine.BlockPWR.TileEntityBlockPWR; +import com.hbm.inventory.gui.GUIScreenSlicePrinter; +import com.hbm.main.MainRegistry; +import com.hbm.tileentity.IGUIProvider; +import com.hbm.tileentity.machine.TileEntityPWRController; +import com.hbm.util.fauxpointtwelve.BlockPos; + +import cpw.mods.fml.common.network.internal.FMLNetworkHandler; +import io.netty.buffer.ByteBuf; +import net.minecraft.block.Block; +import net.minecraft.client.Minecraft; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; + +public class ItemPWRPrinter extends Item implements IGUIProvider { + + private static int x1, y1, z1; + private static int x2, y2, z2; + private static Block[] blockSync; + + private HashSet fill = new HashSet<>(); + private static HashSet whitelist = new HashSet() {{ + add(ModBlocks.pwr_block); + add(ModBlocks.pwr_controller); + }}; + + // Piggybacking functions using the bytebuf TE sync + public static void serialize(World world, ByteBuf buf) { + buf.writeInt(x1); + buf.writeInt(y1); + buf.writeInt(z1); + buf.writeInt(x2); + buf.writeInt(y2); + buf.writeInt(z2); + + for(Block block : blockSync) { + buf.writeInt(Block.getIdFromBlock(block)); + } + + blockSync = null; + } + + public static void deserialize(World world, ByteBuf buf) { + x1 = buf.readInt(); + y1 = buf.readInt(); + z1 = buf.readInt(); + x2 = buf.readInt(); + y2 = buf.readInt(); + z2 = buf.readInt(); + + for(int x = x1; x <= x2; x++) { + for(int y = y1; y <= y2; y++) { + for(int z = z1; z <= z2; z++) { + Block block = Block.getBlockById(buf.readInt()); + + TileEntity tile = world.getTileEntity(x, y, z); + if(!(tile instanceof TileEntityBlockPWR)) continue; + ((TileEntityBlockPWR) tile).block = block; + } + } + } + + System.out.println("oh wow it synced and attempted to GUI!"); + + // Open the printer GUI on any client players holding the printer + // yeah it's a shit hack yay weee wooo + EntityPlayer player = Minecraft.getMinecraft().thePlayer; + if(player != null && player.getHeldItem() != null && player.getHeldItem().getItem() instanceof ItemPWRPrinter) { + FMLNetworkHandler.openGui(Minecraft.getMinecraft().thePlayer, MainRegistry.instance, 0, world, 0, 0, 0); + } + + } + + @Override + public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int i, float f0, float f1, float f2) { + TileEntity tile = world.getTileEntity(x, y, z); + if(!(tile instanceof TileEntityPWRController)) return false; + if(world.isRemote) return true; + + TileEntityPWRController pwr = (TileEntityPWRController) tile; + syncAndScreenshot(world, pwr); + + return true; + } + + public void syncAndScreenshot(World world, TileEntityPWRController pwr) { + findBounds(world, pwr); + + int sizeX = x2 - x1 + 1; + int sizeY = y2 - y1 + 1; + int sizeZ = z2 - z1 + 1; + + blockSync = new Block[sizeX * sizeY * sizeZ]; + int i = 0; + + for(int x = x1; x <= x2; x++) { + for(int y = y1; y <= y2; y++) { + for(int z = z1; z <= z2; z++) { + TileEntity tile = world.getTileEntity(x, y, z); + if(tile instanceof TileEntityBlockPWR) { + blockSync[i] = ((TileEntityBlockPWR) tile).block; + } + i++; + } + } + } + + pwr.isPrinting = true; + } + + public void findBounds(World world, TileEntityPWRController pwr) { + ForgeDirection dir = ForgeDirection.getOrientation(world.getBlockMetadata(pwr.xCoord, pwr.yCoord, pwr.zCoord)).getOpposite(); + + fill.clear(); + fill.add(new BlockPos(pwr.xCoord, pwr.yCoord, pwr.zCoord)); + x1 = x2 = pwr.xCoord; + y1 = y2 = pwr.yCoord; + z1 = z2 = pwr.zCoord; + floodFill(world, pwr.xCoord + dir.offsetX, pwr.yCoord, pwr.zCoord + dir.offsetZ); + } + + public void floodFill(World world, int x, int y, int z) { + BlockPos pos = new BlockPos(x, y, z); + if(fill.contains(pos)) return; + + if(world.getBlock(x, y, z) instanceof BlockPWR) { + fill.add(pos); + + x1 = Math.min(x1, x); + y1 = Math.min(y1, y); + z1 = Math.min(z1, z); + x2 = Math.max(x2, x); + y2 = Math.max(y2, y); + z2 = Math.max(z2, z); + + floodFill(world, x + 1, y, z); + floodFill(world, x - 1, y, z); + floodFill(world, x, y + 1, z); + floodFill(world, x, y - 1, z); + floodFill(world, x, y, z + 1); + floodFill(world, x, y, z - 1); + } + } + + @Override + public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { + return null; + } + + @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); + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean bool) { + list.add("Use on a constructed PWR controller to generate construction diagrams"); + } + +} diff --git a/src/main/java/com/hbm/tileentity/machine/TileEntityPWRController.java b/src/main/java/com/hbm/tileentity/machine/TileEntityPWRController.java index 653ec66ca..1cff1e6e5 100644 --- a/src/main/java/com/hbm/tileentity/machine/TileEntityPWRController.java +++ b/src/main/java/com/hbm/tileentity/machine/TileEntityPWRController.java @@ -12,12 +12,13 @@ import com.hbm.inventory.container.ContainerPWR; import com.hbm.inventory.fluid.Fluids; import com.hbm.inventory.fluid.tank.FluidTank; import com.hbm.inventory.fluid.trait.FT_Heatable; -import com.hbm.inventory.fluid.trait.FT_PWRModerator; import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingStep; import com.hbm.inventory.fluid.trait.FT_Heatable.HeatingType; +import com.hbm.inventory.fluid.trait.FT_PWRModerator; import com.hbm.inventory.gui.GUIPWR; import com.hbm.items.ModItems; import com.hbm.items.machine.ItemPWRFuel.EnumPWRFuel; +import com.hbm.items.machine.ItemPWRPrinter; import com.hbm.main.MainRegistry; import com.hbm.sound.AudioWrapper; import com.hbm.tileentity.IGUIProvider; @@ -375,8 +376,17 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG return this.rodCount + (int) Math.ceil(this.heatsinkCount / 4D); } + public boolean isPrinting; + @Override public void serialize(ByteBuf buf) { + buf.writeBoolean(isPrinting); + if(isPrinting) { + ItemPWRPrinter.serialize(worldObj, buf); + isPrinting = false; + return; + } + super.serialize(buf); buf.writeInt(this.rodCount); buf.writeLong(this.coreHeat); @@ -395,6 +405,14 @@ public class TileEntityPWRController extends TileEntityMachineBase implements IG @Override public void deserialize(ByteBuf buf) { + if(buf.readBoolean()) { + // piggybacking off of this packet so that we don't have to sync EVERY PWR + // block continuously to the client for one tiny screenshot tool + + ItemPWRPrinter.deserialize(worldObj, buf); + return; + } + super.deserialize(buf); this.rodCount = buf.readInt(); this.coreHeat = buf.readLong(); diff --git a/src/main/resources/assets/hbm/lang/en_US.lang b/src/main/resources/assets/hbm/lang/en_US.lang index e772302f4..1ce70f12f 100644 --- a/src/main/resources/assets/hbm/lang/en_US.lang +++ b/src/main/resources/assets/hbm/lang/en_US.lang @@ -4013,6 +4013,7 @@ item.pwr_fuel_hot.men.name=Hot MEN PWR Fuel Rod item.pwr_fuel_hot.mep.name=Hot MEP PWR Fuel Rod item.pwr_fuel_hot.meu.name=Hot MEU PWR Fuel Rod item.pwr_fuel_hot.mox.name=Hot MOX PWR Fuel Rod +item.pwr_printer.name=PWR Printer item.quartz_plutonium.name=Plutonic Quartz item.radar_linker.name=Radar Linker item.radaway.name=RadAway diff --git a/src/main/resources/assets/hbm/textures/items/pwr_printer.png b/src/main/resources/assets/hbm/textures/items/pwr_printer.png new file mode 100644 index 0000000000000000000000000000000000000000..a79ce1f2448d16a8180250315274362c2f06fef2 GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jPK-BC>eK@{Ea{HEjtmSN z`?>!lvI6-E$sR$z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8ZKG z?e4;$2!aJHjZQ!j&H|6fVg?4j10c+pb*+;VD9B#o>Fdh=l0$~YOvL&9x*I^DubwWB zAr_~T6C_w89M4{!_5a3?7mq9&J0@JKH#avgOR+QR<(W|+`RVm_eYFzjjVljl9{B$L z{?EiW=I_@TDqTLo;C$fTz3=wSK%guv%*@U%e)xNS{DT}eHn%oob^QerN17JhJow(; z+M0dN|M&Of*~<9*+W!ClZ~W))@Aik+&&%`J*Z)y_(;6>$k*8``5f3|mPKrfEg7RTo zYj?I<+e)^k#1HaPKF5s@JxH>z|Chq?r+`1bXQ9M_6CD?}#5r_6e13jD4+x}h$(2;| zpVxDh!R-q}%JT;zopr0C*Rjv;Y7A literal 0 HcmV?d00001 From a636440d136300f12ccbbfb0b4eb833ab3dcd26f Mon Sep 17 00:00:00 2001 From: George Paton Date: Thu, 28 Aug 2025 15:47:22 +1000 Subject: [PATCH 4/4] 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" })