mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Fix
This commit is contained in:
parent
a0451b46a5
commit
b4b471e5c3
@ -1,9 +1,8 @@
|
|||||||
package com.hbm.config;
|
package com.hbm.config;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileReader;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.io.FileWriter;
|
import java.nio.file.Files;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -148,7 +147,7 @@ public class CustomMachineConfigJSON {
|
|||||||
public static void readConfig(File config) {
|
public static void readConfig(File config) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JsonObject json = gson.fromJson(new FileReader(config), JsonObject.class);
|
JsonObject json = gson.fromJson(new InputStreamReader(Files.newInputStream(config.toPath()), StandardCharsets.UTF_8), JsonObject.class);
|
||||||
JsonArray machines = json.get("machines").getAsJsonArray();
|
JsonArray machines = json.get("machines").getAsJsonArray();
|
||||||
|
|
||||||
for(int i = 0; i < machines.size(); i++) {
|
for(int i = 0; i < machines.size(); i++) {
|
||||||
@ -182,32 +181,32 @@ public class CustomMachineConfigJSON {
|
|||||||
try {
|
try {
|
||||||
JsonArray recipeShape = machineObject.get("recipeShape").getAsJsonArray();
|
JsonArray recipeShape = machineObject.get("recipeShape").getAsJsonArray();
|
||||||
JsonArray recipeParts = machineObject.get("recipeParts").getAsJsonArray();
|
JsonArray recipeParts = machineObject.get("recipeParts").getAsJsonArray();
|
||||||
|
|
||||||
Object[] parts = new Object[recipeShape.size() + recipeParts.size()];
|
Object[] parts = new Object[recipeShape.size() + recipeParts.size()];
|
||||||
|
|
||||||
for(int j = 0; j < recipeShape.size(); j++) {
|
for(int j = 0; j < recipeShape.size(); j++) {
|
||||||
parts[j] = recipeShape.get(j).getAsString();
|
parts[j] = recipeShape.get(j).getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int j = 0; j < recipeParts.size(); j++) {
|
for(int j = 0; j < recipeParts.size(); j++) {
|
||||||
Object o = null;
|
Object o = null;
|
||||||
|
|
||||||
if(j % 2 == 0) {
|
if(j % 2 == 0) {
|
||||||
o = recipeParts.get(j).getAsString().charAt(0); //god is dead and we killed him
|
o = recipeParts.get(j).getAsString().charAt(0); //god is dead and we killed him
|
||||||
} else {
|
} else {
|
||||||
AStack a = SerializableRecipe.readAStack(recipeParts.get(j).getAsJsonArray());
|
AStack a = SerializableRecipe.readAStack(recipeParts.get(j).getAsJsonArray());
|
||||||
|
|
||||||
if(a instanceof ComparableStack) o = ((ComparableStack) a).toStack();
|
if(a instanceof ComparableStack) o = ((ComparableStack) a).toStack();
|
||||||
if(a instanceof OreDictStack) o = ((OreDictStack) a).name;
|
if(a instanceof OreDictStack) o = ((OreDictStack) a).name;
|
||||||
}
|
}
|
||||||
|
|
||||||
parts[j + recipeShape.size()] = o;
|
parts[j + recipeShape.size()] = o;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = new ItemStack(ModBlocks.custom_machine, 1, i + 100);
|
ItemStack stack = new ItemStack(ModBlocks.custom_machine, 1, i + 100);
|
||||||
stack.stackTagCompound = new NBTTagCompound();
|
stack.stackTagCompound = new NBTTagCompound();
|
||||||
stack.stackTagCompound.setString("machineType", configuration.unlocalizedName);
|
stack.stackTagCompound.setString("machineType", configuration.unlocalizedName);
|
||||||
|
|
||||||
CraftingManager.addRecipeAuto(stack, parts);
|
CraftingManager.addRecipeAuto(stack, parts);
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
MainRegistry.logger.error("Caught exception trying to parse core recipe for custom machine " + configuration.unlocalizedName);
|
MainRegistry.logger.error("Caught exception trying to parse core recipe for custom machine " + configuration.unlocalizedName);
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
package com.hbm.inventory.fluid;
|
package com.hbm.inventory.fluid;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileReader;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.io.FileWriter;
|
import java.nio.file.Files;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -35,7 +34,7 @@ import net.minecraft.potion.PotionEffect;
|
|||||||
public class Fluids {
|
public class Fluids {
|
||||||
|
|
||||||
public static final Gson gson = new Gson();
|
public static final Gson gson = new Gson();
|
||||||
|
|
||||||
public static List<IFluidRegisterListener> additionalListeners = new ArrayList();
|
public static List<IFluidRegisterListener> additionalListeners = new ArrayList();
|
||||||
|
|
||||||
public static FluidType NONE;
|
public static FluidType NONE;
|
||||||
@ -797,7 +796,7 @@ public class Fluids {
|
|||||||
private static void readCustomFluids(File file) {
|
private static void readCustomFluids(File file) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JsonObject json = gson.fromJson(new FileReader(file), JsonObject.class);
|
JsonObject json = gson.fromJson(new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8), JsonObject.class);
|
||||||
|
|
||||||
for(Entry<String, JsonElement> entry : json.entrySet()) {
|
for(Entry<String, JsonElement> entry : json.entrySet()) {
|
||||||
|
|
||||||
@ -879,12 +878,12 @@ public class Fluids {
|
|||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void reloadFluids(){
|
public static void reloadFluids(){
|
||||||
File folder = MainRegistry.configHbmDir;
|
File folder = MainRegistry.configHbmDir;
|
||||||
File customTypes = new File(folder.getAbsolutePath() + File.separatorChar + "hbmFluidTypes.json");
|
File customTypes = new File(folder.getAbsolutePath() + File.separatorChar + "hbmFluidTypes.json");
|
||||||
if(!customTypes.exists()) initDefaultFluids(customTypes);
|
if(!customTypes.exists()) initDefaultFluids(customTypes);
|
||||||
|
|
||||||
for(FluidType type : customFluids){
|
for(FluidType type : customFluids){
|
||||||
idMapping.remove(type.getID());
|
idMapping.remove(type.getID());
|
||||||
registerOrder.remove(type);
|
registerOrder.remove(type);
|
||||||
@ -892,7 +891,7 @@ public class Fluids {
|
|||||||
metaOrder.remove(type);
|
metaOrder.remove(type);
|
||||||
}
|
}
|
||||||
customFluids.clear();
|
customFluids.clear();
|
||||||
|
|
||||||
for(FluidType type : foreignFluids){
|
for(FluidType type : foreignFluids){
|
||||||
idMapping.remove(type.getID());
|
idMapping.remove(type.getID());
|
||||||
registerOrder.remove(type);
|
registerOrder.remove(type);
|
||||||
@ -900,7 +899,7 @@ public class Fluids {
|
|||||||
metaOrder.remove(type);
|
metaOrder.remove(type);
|
||||||
}
|
}
|
||||||
foreignFluids.clear();
|
foreignFluids.clear();
|
||||||
|
|
||||||
readCustomFluids(customTypes);
|
readCustomFluids(customTypes);
|
||||||
for(FluidType custom : customFluids) metaOrder.add(custom);
|
for(FluidType custom : customFluids) metaOrder.add(custom);
|
||||||
File config = new File(MainRegistry.configHbmDir.getAbsolutePath() + File.separatorChar + "hbmFluidTraits.json");
|
File config = new File(MainRegistry.configHbmDir.getAbsolutePath() + File.separatorChar + "hbmFluidTraits.json");
|
||||||
@ -911,7 +910,7 @@ public class Fluids {
|
|||||||
} else {
|
} else {
|
||||||
readTraits(config);
|
readTraits(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(IFluidRegisterListener listener : additionalListeners) listener.onFluidsLoad();
|
for(IFluidRegisterListener listener : additionalListeners) listener.onFluidsLoad();
|
||||||
}
|
}
|
||||||
private static void registerCalculatedFuel(FluidType type, double base, double combustMult, FuelGrade grade) {
|
private static void registerCalculatedFuel(FluidType type, double base, double combustMult, FuelGrade grade) {
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
public class GuiQMAW extends GuiScreen {
|
public class GuiQMAW extends GuiScreen {
|
||||||
|
|
||||||
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_wiki.png");
|
protected static final ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/gui_wiki.png");
|
||||||
|
|
||||||
public String title;
|
public String title;
|
||||||
public String qmawID;
|
public String qmawID;
|
||||||
public ItemStack icon;
|
public ItemStack icon;
|
||||||
@ -31,51 +31,51 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
/** History for returning via button */
|
/** History for returning via button */
|
||||||
public List<String> back = new ArrayList();
|
public List<String> back = new ArrayList();
|
||||||
public List<String> forward = new ArrayList();
|
public List<String> forward = new ArrayList();
|
||||||
|
|
||||||
protected int xSize = 340;
|
protected int xSize = 340;
|
||||||
protected int ySize = 224;
|
protected int ySize = 224;
|
||||||
protected int guiLeft;
|
protected int guiLeft;
|
||||||
protected int guiTop;
|
protected int guiTop;
|
||||||
|
|
||||||
protected boolean isDragging = false;
|
protected boolean isDragging = false;
|
||||||
protected int scrollProgress = 0;
|
protected int scrollProgress = 0;
|
||||||
protected int lastClickX = 0;
|
protected int lastClickX = 0;
|
||||||
protected int lastClickY = 0;
|
protected int lastClickY = 0;
|
||||||
|
|
||||||
public static final String EN_US = "en_US";
|
public static final String EN_US = "en_US";
|
||||||
|
|
||||||
public GuiQMAW(QuickManualAndWiki qmaw) {
|
public GuiQMAW(QuickManualAndWiki qmaw) {
|
||||||
qmawID = qmaw.name;
|
qmawID = qmaw.name;
|
||||||
parseQMAW(qmaw);
|
parseQMAW(qmaw);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void parseQMAW(QuickManualAndWiki qmaw) {
|
protected void parseQMAW(QuickManualAndWiki qmaw) {
|
||||||
LanguageManager lang = Minecraft.getMinecraft().getLanguageManager();
|
LanguageManager lang = Minecraft.getMinecraft().getLanguageManager();
|
||||||
|
|
||||||
this.title = qmaw.title.get(lang.getCurrentLanguage());
|
this.title = qmaw.title.get(lang.getCurrentLanguage().getLanguageCode());
|
||||||
if(title == null) this.title = qmaw.title.get(EN_US);
|
if(title == null) this.title = qmaw.title.get(EN_US);
|
||||||
if(title == null) this.title = "Missing Localization!";
|
if(title == null) this.title = "Missing Localization!";
|
||||||
|
|
||||||
this.icon = qmaw.icon;
|
this.icon = qmaw.icon;
|
||||||
|
|
||||||
String toParse = qmaw.contents.get(lang.getCurrentLanguage());
|
String toParse = qmaw.contents.get(lang.getCurrentLanguage().getLanguageCode());
|
||||||
if(toParse == null) toParse = qmaw.contents.get(EN_US);
|
if(toParse == null) toParse = qmaw.contents.get(EN_US);
|
||||||
if(toParse == null) toParse = "Missing Localization!";
|
if(toParse == null) toParse = "Missing Localization!";
|
||||||
toParse = "" + toParse; // strings are reference types, no?
|
toParse = "" + toParse; // strings are reference types, no?
|
||||||
|
|
||||||
int maxLineLength = xSize - 29;
|
int maxLineLength = xSize - 29;
|
||||||
String prevToParse = "" + toParse;
|
String prevToParse = "" + toParse;
|
||||||
int maxIterations = 1000;
|
int maxIterations = 1000;
|
||||||
int currentLineWidth = 0;
|
int currentLineWidth = 0;
|
||||||
|
|
||||||
while(!toParse.isEmpty() && maxIterations > 0) {
|
while(!toParse.isEmpty() && maxIterations > 0) {
|
||||||
if(this.lines.isEmpty()) this.lines.add(new ArrayList());
|
if(this.lines.isEmpty()) this.lines.add(new ArrayList());
|
||||||
List<ManualElement> currentLine = this.lines.get(this.lines.size() - 1);
|
List<ManualElement> currentLine = this.lines.get(this.lines.size() - 1);
|
||||||
|
|
||||||
toParse = toParse.trim();
|
toParse = toParse.trim();
|
||||||
|
|
||||||
maxIterations--;
|
maxIterations--;
|
||||||
|
|
||||||
if(toParse.startsWith("<br>")) {
|
if(toParse.startsWith("<br>")) {
|
||||||
toParse = toParse.substring(4);
|
toParse = toParse.substring(4);
|
||||||
currentLine = new ArrayList();
|
currentLine = new ArrayList();
|
||||||
@ -83,25 +83,25 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
currentLineWidth = 0;
|
currentLineWidth = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle links
|
// handle links
|
||||||
if(toParse.startsWith("[[")) {
|
if(toParse.startsWith("[[")) {
|
||||||
int end = toParse.indexOf("]]");
|
int end = toParse.indexOf("]]");
|
||||||
if(end != -1) {
|
if(end != -1) {
|
||||||
String link = toParse.substring(2, end);
|
String link = toParse.substring(2, end);
|
||||||
toParse = toParse.substring(end + 2);
|
toParse = toParse.substring(end + 2);
|
||||||
|
|
||||||
int pipe = link.indexOf("|");
|
int pipe = link.indexOf("|");
|
||||||
QComponentLink linkComponent;
|
QComponentLink linkComponent;
|
||||||
|
|
||||||
String suffix = toParse.startsWith(" ") ? " " : "";
|
String suffix = toParse.startsWith(" ") ? " " : "";
|
||||||
|
|
||||||
if(pipe == -1) {
|
if(pipe == -1) {
|
||||||
linkComponent = new QComponentLink(link, link + suffix);
|
linkComponent = new QComponentLink(link, link + suffix);
|
||||||
} else {
|
} else {
|
||||||
linkComponent = new QComponentLink(link.substring(pipe + 1, link.length()), link.substring(0, pipe) + suffix);
|
linkComponent = new QComponentLink(link.substring(pipe + 1, link.length()), link.substring(0, pipe) + suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// append to current line
|
// append to current line
|
||||||
int width = linkComponent.getWidth();
|
int width = linkComponent.getWidth();
|
||||||
if(width + currentLineWidth <= maxLineLength) {
|
if(width + currentLineWidth <= maxLineLength) {
|
||||||
@ -119,21 +119,21 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle standard text
|
// handle standard text
|
||||||
int delimit = toParse.length();
|
int delimit = toParse.length();
|
||||||
|
|
||||||
int spaceIndex = toParse.indexOf(" ");
|
int spaceIndex = toParse.indexOf(" ");
|
||||||
if(spaceIndex != -1) delimit = Math.min(delimit, spaceIndex);
|
if(spaceIndex != -1) delimit = Math.min(delimit, spaceIndex);
|
||||||
int linkIndex = toParse.indexOf("[[");
|
int linkIndex = toParse.indexOf("[[");
|
||||||
if(linkIndex != -1) delimit = Math.min(delimit, linkIndex);
|
if(linkIndex != -1) delimit = Math.min(delimit, linkIndex);
|
||||||
int brIndex = toParse.indexOf("<br>");
|
int brIndex = toParse.indexOf("<br>");
|
||||||
if(brIndex != -1) delimit = Math.min(delimit, brIndex);
|
if(brIndex != -1) delimit = Math.min(delimit, brIndex);
|
||||||
|
|
||||||
if(delimit > 0) {
|
if(delimit > 0) {
|
||||||
QComponentText textComponent = new QComponentText(toParse.substring(0, delimit) + (spaceIndex == delimit ? " " : ""));
|
QComponentText textComponent = new QComponentText(toParse.substring(0, delimit) + (spaceIndex == delimit ? " " : ""));
|
||||||
toParse = toParse.substring(delimit);
|
toParse = toParse.substring(delimit);
|
||||||
|
|
||||||
// append to current line
|
// append to current line
|
||||||
int width = textComponent.getWidth();
|
int width = textComponent.getWidth();
|
||||||
if(width + currentLineWidth <= maxLineLength) {
|
if(width + currentLineWidth <= maxLineLength) {
|
||||||
@ -150,7 +150,7 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
prevToParse = "" + toParse;
|
prevToParse = "" + toParse;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(toParse.equals(prevToParse)) break;
|
if(toParse.equals(prevToParse)) break;
|
||||||
prevToParse = "" + toParse;
|
prevToParse = "" + toParse;
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
@Override
|
@Override
|
||||||
protected void mouseClicked(int x, int y, int key) {
|
protected void mouseClicked(int x, int y, int key) {
|
||||||
super.mouseClicked(x, y, key);
|
super.mouseClicked(x, y, key);
|
||||||
|
|
||||||
if(key == 0) {
|
if(key == 0) {
|
||||||
this.lastClickX = x;
|
this.lastClickX = x;
|
||||||
this.lastClickY = y;
|
this.lastClickY = y;
|
||||||
@ -175,10 +175,10 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
if(guiLeft + 3 <= x && guiLeft + 3 + 18 > x && guiTop + 3 < y && guiTop + 3 + 18 >= y) back();
|
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();
|
if(guiLeft + 21 <= x && guiLeft + 21 + 18 > x && guiTop + 3 < y && guiTop + 3 + 18 >= y) forward();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void back() {
|
public void back() {
|
||||||
if(this.back.isEmpty()) return;
|
if(this.back.isEmpty()) return;
|
||||||
|
|
||||||
String prev = back.get(back.size() - 1);
|
String prev = back.get(back.size() - 1);
|
||||||
|
|
||||||
QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(prev);
|
QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(prev);
|
||||||
@ -192,10 +192,10 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
FMLCommonHandler.instance().showGuiScreen(screen);
|
FMLCommonHandler.instance().showGuiScreen(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forward() {
|
public void forward() {
|
||||||
if(this.forward.isEmpty()) return;
|
if(this.forward.isEmpty()) return;
|
||||||
|
|
||||||
String next = forward.get(forward.size() - 1);
|
String next = forward.get(forward.size() - 1);
|
||||||
|
|
||||||
QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(next);
|
QuickManualAndWiki qmaw = QMAWLoader.qmaw.get(next);
|
||||||
@ -209,7 +209,7 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
FMLCommonHandler.instance().showGuiScreen(screen);
|
FMLCommonHandler.instance().showGuiScreen(screen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSliderPosition() {
|
public int getSliderPosition() {
|
||||||
double progress = (double) scrollProgress / (double) (lines.size() - 1);
|
double progress = (double) scrollProgress / (double) (lines.size() - 1);
|
||||||
return 25 + (int) (progress * 180);
|
return 25 + (int) (progress * 180);
|
||||||
@ -217,38 +217,38 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawScreen(int mouseX, int mouseY, float f) {
|
public void drawScreen(int mouseX, int mouseY, float f) {
|
||||||
|
|
||||||
if(Mouse.isButtonDown(0) && guiLeft + xSize - 15 <= mouseX && guiLeft + xSize - 15 + 12 > mouseX && guiTop + 25 < mouseY && guiTop + 25 + 191 >= mouseY) {
|
if(Mouse.isButtonDown(0) && guiLeft + xSize - 15 <= mouseX && guiLeft + xSize - 15 + 12 > mouseX && guiTop + 25 < mouseY && guiTop + 25 + 191 >= mouseY) {
|
||||||
isDragging = true;
|
isDragging = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Mouse.isButtonDown(0)) isDragging = false;
|
if(!Mouse.isButtonDown(0)) isDragging = false;
|
||||||
|
|
||||||
if(isDragging) {
|
if(isDragging) {
|
||||||
int min = guiTop + 25 + 8;
|
int min = guiTop + 25 + 8;
|
||||||
int max = guiTop + 25 + 191 - 8;
|
int max = guiTop + 25 + 191 - 8;
|
||||||
int span = max - min;
|
int span = max - min;
|
||||||
|
|
||||||
double progress = MathHelper.clamp_double((double) (mouseY - min) / span, 0D, 1D);
|
double progress = MathHelper.clamp_double((double) (mouseY - min) / span, 0D, 1D);
|
||||||
this.scrollProgress = MathHelper.clamp_int((int) Math.round((lines.size() - 1) * progress), 0, lines.size() - 1);
|
this.scrollProgress = MathHelper.clamp_int((int) Math.round((lines.size() - 1) * progress), 0, lines.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScroll();
|
handleScroll();
|
||||||
|
|
||||||
//this.drawRect(0, 0, this.width, this.height, 0x80919191);
|
//this.drawRect(0, 0, this.width, this.height, 0x80919191);
|
||||||
this.drawRect(0, 0, this.width, this.height, 0xe0000000);
|
this.drawRect(0, 0, this.width, this.height, 0xe0000000);
|
||||||
|
|
||||||
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
this.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
GL11.glDisable(GL11.GL_LIGHTING);
|
||||||
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
this.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
GL11.glEnable(GL11.GL_LIGHTING);
|
||||||
|
|
||||||
this.lastClickX = 0;
|
this.lastClickX = 0;
|
||||||
this.lastClickY = 0;
|
this.lastClickY = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void handleScroll() {
|
protected void handleScroll() {
|
||||||
|
|
||||||
if(!Mouse.isButtonDown(0) && !Mouse.isButtonDown(1) && Mouse.next()) {
|
if(!Mouse.isButtonDown(0) && !Mouse.isButtonDown(1) && Mouse.next()) {
|
||||||
int scroll = Mouse.getEventDWheel();
|
int scroll = Mouse.getEventDWheel();
|
||||||
if(scroll > 0 && this.scrollProgress > 0) this.scrollProgress--;
|
if(scroll > 0 && this.scrollProgress > 0) this.scrollProgress--;
|
||||||
@ -257,10 +257,10 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
private void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||||
|
|
||||||
int x = 43;
|
int x = 43;
|
||||||
int y = 4;
|
int y = 4;
|
||||||
|
|
||||||
if(this.icon != null) {
|
if(this.icon != null) {
|
||||||
GL11.glPushMatrix();
|
GL11.glPushMatrix();
|
||||||
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
GL11.glEnable(GL11.GL_DEPTH_TEST);
|
||||||
@ -273,13 +273,13 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
RenderHelper.disableStandardItemLighting();
|
RenderHelper.disableStandardItemLighting();
|
||||||
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
GL11.glDisable(GL11.GL_DEPTH_TEST);
|
||||||
GL11.glPopMatrix();
|
GL11.glPopMatrix();
|
||||||
|
|
||||||
x += 18;
|
x += 18;
|
||||||
y += (16 - this.fontRendererObj.FONT_HEIGHT) / 2;
|
y += (16 - this.fontRendererObj.FONT_HEIGHT) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
y += 1;
|
y += 1;
|
||||||
|
|
||||||
this.fontRendererObj.drawString(title, guiLeft + x, guiTop + y, 0xFFFFFF);
|
this.fontRendererObj.drawString(title, guiLeft + x, guiTop + y, 0xFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,30 +292,30 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
|
|
||||||
if(!back.isEmpty()) drawTexturedModalRect(guiLeft + 3, guiTop + 3, 204, 0, 18, 18);
|
if(!back.isEmpty()) drawTexturedModalRect(guiLeft + 3, guiTop + 3, 204, 0, 18, 18);
|
||||||
if(!forward.isEmpty()) drawTexturedModalRect(guiLeft + 21, guiTop + 3, 222, 0, 18, 18);
|
if(!forward.isEmpty()) drawTexturedModalRect(guiLeft + 21, guiTop + 3, 222, 0, 18, 18);
|
||||||
|
|
||||||
// scroll bar
|
// scroll bar
|
||||||
drawTexturedModalRect(guiLeft + xSize - 15, guiTop + getSliderPosition(), 192, 0, 12, 16);
|
drawTexturedModalRect(guiLeft + xSize - 15, guiTop + getSliderPosition(), 192, 0, 12, 16);
|
||||||
|
|
||||||
int x = guiLeft + 7;
|
int x = guiLeft + 7;
|
||||||
int y = guiTop + 30;
|
int y = guiTop + 30;
|
||||||
int lineNum = 0;
|
int lineNum = 0;
|
||||||
|
|
||||||
for(List<ManualElement> line : lines) {
|
for(List<ManualElement> line : lines) {
|
||||||
lineNum++;
|
lineNum++;
|
||||||
|
|
||||||
if(lineNum <= this.scrollProgress) continue;
|
if(lineNum <= this.scrollProgress) continue;
|
||||||
|
|
||||||
int maxHeight = 0;
|
int maxHeight = 0;
|
||||||
int inset = 0;
|
int inset = 0;
|
||||||
|
|
||||||
for(ManualElement element : line) {
|
for(ManualElement element : line) {
|
||||||
maxHeight = Math.max(maxHeight, element.getHeight());
|
maxHeight = Math.max(maxHeight, element.getHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(y + maxHeight > guiTop + 219) break;
|
if(y + maxHeight > guiTop + 219) break;
|
||||||
|
|
||||||
if(line.isEmpty()) y += this.fontRendererObj.FONT_HEIGHT;
|
if(line.isEmpty()) y += this.fontRendererObj.FONT_HEIGHT;
|
||||||
|
|
||||||
for(ManualElement element : line) {
|
for(ManualElement element : line) {
|
||||||
int elementX = x + inset;
|
int elementX = x + inset;
|
||||||
int elementY = y + (maxHeight - element.getHeight()) / 2;
|
int elementY = y + (maxHeight - element.getHeight()) / 2;
|
||||||
@ -325,7 +325,7 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
element.onClick(this);
|
element.onClick(this);
|
||||||
inset += element.getWidth();
|
inset += element.getWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
y += maxHeight + 2;
|
y += maxHeight + 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,7 +335,7 @@ public class GuiQMAW extends GuiScreen {
|
|||||||
|
|
||||||
if(keyCode == Keyboard.KEY_LEFT) back();
|
if(keyCode == Keyboard.KEY_LEFT) back();
|
||||||
if(keyCode == Keyboard.KEY_RIGHT) forward();
|
if(keyCode == Keyboard.KEY_RIGHT) forward();
|
||||||
|
|
||||||
if(keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
|
if(keyCode == 1 || keyCode == this.mc.gameSettings.keyBindInventory.getKeyCode()) {
|
||||||
this.mc.displayGuiScreen((GuiScreen) null);
|
this.mc.displayGuiScreen((GuiScreen) null);
|
||||||
this.mc.setIngameFocus();
|
this.mc.setIngameFocus();
|
||||||
|
|||||||
@ -1,9 +1,8 @@
|
|||||||
package com.hbm.qmaw;
|
package com.hbm.qmaw;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.*;
|
||||||
import java.io.FileReader;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.io.InputStream;
|
import java.nio.file.Files;
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -47,7 +46,7 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
init();
|
init();
|
||||||
MainRegistry.logger.info("[QMAW] Loaded " + qmaw.size() + " manual entries! (" + (System.currentTimeMillis() - timestamp) + "ms)");
|
MainRegistry.logger.info("[QMAW] Loaded " + qmaw.size() + " manual entries! (" + (System.currentTimeMillis() - timestamp) + "ms)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** For the like 2 people who might consider making an NTM addon and want to include manual pages. Requires the mod's actual JAR file as the parameter. */
|
/** For the like 2 people who might consider making an NTM addon and want to include manual pages. Requires the mod's actual JAR file as the parameter. */
|
||||||
public static void registerModFileURL(File file) {
|
public static void registerModFileURL(File file) {
|
||||||
registeredModFiles.add(file);
|
registeredModFiles.add(file);
|
||||||
@ -62,14 +61,14 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
// exclude .class in the case of a dev env
|
// exclude .class in the case of a dev env
|
||||||
MainRegistry.logger.info("[QMAW] Current running file: " + path);
|
MainRegistry.logger.info("[QMAW] Current running file: " + path);
|
||||||
if(!path.endsWith(".class")) registerModFileURL(new File(path)); // i am going to shit myself*/ // deactivated because it likely doesn't even fucking work
|
if(!path.endsWith(".class")) registerModFileURL(new File(path)); // i am going to shit myself*/ // deactivated because it likely doesn't even fucking work
|
||||||
|
|
||||||
// registering of the mod file now happens in the MainRegistry during preinit
|
// registering of the mod file now happens in the MainRegistry during preinit
|
||||||
|
|
||||||
qmaw.clear();
|
qmaw.clear();
|
||||||
triggers.clear();
|
triggers.clear();
|
||||||
agonyEngine();
|
agonyEngine();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** "digital equivalent to holywater" yielded few results on google, if only i had the answer i would drown this entire class in it <br><br>
|
/** "digital equivalent to holywater" yielded few results on google, if only i had the answer i would drown this entire class in it <br><br>
|
||||||
* This affront to god can load QMAW definition files from four different sources:<br>
|
* This affront to god can load QMAW definition files from four different sources:<br>
|
||||||
* * Any mod's jar that has registered itself to include QMAW files<br>
|
* * Any mod's jar that has registered itself to include QMAW files<br>
|
||||||
@ -78,12 +77,12 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
* * Folder-based resource packs
|
* * Folder-based resource packs
|
||||||
* */
|
* */
|
||||||
public static void agonyEngine() {
|
public static void agonyEngine() {
|
||||||
|
|
||||||
for(File modFile : registeredModFiles) {
|
for(File modFile : registeredModFiles) {
|
||||||
logJarAttempt(modFile.getName());
|
logJarAttempt(modFile.getName());
|
||||||
dissectZip(modFile);
|
dissectZip(modFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
File devEnvManualFolder = new File(Minecraft.getMinecraft().mcDataDir.getAbsolutePath().replace("/eclipse/.".replace('/', File.separatorChar), "") + "/src/main/resources/assets/hbm/manual".replace('/', File.separatorChar));
|
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()) {
|
if(devEnvManualFolder.exists() && devEnvManualFolder.isDirectory()) {
|
||||||
MainRegistry.logger.info("[QMAW] Exploring " + devEnvManualFolder.getAbsolutePath());
|
MainRegistry.logger.info("[QMAW] Exploring " + devEnvManualFolder.getAbsolutePath());
|
||||||
@ -91,17 +90,17 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ResourcePackRepository repo = Minecraft.getMinecraft().getResourcePackRepository();
|
ResourcePackRepository repo = Minecraft.getMinecraft().getResourcePackRepository();
|
||||||
|
|
||||||
for(Object o : repo.getRepositoryEntries()) {
|
for(Object o : repo.getRepositoryEntries()) {
|
||||||
ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry) o;
|
ResourcePackRepository.Entry entry = (ResourcePackRepository.Entry) o;
|
||||||
IResourcePack pack = entry.getResourcePack();
|
IResourcePack pack = entry.getResourcePack();
|
||||||
|
|
||||||
logPackAttempt(pack.getPackName());
|
logPackAttempt(pack.getPackName());
|
||||||
|
|
||||||
if(pack instanceof FileResourcePack) {
|
if(pack instanceof FileResourcePack) {
|
||||||
dissectZip(((FileResourcePack) pack).resourcePackFile);
|
dissectZip(((FileResourcePack) pack).resourcePackFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(pack instanceof FolderResourcePack) {
|
if(pack instanceof FolderResourcePack) {
|
||||||
dissectFolder(((FolderResourcePack) pack).resourcePackFile);
|
dissectFolder(((FolderResourcePack) pack).resourcePackFile);
|
||||||
}
|
}
|
||||||
@ -111,27 +110,27 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
public static void logJarAttempt(String name) { MainRegistry.logger.info("[QMAW] Dissecting jar " + name); }
|
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 logPackAttempt(String name) { MainRegistry.logger.info("[QMAW] Dissecting resource " + name); }
|
||||||
public static void logFoundManual(String name) { MainRegistry.logger.info("[QMAW] Found manual " + name); }
|
public static void logFoundManual(String name) { MainRegistry.logger.info("[QMAW] Found manual " + name); }
|
||||||
|
|
||||||
/** You put your white gloves on, you get your hand in there, and then you iterate OVER THE ENTIRE FUCKING ZIP until we find things we deem usable */
|
/** You put your white gloves on, you get your hand in there, and then you iterate OVER THE ENTIRE FUCKING ZIP until we find things we deem usable */
|
||||||
public static void dissectZip(File zipFile) {
|
public static void dissectZip(File zipFile) {
|
||||||
|
|
||||||
if(zipFile == null) {
|
if(zipFile == null) {
|
||||||
MainRegistry.logger.info("[QMAW] Pack file does not exist!");
|
MainRegistry.logger.info("[QMAW] Pack file does not exist!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ZipFile zip = null;
|
ZipFile zip = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
zip = new ZipFile(zipFile);
|
zip = new ZipFile(zipFile);
|
||||||
Enumeration<? extends ZipEntry> enumerator = zip.entries();
|
Enumeration<? extends ZipEntry> enumerator = zip.entries();
|
||||||
|
|
||||||
while(enumerator.hasMoreElements()) {
|
while(enumerator.hasMoreElements()) {
|
||||||
ZipEntry entry = enumerator.nextElement();
|
ZipEntry entry = enumerator.nextElement();
|
||||||
String name = entry.getName();
|
String name = entry.getName();
|
||||||
if(name.startsWith("assets/hbm/manual/") && name.endsWith(".json")) {
|
if(name.startsWith("assets/hbm/manual/") && name.endsWith(".json")) {
|
||||||
InputStream fileStream = zip.getInputStream(entry);
|
InputStream fileStream = zip.getInputStream(entry);
|
||||||
InputStreamReader reader = new InputStreamReader(fileStream);
|
InputStreamReader reader = new InputStreamReader(fileStream, StandardCharsets.UTF_8);
|
||||||
try {
|
try {
|
||||||
JsonObject obj = (JsonObject) parser.parse(reader);
|
JsonObject obj = (JsonObject) parser.parse(reader);
|
||||||
String manName = name.replace("assets/hbm/manual/", "");
|
String manName = name.replace("assets/hbm/manual/", "");
|
||||||
@ -143,7 +142,7 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(Exception ex) {
|
} catch(Exception ex) {
|
||||||
MainRegistry.logger.info("[QMAW] Error dissecting zip " + zipFile.getName() + ": " + ex);
|
MainRegistry.logger.info("[QMAW] Error dissecting zip " + zipFile.getName() + ": " + ex);
|
||||||
} finally {
|
} finally {
|
||||||
@ -152,13 +151,13 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
} catch(Exception ex) { }
|
} catch(Exception ex) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Opens a resource pack folder, skips to the manual folder, then tries to dissect that */
|
/** Opens a resource pack folder, skips to the manual folder, then tries to dissect that */
|
||||||
public static void dissectFolder(File folder) {
|
public static void dissectFolder(File folder) {
|
||||||
File manualFolder = new File(folder, "/assets/hbm/manual");
|
File manualFolder = new File(folder, "/assets/hbm/manual");
|
||||||
if(manualFolder.exists() && manualFolder.isDirectory()) dissectManualFolder(manualFolder);
|
if(manualFolder.exists() && manualFolder.isDirectory()) dissectManualFolder(manualFolder);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Anal bleeding */
|
/** Anal bleeding */
|
||||||
public static void dissectManualFolder(File folder) {
|
public static void dissectManualFolder(File folder) {
|
||||||
|
|
||||||
@ -167,7 +166,8 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
String name = file.getName();
|
String name = file.getName();
|
||||||
if(file.isFile() && name.endsWith(".json")) {
|
if(file.isFile() && name.endsWith(".json")) {
|
||||||
try {
|
try {
|
||||||
FileReader reader = new FileReader(file);
|
//FileReader reader = new FileReader(file);
|
||||||
|
InputStreamReader reader = new InputStreamReader(Files.newInputStream(file.toPath()), StandardCharsets.UTF_8);
|
||||||
JsonObject obj = (JsonObject) parser.parse(reader);
|
JsonObject obj = (JsonObject) parser.parse(reader);
|
||||||
registerJson(name, obj);
|
registerJson(name, obj);
|
||||||
logFoundManual(name);
|
logFoundManual(name);
|
||||||
@ -179,35 +179,35 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Extracts all the info from a json file's main object to add a QMAW to the system. Very barebones, only handles name, icon and the localized text. */
|
/** Extracts all the info from a json file's main object to add a QMAW to the system. Very barebones, only handles name, icon and the localized text. */
|
||||||
public static void registerJson(String file, JsonObject json) {
|
public static void registerJson(String file, JsonObject json) {
|
||||||
|
|
||||||
String name = json.get("name").getAsString();
|
String name = json.get("name").getAsString();
|
||||||
|
|
||||||
if(QMAWLoader.qmaw.containsKey(name)) {
|
if(QMAWLoader.qmaw.containsKey(name)) {
|
||||||
MainRegistry.logger.info("[QMAW] Skipping existing entry " + file);
|
MainRegistry.logger.info("[QMAW] Skipping existing entry " + file);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QuickManualAndWiki qmaw = new QuickManualAndWiki(name);
|
QuickManualAndWiki qmaw = new QuickManualAndWiki(name);
|
||||||
|
|
||||||
if(json.has("icon")) {
|
if(json.has("icon")) {
|
||||||
qmaw.setIcon(SerializableRecipe.readItemStack(json.get("icon").getAsJsonArray()));
|
qmaw.setIcon(SerializableRecipe.readItemStack(json.get("icon").getAsJsonArray()));
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject title = json.get("title").getAsJsonObject();
|
JsonObject title = json.get("title").getAsJsonObject();
|
||||||
for(Entry<String, JsonElement> part : title.entrySet()) {
|
for(Entry<String, JsonElement> part : title.entrySet()) {
|
||||||
qmaw.addTitle(part.getKey(), part.getValue().getAsString());
|
qmaw.addTitle(part.getKey(), part.getValue().getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject content = json.get("content").getAsJsonObject();
|
JsonObject content = json.get("content").getAsJsonObject();
|
||||||
for(Entry<String, JsonElement> part : content.entrySet()) {
|
for(Entry<String, JsonElement> part : content.entrySet()) {
|
||||||
qmaw.addLang(part.getKey(), part.getValue().getAsString());
|
qmaw.addLang(part.getKey(), part.getValue().getAsString());
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonArray triggers = json.get("trigger").getAsJsonArray();
|
JsonArray triggers = json.get("trigger").getAsJsonArray();
|
||||||
|
|
||||||
for(JsonElement element : triggers) {
|
for(JsonElement element : triggers) {
|
||||||
ItemStack trigger = SerializableRecipe.readItemStack(element.getAsJsonArray());
|
ItemStack trigger = SerializableRecipe.readItemStack(element.getAsJsonArray());
|
||||||
// items get renamed and removed all the time, so we add some more debug goodness for those cases
|
// items get renamed and removed all the time, so we add some more debug goodness for those cases
|
||||||
@ -217,7 +217,7 @@ public class QMAWLoader implements IResourceManagerReloadListener {
|
|||||||
QMAWLoader.triggers.put(new ComparableStack(trigger).makeSingular(), qmaw);
|
QMAWLoader.triggers.put(new ComparableStack(trigger).makeSingular(), qmaw);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!qmaw.contents.isEmpty()) {
|
if(!qmaw.contents.isEmpty()) {
|
||||||
QMAWLoader.qmaw.put(name, qmaw);
|
QMAWLoader.qmaw.put(name, qmaw);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user