diff --git a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/GuiBase.java b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/GuiBase.java index 84baf8c..02fd9ed 100644 --- a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/GuiBase.java +++ b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/GuiBase.java @@ -126,58 +126,44 @@ public abstract class GuiBase extends GuiContainer { @Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { final boolean[] clickedSlot = new boolean[]{false}; - container.getRecipeSlots().stream().filter(slot -> { + for (SlotRecipe slot : container.getRecipeSlots()) { Rectangle rectangle = new Rectangle(guiLeft + slot.xDisplayPosition, guiTop + slot.yDisplayPosition, 18, 18); if (rectangle.contains(mouseX, mouseY)) { switch (mouseButton) { case 0: - return false; case 1: if (slot.getHasStack()) { clickedSlot[0] = true; - return true; + selectedSlot = slot; + editingField.setText(slot.getItemString()); + if (shouldOpenMenu) { + menu.toggle(true); + for (Pair but : menu.getButtons()) { + for (Slider slider : but.getValue()) { + buttonList.remove(slider); + } + } + menu.getFromMap(slot.getPropertyMap(), slot.getProperties()); + } } - return false; case 2: clickedSlot[0] = true; - return true; + selectedSlot = null; + if (shouldOpenMenu) { + menu.toggle(false); + for (Pair but : menu.getButtons()) { + for (Slider slider : but.getValue()) { + slider.updateSlider(); + buttonList.remove(slider); + } + } + } + if (editingField != null) + editingField.setText(""); } } - return false; - }).forEach(slot -> { - switch (mouseButton) { - case 0: - break; - case 1: - selectedSlot = slot; - editingField.setText(slot.getItemString()); - if (shouldOpenMenu) { - menu.toggle(true); - menu.getButtons().forEach(but -> { - for (Slider slider : but.getValue()) { - buttonList.remove(slider); - } - }); - menu.getFromMap(slot.getPropertyMap(), slot.getProperties()); - } - break; - case 2: - selectedSlot = null; - if (shouldOpenMenu) { - menu.toggle(false); - menu.getButtons().forEach(but -> { - for (Slider slider : but.getValue()) { - slider.updateSlider(); - buttonList.remove(slider); - } - }); - } - if (editingField != null) - editingField.setText(""); - break; - } - }); + } if (!clickedSlot[0]) { super.mouseClicked(mouseX, mouseY, mouseButton); } @@ -195,12 +181,17 @@ public abstract class GuiBase extends GuiContainer { generateFile(scriptFile); } try { - List lines = new LinkedList<>(); + List lines = new LinkedList(); BufferedReader reader = new BufferedReader(new FileReader(scriptFile)); - reader.lines().forEach(line -> lines.add(line)); + String line = ""; + while ((line = reader.readLine()) != null) { + lines.add(line); + } if (lines.isEmpty()) { generateFile(scriptFile); - reader.lines().forEach(line -> lines.add(line)); + while ((line = reader.readLine()) != null) { + lines.add(line); + } } reader.close(); PrintWriter writer = new PrintWriter(new FileWriter(scriptFile)); @@ -209,14 +200,14 @@ public abstract class GuiBase extends GuiContainer { if (i > 0) beforeLine = lines.get(i - 1); - String line = lines.get(i); + String lined = lines.get(i); if (beforeLine.trim().equals("//#Remove")) { } if (beforeLine.trim().equals("//#Add")) { writer.println(getOutputAdd()); } - if (!line.isEmpty()) { - writer.println(line); + if (!lined.isEmpty()) { + writer.println(lined); } } @@ -234,12 +225,17 @@ public abstract class GuiBase extends GuiContainer { } try { - List lines = new LinkedList<>(); + List lines = new LinkedList(); BufferedReader reader = new BufferedReader(new FileReader(scriptFile)); - reader.lines().forEach(line -> lines.add(line)); + String line = ""; + while ((line = reader.readLine()) != null) { + lines.add(line); + } if (lines.isEmpty()) { generateFile(scriptFile); - reader.lines().forEach(line -> lines.add(line)); + while ((line = reader.readLine()) != null) { + lines.add(line); + } } reader.close(); PrintWriter writer = new PrintWriter(new FileWriter(scriptFile)); @@ -248,14 +244,14 @@ public abstract class GuiBase extends GuiContainer { if (i > 0) beforeLine = lines.get(i - 1); - String line = lines.get(i); + String lined = lines.get(i); if (beforeLine.trim().equals("//#Remove")) { writer.println(getOutputRemove()); } if (beforeLine.trim().equals("//#Add")) { } - if (!line.isEmpty()) { - writer.println(line); + if (!lined.isEmpty()) { + writer.println(lined); } } writer.close(); diff --git a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/Slider.java b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/Slider.java index 503e82b..4536151 100644 --- a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/Slider.java +++ b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/Slider.java @@ -8,6 +8,11 @@ import net.minecraftforge.fml.client.config.GuiSlider; public class Slider extends GuiSlider { private String propertyKey; + public Slider(String propertyKey, int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr) { + super(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr); + this.propertyKey = propertyKey; + } + public Slider(String propertyKey, int id, int xPos, int yPos, int width, int height, String prefix, String suf, double minVal, double maxVal, double currentVal, boolean showDec, boolean drawStr, ISlider par) { super(id, xPos, yPos, width, height, prefix, suf, minVal, maxVal, currentVal, showDec, drawStr, par); this.propertyKey = propertyKey; diff --git a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/SlotRecipe.java b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/SlotRecipe.java index 3e59de2..7292878 100644 --- a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/SlotRecipe.java +++ b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/api/SlotRecipe.java @@ -18,8 +18,8 @@ import java.util.Map; public class SlotRecipe extends Slot { //key is the operation, value is the values, for more than 1 value, seperate using ยง - private Map propertyMap = new HashMap<>(); - private Map properties = new HashMap<>(); + private Map propertyMap = new HashMap(); + private Map properties = new HashMap(); public SlotRecipe(IInventory inventoryIn, int index, int xPosition, int yPosition) { diff --git a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/GuiMenu.java b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/GuiMenu.java index 8f1e9f7..bcfc0ac 100644 --- a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/GuiMenu.java +++ b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/GuiMenu.java @@ -3,6 +3,8 @@ package com.blamejared.ctgui.client.gui; import com.blamejared.ctgui.api.CheckButtonRecipe; import com.blamejared.ctgui.api.GuiBase; import com.blamejared.ctgui.api.Slider; +import net.minecraft.client.gui.GuiButton; +import net.minecraftforge.fml.client.config.GuiSlider; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -18,7 +20,7 @@ public class GuiMenu { private GuiBase parent; private int x; private int y; - private List> buttons = new ArrayList<>(); + private List> buttons = new ArrayList>(); // public Pair matchNotEmpty; public Pair useOreDict; public Pair matchAnyMetadata; @@ -42,40 +44,52 @@ public class GuiMenu { public GuiMenu() { } - public void open(GuiBase parent, int x, int y) { + public void open(final GuiBase parent, int x, int y) { this.parent = parent; this.x = x; this.y = y; int buttonCount = 0; // matchNotEmpty = new MutablePair<>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "Match Not Empty", false, "matchNotEmpty"), new Slider[]{}); - useOreDict = new MutablePair<>(new CheckButtonRecipe(parent, 1, x, y + (15 * buttonCount++), "Ore Dictionary", false, "oreDictionary"), new Slider[]{}); - matchAnyMetadata = new MutablePair<>(new CheckButtonRecipe(parent, 2, x, y + (15 * buttonCount++), "Any Metadata", false, "anyMetadata"), new Slider[]{}); - anyDamage = new MutablePair<>(new CheckButtonRecipe(parent, 3, x, y + (15 * buttonCount++), "Any Damage", false, "anyDamage"), new Slider[]{}); - onlyDamage = new MutablePair<>(new CheckButtonRecipe(parent, 4, x, y + (15 * buttonCount++), "Only Damage", false, "onlyDamage"), new Slider[]{}); - greaterThanEqualDamage = new MutablePair<>(new CheckButtonRecipe(parent, 6, x, y + (15 * buttonCount++), "X>=Damage", false, "gted"), new Slider[]{new Slider("gted", 10, x - 2, parent.getGuiTop() + parent.getYSize() + 20, parent.getXSize() + 102, 20, "X= ", "", 0, 0, 0, false, true, slider -> { - if (parent.selectedSlot != null && parent.selectedSlot.getStack() != null) { - parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt()); + useOreDict = new MutablePair(new CheckButtonRecipe(parent, 1, x, y + (15 * buttonCount++), "Ore Dictionary", false, "oreDictionary"), new Slider[]{}); + matchAnyMetadata = new MutablePair(new CheckButtonRecipe(parent, 2, x, y + (15 * buttonCount++), "Any Metadata", false, "anyMetadata"), new Slider[]{}); + anyDamage = new MutablePair(new CheckButtonRecipe(parent, 3, x, y + (15 * buttonCount++), "Any Damage", false, "anyDamage"), new Slider[]{}); + onlyDamage = new MutablePair(new CheckButtonRecipe(parent, 4, x, y + (15 * buttonCount++), "Only Damage", false, "onlyDamage"), new Slider[]{}); + greaterThanEqualDamage = new MutablePair(new CheckButtonRecipe(parent, 6, x, y + (15 * buttonCount++), "X>=Damage", false, "gted"), new Slider[]{new Slider("gted", 10, x - 2, parent.getGuiTop() + parent.getYSize() + 20, parent.getXSize() + 102, 20, "X= ", "", 0, 0, 0, false, true, new GuiSlider.ISlider() { + @Override + public void onChangeSliderValue(GuiSlider slider) { + if (parent.selectedSlot != null && parent.selectedSlot.getStack() != null) { + parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt()); + } } })}); - lessThanDamage = new MutablePair<>(new CheckButtonRecipe(parent, 7, x, y + (15 * buttonCount++), "Damage { - if (parent.selectedSlot != null && parent.selectedSlot.getStack() != null) { - parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt()); + lessThanDamage = new MutablePair(new CheckButtonRecipe(parent, 7, x, y + (15 * buttonCount++), "Damage(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "X { - if (parent.selectedSlot != null && parent.selectedSlot.getStack() != null) { - parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt()); + betweenDamage = new MutablePair(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "X { - if (parent.selectedSlot != null && parent.selectedSlot.getStack() != null) { - parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt()); + }), new Slider("betweenDamageY", 13, x - 2, parent.getGuiTop() + parent.getYSize() + 44, parent.getXSize() + 102, 20, "Y= ", "", 0, 0, 0, false, true, new GuiSlider.ISlider() { + @Override + public void onChangeSliderValue(GuiSlider slider) { + if (parent.selectedSlot != null && parent.selectedSlot.getStack() != null) { + parent.selectedSlot.getProperties().put(((Slider) slider).getPropertyKey(), slider.getValueInt()); + } } })}); - nbt = new MutablePair<>(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "NBT", false, "nbt"), new Slider[]{}); + nbt = new MutablePair(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "NBT", false, "nbt"), new Slider[]{}); - reuse = new MutablePair<>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "Reuse", false, "reuse"), new Slider[]{}); - noReturn = new MutablePair<>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "No Return", false, "noreturn"), new Slider[]{}); + reuse = new MutablePair(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "Reuse", false, "reuse"), new Slider[]{}); + noReturn = new MutablePair(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "No Return", false, "noreturn"), new Slider[]{}); this.buttons.add(useOreDict); @@ -92,20 +106,22 @@ public class GuiMenu { this.buttons.add(reuse); this.buttons.add(noReturn); - this.buttons.forEach(but -> parent.getButtonList().add(but.getLeft())); + for (Pair but : this.buttons) { + parent.getButtonList().add(but.getLeft()); + } - useOreDict.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft(), nbt.getLeft()})); - matchAnyMetadata.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); - anyDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); - onlyDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); + useOreDict.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft(), nbt.getLeft()})); + matchAnyMetadata.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); + anyDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); + onlyDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); - greaterThanEqualDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); - lessThanDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), betweenDamage.getLeft()})); - betweenDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft()})); + greaterThanEqualDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()})); + lessThanDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), betweenDamage.getLeft()})); + betweenDamage.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft()})); - nbt.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft()})); - noReturn.getLeft().setIncompatible(Arrays.asList(reuse.getLeft())); - reuse.getLeft().setIncompatible(Arrays.asList(noReturn.getLeft())); + nbt.getLeft().setIncompatible(Arrays.asList(new CheckButtonRecipe[]{useOreDict.getLeft()})); + noReturn.getLeft().setIncompatible(Arrays.asList(reuse.getLeft())); + reuse.getLeft().setIncompatible(Arrays.asList(noReturn.getLeft())); } diff --git a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/craftingtable/GuiCraftingTable.java b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/craftingtable/GuiCraftingTable.java index cd2cd86..e7f234d 100644 --- a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/craftingtable/GuiCraftingTable.java +++ b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/craftingtable/GuiCraftingTable.java @@ -4,6 +4,7 @@ import com.blamejared.ctgui.api.CheckButton; import com.blamejared.ctgui.api.ContainerBase; import com.blamejared.ctgui.api.GuiBase; import com.blamejared.ctgui.api.SlotRecipe; +import net.minecraft.client.gui.GuiButton; import net.minecraft.util.ResourceLocation; import java.util.Arrays; @@ -35,8 +36,8 @@ public class GuiCraftingTable extends GuiBase { getButtonList().add(shapeless); getButtonList().add(shaped); getButtonList().add(mirror); - shaped.setIncompatible(Arrays.asList(shapeless)); - shapeless.setIncompatible(Arrays.asList(shaped, mirror)); + shaped.setIncompatible(Arrays.asList(shapeless)); + shapeless.setIncompatible(Arrays.asList(shaped, mirror)); mirror.setIncompatible(Arrays.asList(remove)); shaped.setIsChecked(true); diff --git a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/furnace/GuiFurnace.java b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/furnace/GuiFurnace.java index 4edb18e..63c542e 100644 --- a/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/furnace/GuiFurnace.java +++ b/MineTweaker3-MC1102-Main/src/main/java/com/blamejared/ctgui/client/gui/furnace/GuiFurnace.java @@ -18,8 +18,7 @@ public class GuiFurnace extends GuiBase { @Override public void initGui() { super.initGui(); - xpSlider = new Slider("slider", 10, getGuiLeft() - 102 - 2, getGuiTop() + getYSize() + 20, getXSize()+102, 20, "XP= ", "", 0, 50, 0, true, true, slider -> { - }); + xpSlider = new Slider("slider", 10, getGuiLeft() - 102 - 2, getGuiTop() + getYSize() + 20, getXSize() + 102, 20, "XP= ", "", 0, 50, 0, true, true); getButtonList().add(xpSlider); }