From 5444f57cade5b04a92dea47fc81cee5a8bfc2b68 Mon Sep 17 00:00:00 2001 From: Boblet Date: Mon, 11 Aug 2025 11:14:06 +0200 Subject: [PATCH] the glunch --- changelog | 23 +------ src/main/java/com/hbm/calc/EasyLocation.java | 14 ----- src/main/java/com/hbm/calc/Location.java | 33 ---------- src/main/java/com/hbm/qmaw/GuiQMAW.java | 58 +++++++++++++++++- src/main/java/com/hbm/qmaw/ManualElement.java | 2 +- src/main/java/com/hbm/qmaw/QMAWLoader.java | 7 ++- .../hbm/qmaw/components/QComponentLink.java | 7 ++- .../hbm/qmaw/components/QComponentText.java | 3 +- .../network/TileEntityConverterHeRf.java | 7 ++- .../assets/hbm/textures/gui/gui_wiki.png | Bin 1017 -> 1258 bytes 10 files changed, 74 insertions(+), 80 deletions(-) delete mode 100644 src/main/java/com/hbm/calc/EasyLocation.java delete mode 100644 src/main/java/com/hbm/calc/Location.java diff --git a/changelog b/changelog index 95f85136d..9e379b53c 100644 --- a/changelog +++ b/changelog @@ -1,23 +1,2 @@ -## Added -* QMAW (quick manual and wiki) - * It's a simple ingame manual that can be found by pressing F1 on items (like the WIAJ presentations) - * Supports text and links and not much else - * Easy to make entries for, the system scans `assets/manual` for valid `.json` format files - * Should also work in resource packs (no recent tests for that, not going to make promises) - * Still WIP, many new info pages are yet to be made -* `/ntmlocate` - * Finds structures - * Only works on the new component structures, the old crusty ones like the factors and powerplant aren't supported - ## Changed -* Updated chinese and russian localization -* All the never completed missile parts (20/20 fuselage, 20 warhead, 10 and 15 tec kerosene thrusters) have been removed -* The electric arc furnace now scrapes the vanilla furnace recipe list on server start in addition to postinit, making sure recipes added during postinit after NTM loads (like Thermal's ingots) are covered too -* The shredder's sound will now start immediately when processing instead of with random delay -* The assembly machine can now make nuclear waste into barrels -* Capacitors now have OpenComputers integration - -## Fixed -* Fixed GT6 compatibility watz pellets crashing due to misconfigured recipes -* Removed failed attempt at fixing the gun desync dupe which made things worse -* Fixed a potential crash regarding structure blocks \ No newline at end of file +* QMAW now has buttons for returning to previously viewed pages \ No newline at end of file diff --git a/src/main/java/com/hbm/calc/EasyLocation.java b/src/main/java/com/hbm/calc/EasyLocation.java deleted file mode 100644 index 8e4755c1b..000000000 --- a/src/main/java/com/hbm/calc/EasyLocation.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.hbm.calc; - -public class EasyLocation { - - public double posX; - public double posY; - public double posZ; - - public EasyLocation(double x, double y, double z) { - posX = x; - posY = y; - posZ = z; - } -} diff --git a/src/main/java/com/hbm/calc/Location.java b/src/main/java/com/hbm/calc/Location.java deleted file mode 100644 index 6c1d7235d..000000000 --- a/src/main/java/com/hbm/calc/Location.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.hbm.calc; - -import net.minecraft.tileentity.TileEntity; -import net.minecraft.world.World; -import net.minecraftforge.common.util.ForgeDirection; - -public class Location { - - public int x; - public int y; - public int z; - public World world; - - public Location(World world, int x, int y, int z) { - this.world = world; - this.x = x; - this.y = y; - this.z = z; - } - - public Location add(int xa, int ya, int za) { - return new Location(world, x + xa, y + ya, z + za); - } - - public Location add(ForgeDirection dir) { - return add(dir.offsetX, dir.offsetY, dir.offsetZ); - } - - public TileEntity getTileEntity() { - return world.getTileEntity(x, y, z); - } - -} diff --git a/src/main/java/com/hbm/qmaw/GuiQMAW.java b/src/main/java/com/hbm/qmaw/GuiQMAW.java index b4d60c42b..c59834957 100644 --- a/src/main/java/com/hbm/qmaw/GuiQMAW.java +++ b/src/main/java/com/hbm/qmaw/GuiQMAW.java @@ -3,13 +3,16 @@ package com.hbm.qmaw; import java.util.ArrayList; import java.util.List; +import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; import com.hbm.lib.RefStrings; import com.hbm.qmaw.components.*; +import cpw.mods.fml.common.FMLCommonHandler; import net.minecraft.client.Minecraft; +import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.resources.LanguageManager; @@ -22,8 +25,12 @@ public class GuiQMAW extends GuiScreen { protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_wiki.png"); public String title; + public String qmawID; public ItemStack icon; public List> lines = new ArrayList(); + /** History for returning via button */ + public List back = new ArrayList(); + public List forward = new ArrayList(); protected int xSize = 340; protected int ySize = 224; @@ -38,6 +45,7 @@ public class GuiQMAW extends GuiScreen { public static final String EN_US = "en_US"; public GuiQMAW(QuickManualAndWiki qmaw) { + qmawID = qmaw.name; parseQMAW(qmaw); } @@ -163,6 +171,43 @@ public class GuiQMAW extends GuiScreen { this.lastClickX = x; this.lastClickY = y; } + + if(guiLeft + 3 <= x && guiLeft + 3 + 18 > x && guiTop + 3 < y && guiTop + 3 + 18 >= y) back(); + if(guiLeft + 21 <= x && guiLeft + 21 + 18 > x && guiTop + 3 < y && guiTop + 3 + 18 >= y) forward(); + } + + public void back() { + if(this.back.isEmpty()) return; + + String prev = back.get(back.size() - 1); + + QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(prev); + if(qmaw != null) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + GuiQMAW screen = new GuiQMAW(qmaw); + screen.back.addAll(back); + screen.back.remove(screen.back.size() - 1); + screen.forward.addAll(forward); + screen.forward.add(qmawID); + FMLCommonHandler.instance().showGuiScreen(screen); + } + } + + public void forward() { + if(this.forward.isEmpty()) return; + + String next = forward.get(forward.size() - 1); + + QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(next); + if(qmaw != null) { + Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); + GuiQMAW screen = new GuiQMAW(qmaw); + screen.back.addAll(back); + screen.back.add(qmawID); + screen.forward.addAll(forward); + screen.forward.remove(screen.forward.size() - 1); + FMLCommonHandler.instance().showGuiScreen(screen); + } } public int getSliderPosition() { @@ -213,7 +258,7 @@ public class GuiQMAW extends GuiScreen { private void drawGuiContainerForegroundLayer(int mouseX, int mouseY) { - int x = 7; + int x = 43; int y = 4; if(this.icon != null) { @@ -242,7 +287,11 @@ public class GuiQMAW extends GuiScreen { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(texture); drawTexturedModalRect(guiLeft, guiTop, 0, 0, 170, ySize); - drawTexturedModalRect(guiLeft + 170, guiTop, 22, 0, 170, ySize); + drawTexturedModalRect(guiLeft + 170, guiTop, 52, 0, 30, ySize); + drawTexturedModalRect(guiLeft + 200, guiTop, 52, 0, 140, ySize); + + if(!back.isEmpty()) drawTexturedModalRect(guiLeft + 3, guiTop + 3, 204, 0, 18, 18); + if(!forward.isEmpty()) drawTexturedModalRect(guiLeft + 21, guiTop + 3, 222, 0, 18, 18); // scroll bar drawTexturedModalRect(guiLeft + xSize - 15, guiTop + getSliderPosition(), 192, 0, 12, 16); @@ -273,7 +322,7 @@ public class GuiQMAW extends GuiScreen { boolean mouseOver = (elementX <= mouseX && elementX + element.getWidth() > mouseX && elementY < mouseY && elementY + element.getHeight() >= mouseY); element.render(mouseOver, elementX, elementY, mouseX, mouseY); if(elementX <= lastClickX && elementX + element.getWidth() > lastClickX && elementY < lastClickY && elementY + element.getHeight() >= lastClickY) - element.onClick(); + element.onClick(this); inset += element.getWidth(); } @@ -283,6 +332,9 @@ public class GuiQMAW extends GuiScreen { @Override protected void keyTyped(char typedChar, int keyCode) { + + if(keyCode == Keyboard.KEY_LEFT) back(); + if(keyCode == Keyboard.KEY_RIGHT) forward(); if(keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) { this.mc.displayGuiScreen((GuiScreen) null); diff --git a/src/main/java/com/hbm/qmaw/ManualElement.java b/src/main/java/com/hbm/qmaw/ManualElement.java index 7d5c640d5..92ab74a13 100644 --- a/src/main/java/com/hbm/qmaw/ManualElement.java +++ b/src/main/java/com/hbm/qmaw/ManualElement.java @@ -5,5 +5,5 @@ public abstract class ManualElement { public abstract int getWidth(); public abstract int getHeight(); public abstract void render(boolean isMouseOver, int x, int y, int mouseX, int mouseY); - public abstract void onClick(); + public abstract void onClick(GuiQMAW gui); } diff --git a/src/main/java/com/hbm/qmaw/QMAWLoader.java b/src/main/java/com/hbm/qmaw/QMAWLoader.java index f085aeba4..3bf265372 100644 --- a/src/main/java/com/hbm/qmaw/QMAWLoader.java +++ b/src/main/java/com/hbm/qmaw/QMAWLoader.java @@ -60,6 +60,7 @@ public class QMAWLoader implements IResourceManagerReloadListener { //no fucking null check, if this fails then the entire game will sink along with the ship String path = QMAWLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath(); // exclude .class in the case of a dev env + MainRegistry.logger.info("[QMAW] Current running file: " + path); if(!path.endsWith(".class")) registerModFileURL(new File(path)); // i am going to shit myself qmaw.clear(); @@ -76,7 +77,10 @@ public class QMAWLoader implements IResourceManagerReloadListener { * */ public static void agonyEngine() { - for(File modFile : registeredModFiles) dissectZip(modFile); + for(File modFile : registeredModFiles) { + logJarAttempt(modFile.getName()); + dissectZip(modFile); + } File devEnvManualFolder = new File(Minecraft.getMinecraft().mcDataDir.getAbsolutePath().replace("/eclipse/.".replace('/', File.separatorChar), "") + "/src/main/resources/assets/hbm/manual".replace('/', File.separatorChar)); if(devEnvManualFolder.exists() && devEnvManualFolder.isDirectory()) { @@ -102,6 +106,7 @@ public class QMAWLoader implements IResourceManagerReloadListener { } } + public static void logJarAttempt(String name) { MainRegistry.logger.info("[QMAW] Dissecting jar " + name); } public static void logPackAttempt(String name) { MainRegistry.logger.info("[QMAW] Dissecting resource " + name); } public static void logFoundManual(String name) { MainRegistry.logger.info("[QMAW] Found manual " + name); } diff --git a/src/main/java/com/hbm/qmaw/components/QComponentLink.java b/src/main/java/com/hbm/qmaw/components/QComponentLink.java index c2816835e..acb4a4c9b 100644 --- a/src/main/java/com/hbm/qmaw/components/QComponentLink.java +++ b/src/main/java/com/hbm/qmaw/components/QComponentLink.java @@ -81,11 +81,14 @@ public class QComponentLink extends ManualElement { font.drawString(text, x, y, isMouseOver ? hoverColor : color); } - @Override public void onClick() { + @Override public void onClick(GuiQMAW gui) { QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(link); if(qmaw != null) { Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.func_147674_a(new ResourceLocation("gui.button.press"), 1.0F)); - FMLCommonHandler.instance().showGuiScreen(new GuiQMAW(qmaw)); + GuiQMAW screen = new GuiQMAW(qmaw); + screen.back.addAll(gui.back); + screen.back.add(gui.qmawID); + FMLCommonHandler.instance().showGuiScreen(screen); } } } diff --git a/src/main/java/com/hbm/qmaw/components/QComponentText.java b/src/main/java/com/hbm/qmaw/components/QComponentText.java index 30fd266b5..efcb0ffd8 100644 --- a/src/main/java/com/hbm/qmaw/components/QComponentText.java +++ b/src/main/java/com/hbm/qmaw/components/QComponentText.java @@ -1,5 +1,6 @@ package com.hbm.qmaw.components; +import com.hbm.qmaw.GuiQMAW; import com.hbm.qmaw.ManualElement; import net.minecraft.client.Minecraft; @@ -40,5 +41,5 @@ public class QComponentText extends ManualElement { font.drawString(text, x, y, color); } - @Override public void onClick() { } + @Override public void onClick(GuiQMAW gui) { } } diff --git a/src/main/java/com/hbm/tileentity/network/TileEntityConverterHeRf.java b/src/main/java/com/hbm/tileentity/network/TileEntityConverterHeRf.java index 3d7072304..f6dc1fdff 100644 --- a/src/main/java/com/hbm/tileentity/network/TileEntityConverterHeRf.java +++ b/src/main/java/com/hbm/tileentity/network/TileEntityConverterHeRf.java @@ -2,9 +2,10 @@ package com.hbm.tileentity.network; import com.google.gson.JsonObject; import com.google.gson.stream.JsonWriter; -import com.hbm.calc.Location; import com.hbm.tileentity.IConfigurableMachine; import com.hbm.tileentity.TileEntityLoadedBase; +import com.hbm.util.Compat; +import com.hbm.util.fauxpointtwelve.BlockPos; import api.hbm.energymk2.IEnergyReceiverMK2; import cofh.api.energy.EnergyStorage; @@ -41,8 +42,8 @@ public class TileEntityConverterHeRf extends TileEntityLoadedBase implements IEn for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) { this.trySubscribe(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir); - Location loc = new Location(worldObj, xCoord, yCoord, zCoord).add(dir); - TileEntity entity = loc.getTileEntity(); + BlockPos loc = new BlockPos(xCoord, yCoord, zCoord).offset(dir); + TileEntity entity = Compat.getTileStandard(worldObj, loc.getX(), loc.getY(), loc.getZ()); if (entity != null && entity instanceof IEnergyReceiver) { IEnergyReceiver receiver = (IEnergyReceiver) entity; diff --git a/src/main/resources/assets/hbm/textures/gui/gui_wiki.png b/src/main/resources/assets/hbm/textures/gui/gui_wiki.png index 48c92d1c46ca12cf5d22954dbccfe040f2e43d86..9f8c2d655a66fcc3422ab635e9e2e608eefec5b7 100644 GIT binary patch literal 1258 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6%N?Bp530R%N1DIGxWLQfaR zkcv5P@A&53c4KG=TzVmP6W6Ah%rD$-elT+l6mffZkU1kcW$NWE+Tzyxm78zBz4zwpb&2Pt9zdc$)|w|VoiZBOXg_)Tw*^zFm?mS-iBC(h_GG^_vrwYJf=Y5B6uUr%p;zmWcI zvD@S641ad~ue{iB*(CSd@4rfqIT)@R`CeXK|9{2ulil)+2XuF(H0c-G?Z0OBFQUeU zBQnXf{%o!#Q^VQHY=-M|{`7C(`DEgOgA6r4fBk&)`RDfyycK6xW;2{u|G&}D!sMLc zw4MX28Gn5G`dLZZvW;WIvi@Bs%1`7o7o0u$zhbu10o{r^)B8IaEx*-z=e$JmYh literal 1017 zcmeAS@N?(olHy`uVBq!ia0y~yU<5K5893O0R7}x|G$6%N?Bp530R%N1DIE+9%o{vi z978JRyuIt#H!DG+A#vG5519t(oevvi8hT%@TAnH1+v__!$Tv-*a(?s@@GZS24NI{oz1w>sh4J%ti=`wUmy+?G4z`Op2^|L5MmSH6I`XFGd( zP4Nfw%O?7K@HuDudFkt=vfFa4tN4KV6EFBNrH&!&LHw8X)q3kd3O!x@ KT-G@yGywq1n>$(n