Converted everything to Java 6

This commit is contained in:
Jared committed 2016-10-20 01:41:12 +02:00
1 parent d087211939
commit a34b69b1f1
6 files changed
+106 -89

No files matched your search

@@ -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<CheckButtonRecipe, Slider[]> 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<CheckButtonRecipe, Slider[]> 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<String> lines = new LinkedList<>();
List<String> lines = new LinkedList<String>();
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<String> lines = new LinkedList<>();
List<String> lines = new LinkedList<String>();
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();
@@ -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;
@@ -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<String, Boolean> propertyMap = new HashMap<>();
private Map<String, Integer> properties = new HashMap<>();
private Map<String, Boolean> propertyMap = new HashMap<String, Boolean>();
private Map<String, Integer> properties = new HashMap<String, Integer>();
public SlotRecipe(IInventory inventoryIn, int index, int xPosition, int yPosition) {
@@ -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<Pair<CheckButtonRecipe, Slider[]>> buttons = new ArrayList<>();
private List<Pair<CheckButtonRecipe, Slider[]>> buttons = new ArrayList<Pair<CheckButtonRecipe, Slider[]>>();
// public Pair<CheckButtonRecipe, Slider[]> matchNotEmpty;
public Pair<CheckButtonRecipe, Slider[]> useOreDict;
public Pair<CheckButtonRecipe, Slider[]> 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<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 1, x, y + (15 * buttonCount++), "Ore Dictionary", false, "oreDictionary"), new Slider[]{});
matchAnyMetadata = new MutablePair<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 2, x, y + (15 * buttonCount++), "Any Metadata", false, "anyMetadata"), new Slider[]{});
anyDamage = new MutablePair<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 3, x, y + (15 * buttonCount++), "Any Damage", false, "anyDamage"), new Slider[]{});
onlyDamage = new MutablePair<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 4, x, y + (15 * buttonCount++), "Only Damage", false, "onlyDamage"), new Slider[]{});
greaterThanEqualDamage = new MutablePair<CheckButtonRecipe, Slider[]>(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<X", false, "ltd"), new Slider[]{new Slider("ltd", 11, 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());
lessThanDamage = new MutablePair<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 7, x, y + (15 * buttonCount++), "Damage<X", false, "ltd"), new Slider[]{new Slider("ltd", 11, 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());
}
}
})});
betweenDamage = new MutablePair<>(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "X<Damage<Y", false, "betweenDamage"), new Slider[]{new Slider("betweenDamageX", 12, 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());
betweenDamage = new MutablePair<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 8, x, y + (15 * buttonCount++), "X<Damage<Y", false, "betweenDamage"), new Slider[]{new Slider("betweenDamageX", 12, 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());
}
}
}), new Slider("betweenDamageY", 13, x - 2, parent.getGuiTop() + parent.getYSize() + 44, parent.getXSize() + 102, 20, "Y= ", "", 0, 0, 0, false, true, slider -> {
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<CheckButtonRecipe, Slider[]>(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<CheckButtonRecipe, Slider[]>(new CheckButtonRecipe(parent, 0, x, y + (15 * buttonCount++), "Reuse", false, "reuse"), new Slider[]{});
noReturn = new MutablePair<CheckButtonRecipe, Slider[]>(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<CheckButtonRecipe, Slider[]> 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.<GuiButton>asList(new CheckButtonRecipe[]{matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft(), nbt.getLeft()}));
matchAnyMetadata.getLeft().setIncompatible(Arrays.<GuiButton>asList(new CheckButtonRecipe[]{useOreDict.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
anyDamage.getLeft().setIncompatible(Arrays.<GuiButton>asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
onlyDamage.getLeft().setIncompatible(Arrays.<GuiButton>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.<GuiButton>asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), lessThanDamage.getLeft(), betweenDamage.getLeft()}));
lessThanDamage.getLeft().setIncompatible(Arrays.<GuiButton>asList(new CheckButtonRecipe[]{useOreDict.getLeft(), matchAnyMetadata.getLeft(), anyDamage.getLeft(), onlyDamage.getLeft(), greaterThanEqualDamage.getLeft(), betweenDamage.getLeft()}));
betweenDamage.getLeft().setIncompatible(Arrays.<GuiButton>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.<GuiButton>asList(new CheckButtonRecipe[]{useOreDict.getLeft()}));
noReturn.getLeft().setIncompatible(Arrays.<GuiButton>asList(reuse.getLeft()));
reuse.getLeft().setIncompatible(Arrays.<GuiButton>asList(noReturn.getLeft()));
}
@@ -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.<GuiButton>asList(shapeless));
shapeless.setIncompatible(Arrays.<GuiButton>asList(shaped, mirror));
mirror.setIncompatible(Arrays.asList(remove));
shaped.setIsChecked(true);
@@ -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);
}