summaryrefslogtreecommitdiff
path: root/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
diff options
context:
space:
mode:
authorbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 15:50:07 -0400
committerbculkin2442 <bjculkin@mix.wvu.edu>2018-05-24 15:50:07 -0400
commit4f7ad220df0438b6f3382110577b53f29da46453 (patch)
tree07d5e7c812721753cdbe3df7226dad5dc3802c29 /src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
parent01c8701b68986ccfa83e902515716838d6829311 (diff)
Update of all changes
Diffstat (limited to 'src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java')
-rwxr-xr-x[-rw-r--r--]src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java226
1 files changed, 167 insertions, 59 deletions
diff --git a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
index 23f137f..df8035c 100644..100755
--- a/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
+++ b/src/main/java/darkknight/jewelrycraft/client/gui/GuiJewelryModifier.java
@@ -4,8 +4,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
+
import darkknight.jewelrycraft.JewelrycraftMod;
import darkknight.jewelrycraft.client.gui.container.ContainerJewelryModifier;
import darkknight.jewelrycraft.network.PacketRequestSetSlot;
@@ -22,13 +24,21 @@ import net.minecraft.util.ResourceLocation;
public class GuiJewelryModifier extends GuiContainer {
private ResourceLocation texture;
private GuiTextField searchField, pages;
- private int page = 1, maxPages = 1, selectedX = 0, selectedY = 0, selectedPage = 0, enabled = 0;
+ private int page =
+ 1, maxPages = 1, selectedX = 0, selectedY = 0,
+ selectedPage = 0, enabled = 0;
private ItemStack selectedItem;
- private ArrayList<ItemStack> selectedItems = new ArrayList<ItemStack>();
- private List<Map<Integer, Map<Integer, Integer>>> selectedItemsPos = new ArrayList<Map<Integer, Map<Integer, Integer>>>();
+ private ArrayList<
+ ItemStack> selectedItems =
+ new ArrayList<>();
+ private List<Map<Integer,
+ Map<Integer,
+ Integer>>> selectedItemsPos =
+ new ArrayList<>();
ContainerJewelryModifier jMod;
- public GuiJewelryModifier(ContainerJewelryModifier containerJewelryTab, ResourceLocation texture) {
+ public GuiJewelryModifier(ContainerJewelryModifier containerJewelryTab,
+ ResourceLocation texture) {
super(containerJewelryTab);
xSize = 211;
ySize = 247;
@@ -38,17 +48,24 @@ public class GuiJewelryModifier extends GuiContainer {
}
@Override
- public void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
+ public void drawGuiContainerBackgroundLayer(float f, int mouseX,
+ int mouseY) {
GL11.glColor3f(1, 1, 1);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
int k = (this.width - this.xSize) / 2;
int l = (this.height - this.ySize) / 2;
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
- if (selectedX != 0 && selectedY != 0 && page == selectedPage) drawTexturedModalRect(k + selectedX, l + selectedY, 211, 0, 18, 18);
- for (Map<Integer, Map<Integer, Integer>> items : selectedItemsPos) {
+ if (selectedX != 0 && selectedY != 0 && page == selectedPage)
+ drawTexturedModalRect(k + selectedX, l + selectedY, 211, 0, 18,
+ 18);
+ for (Map<Integer,
+ Map<Integer, Integer>> items : selectedItemsPos) {
for (Object itemPage : items.keySet()) {
- if (page == (Integer) itemPage) for (int x : ((Map<Integer, Integer>) items.get(itemPage)).keySet())
- drawTexturedModalRect(k + x, l + (int) ((Map<Integer, Integer>) items.get(itemPage)).get(x), 211, 0, 18, 18);
+ if (page == (Integer) itemPage)
+ for (int x : items.get(itemPage).keySet())
+ drawTexturedModalRect(k + x,
+ l + items.get(itemPage).get(x), 211, 0, 18,
+ 18);
}
}
this.searchField.drawTextBox();
@@ -59,16 +76,29 @@ public class GuiJewelryModifier extends GuiContainer {
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
int i = 0;
for (ItemStack item : JewelrycraftUtil.objects) {
- if (item != null && item.getItem() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
+ if (item != null && item.getItem() != null
+ && (this.searchField.getText() == ""
+ || item.getDisplayName().toLowerCase()
+ .contains(this.searchField.getText()
+ .toLowerCase()))) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glColor3f(1F, 1F, 1F);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
- if (i >= (page - 1) * 48 && i < page * 48) try {
- itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), item, 88 + 20 * (i % 6), 7 + 17 * (i / 6) - 136 * (page - 1));
- } catch (Exception e) {
- JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage() + "\nThe item causing the issue is: " + item);
- }
+ if (i >= (page - 1) * 48 && i < page * 48)
+ try {
+ itemRender.renderItemAndEffectIntoGUI(
+ this.fontRendererObj,
+ this.mc.getTextureManager(), item,
+ 88 + 20 * (i % 6),
+ 7 + 17 * (i / 6) - 136 * (page - 1));
+ } catch (Exception e) {
+ JewelrycraftMod.logger
+ .info("Trying to display an item but gets this error: "
+ + e.getMessage()
+ + "\nThe item causing the issue is: "
+ + item);
+ }
GL11.glDisable(GL11.GL_LIGHTING);
i++;
}
@@ -80,22 +110,35 @@ public class GuiJewelryModifier extends GuiContainer {
if (this.searchField.textboxKeyTyped(character, key)) {
int items = 0;
for (ItemStack item : JewelrycraftUtil.objects)
- if (item != null && searchField != null && searchField.getText() != "" && item.getItem() != null && item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase())) items++;
+ if (item != null && searchField != null
+ && searchField.getText() != ""
+ && item.getItem() != null
+ && item.getDisplayName().toLowerCase().contains(
+ this.searchField.getText().toLowerCase()))
+ items++;
maxPages = items / 48 + 1;
page = 1;
this.pages.setText(page + "/" + maxPages);
- } else super.keyTyped(character, key);
+ } else
+ super.keyTyped(character, key);
}
+ @Override
protected void mouseClicked(int x, int y, int id) {
super.mouseClicked(x, y, id);
- if (x >= this.searchField.xPosition && x <= this.searchField.xPosition + this.searchField.width && y >= this.searchField.yPosition && y <= this.searchField.yPosition + this.searchField.height) {
+ if (x >= this.searchField.xPosition
+ && x <= this.searchField.xPosition + this.searchField.width
+ && y >= this.searchField.yPosition
+ && y <= this.searchField.yPosition
+ + this.searchField.height) {
this.searchField.setText("");
this.searchField.setFocused(true);
maxPages = JewelrycraftUtil.objects.size() / 48 + 1;
- } else this.searchField.setFocused(false);
+ } else
+ this.searchField.setFocused(false);
for (Object button : this.buttonList) {
- if (((GuiButton) button).id < 4 && ((GuiButton) button).mousePressed(mc, x, y)) {
+ if (((GuiButton) button).id < 4
+ && ((GuiButton) button).mousePressed(mc, x, y)) {
if (((GuiButton) button).id != 3) {
this.selectedItems.removeAll(selectedItems);
this.selectedItemsPos.removeAll(selectedItemsPos);
@@ -114,18 +157,35 @@ public class GuiJewelryModifier extends GuiContainer {
}
int i = 0;
for (ItemStack item : JewelrycraftUtil.objects) {
- if (item != null && item.getItem() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
- if (i >= (page - 1) * 48 && i < page * 48 && x >= this.guiLeft + 88 + 20 * (i % 6) && x < this.guiLeft + 108 + 20 * (i % 6) && y >= this.guiTop + 9 + 17 * (i / 6) - 136 * (page - 1) && y < this.guiTop + 25 + 17 * (i / 6) - 136 * (page - 1)) {
+ if (item != null && item.getItem() != null
+ && (this.searchField.getText() == ""
+ || item.getDisplayName().toLowerCase()
+ .contains(this.searchField.getText()
+ .toLowerCase()))) {
+ if (i >= (page - 1) * 48 && i < page * 48
+ && x >= this.guiLeft + 88 + 20 * (i % 6)
+ && x < this.guiLeft + 108 + 20 * (i % 6)
+ && y >= this.guiTop + 9 + 17 * (i / 6)
+ - 136 * (page - 1)
+ && y < this.guiTop + 25 + 17 * (i / 6)
+ - 136 * (page - 1)) {
try {
- if (!((GuiButton) buttonList.get(0)).enabled || !((GuiButton) buttonList.get(1)).enabled || !((GuiButton) buttonList.get(2)).enabled) {
+ if (!((GuiButton) buttonList.get(0)).enabled
+ || !((GuiButton) buttonList.get(1)).enabled
+ || !((GuiButton) buttonList
+ .get(2)).enabled) {
this.selectedItem = item;
this.selectedX = 87 + 20 * (i % 6);
- this.selectedY = 6 + 17 * (i / 6) - 136 * (page - 1);
+ this.selectedY =
+ 6 + 17 * (i / 6) - 136 * (page - 1);
this.selectedPage = page;
- } else if (!((GuiButton) buttonList.get(3)).enabled) {
- Map<Integer, Map<Integer, Integer>> itemPage = new HashMap<Integer, Map<Integer, Integer>>();
- Map<Integer, Integer> pos = new HashMap<Integer, Integer>();
- pos.put(87 + 20 * (i % 6), 6 + 17 * (i / 6) - 136 * (page - 1));
+ } else if (!((GuiButton) buttonList
+ .get(3)).enabled) {
+ Map<Integer, Map<Integer, Integer>> itemPage =
+ new HashMap<>();
+ Map<Integer, Integer> pos = new HashMap<>();
+ pos.put(87 + 20 * (i % 6),
+ 6 + 17 * (i / 6) - 136 * (page - 1));
itemPage.put(page, pos);
if (!this.selectedItems.contains(item)) {
this.selectedItems.add(item);
@@ -136,35 +196,57 @@ public class GuiJewelryModifier extends GuiContainer {
}
}
} catch (Exception e) {
- JewelrycraftMod.logger.info("Trying to display an item but gets this error: " + e.getMessage() + "\nThe item causing the issue is: " + item);
+ JewelrycraftMod.logger
+ .info("Trying to display an item but gets this error: "
+ + e.getMessage()
+ + "\nThe item causing the issue is: "
+ + item);
}
}
i++;
}
}
- if (((GuiButton) buttonList.get(5)).mousePressed(mc, x, y) && page > 1) page--;
- if (((GuiButton) buttonList.get(6)).mousePressed(mc, x, y) && page < maxPages) page++;
+ if (((GuiButton) buttonList.get(5)).mousePressed(mc, x, y)
+ && page > 1)
+ page--;
+ if (((GuiButton) buttonList.get(6)).mousePressed(mc, x, y)
+ && page < maxPages)
+ page++;
if (jMod.modInv.getStackInSlot(36) != null) {
ItemStack targetItem = jMod.modInv.getStackInSlot(36).copy();
- if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton) buttonList.get(0)).enabled) {
+ if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y)
+ && !((GuiButton) buttonList.get(0)).enabled) {
JewelryNBT.addIngotColor(targetItem, 16777215);
- JewelryNBT.addMetal(targetItem, new ItemStack(Item.getItemById(0), 0, 0));
- if (selectedItem != null) JewelryNBT.addMetal(targetItem, this.selectedItem);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem));
+ JewelryNBT.addMetal(targetItem,
+ new ItemStack(Item.getItemById(0), 0, 0));
+ if (selectedItem != null)
+ JewelryNBT.addMetal(targetItem, this.selectedItem);
+ JewelrycraftMod.netWrapper.sendToServer(
+ new PacketRequestSetSlot(targetItem));
}
- if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton) buttonList.get(1)).enabled) {
+ if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y)
+ && !((GuiButton) buttonList.get(1)).enabled) {
JewelryNBT.addGemColor(targetItem, 16777215);
- JewelryNBT.addGem(targetItem, new ItemStack(Item.getItemById(0), 0, 0));
- if (selectedItem != null) JewelryNBT.addGem(targetItem, this.selectedItem);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem));
+ JewelryNBT.addGem(targetItem,
+ new ItemStack(Item.getItemById(0), 0, 0));
+ if (selectedItem != null)
+ JewelryNBT.addGem(targetItem, this.selectedItem);
+ JewelrycraftMod.netWrapper.sendToServer(
+ new PacketRequestSetSlot(targetItem));
}
- if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton) buttonList.get(2)).enabled) {
- if (selectedItem != null) JewelryNBT.addItem(targetItem, selectedItem);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem));
+ if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y)
+ && !((GuiButton) buttonList.get(2)).enabled) {
+ if (selectedItem != null)
+ JewelryNBT.addItem(targetItem, selectedItem);
+ JewelrycraftMod.netWrapper.sendToServer(
+ new PacketRequestSetSlot(targetItem));
}
- if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y) && !((GuiButton) buttonList.get(3)).enabled) {
- if (!selectedItems.isEmpty()) JewelryNBT.addModifiers(targetItem, selectedItems);
- JewelrycraftMod.netWrapper.sendToServer(new PacketRequestSetSlot(targetItem));
+ if (((GuiButton) buttonList.get(4)).mousePressed(mc, x, y)
+ && !((GuiButton) buttonList.get(3)).enabled) {
+ if (!selectedItems.isEmpty())
+ JewelryNBT.addModifiers(targetItem, selectedItems);
+ JewelrycraftMod.netWrapper.sendToServer(
+ new PacketRequestSetSlot(targetItem));
}
}
this.pages.setText(page + "/" + maxPages);
@@ -173,36 +255,62 @@ public class GuiJewelryModifier extends GuiContainer {
@Override
public void initGui() {
super.initGui();
- this.searchField = new GuiTextField(this.fontRendererObj, this.guiLeft + 89, this.guiTop + 148, 115, this.fontRendererObj.FONT_HEIGHT + 3);
+ this.searchField = new GuiTextField(this.fontRendererObj,
+ this.guiLeft + 89, this.guiTop + 148, 115,
+ this.fontRendererObj.FONT_HEIGHT + 3);
this.searchField.setMaxStringLength(15);
this.searchField.setTextColor(16777215);
this.searchField.setVisible(true);
this.searchField.setCanLoseFocus(true);
- this.pages = new GuiTextField(this.fontRendererObj, this.guiLeft + 20, this.guiTop + 146, 50, this.fontRendererObj.FONT_HEIGHT + 3);
+ this.pages = new GuiTextField(this.fontRendererObj,
+ this.guiLeft + 20, this.guiTop + 146, 50,
+ this.fontRendererObj.FONT_HEIGHT + 3);
this.pages.setMaxStringLength(15);
this.pages.setTextColor(16777215);
this.pages.setVisible(true);
this.pages.setText(page + "/" + maxPages);
- this.buttonList.add(new GuiButton(0, this.guiLeft + 17, this.guiTop + 30, 52, 20, "Metal"));
- this.buttonList.add(new GuiButton(1, this.guiLeft + 17, this.guiTop + 52, 52, 20, "Gem"));
- this.buttonList.add(new GuiButton(2, this.guiLeft + 17, this.guiTop + 74, 52, 20, "Item"));
- this.buttonList.add(new GuiButton(3, this.guiLeft + 17, this.guiTop + 96, 52, 20, "Modifiers"));
- this.buttonList.add(new GuiButton(4, this.guiLeft + 17, this.guiTop + 118, 52, 20, "Add Items"));
- this.buttonList.add(new GuiButton(5, this.guiLeft + 5, this.guiTop + 142, 13, 20, "<<"));
- this.buttonList.add(new GuiButton(6, this.guiLeft + 73, this.guiTop + 142, 13, 20, ">>"));
+ this.buttonList.add(new GuiButton(0, this.guiLeft + 17,
+ this.guiTop + 30, 52, 20, "Metal"));
+ this.buttonList.add(new GuiButton(1, this.guiLeft + 17,
+ this.guiTop + 52, 52, 20, "Gem"));
+ this.buttonList.add(new GuiButton(2, this.guiLeft + 17,
+ this.guiTop + 74, 52, 20, "Item"));
+ this.buttonList.add(new GuiButton(3, this.guiLeft + 17,
+ this.guiTop + 96, 52, 20, "Modifiers"));
+ this.buttonList.add(new GuiButton(4, this.guiLeft + 17,
+ this.guiTop + 118, 52, 20, "Add Items"));
+ this.buttonList.add(new GuiButton(5, this.guiLeft + 5,
+ this.guiTop + 142, 13, 20, "<<"));
+ this.buttonList.add(new GuiButton(6, this.guiLeft + 73,
+ this.guiTop + 142, 13, 20, ">>"));
((GuiButton) buttonList.get(enabled)).enabled = false;
}
+ @Override
public void drawScreen(int x, int y, float z) {
super.drawScreen(x, y, z);
int i = 0;
- List<String> list = new ArrayList<String>();
+ List<String> list = new ArrayList<>();
for (ItemStack item : JewelrycraftUtil.objects) {
- if (item != null && item.getItem() != null && (this.searchField.getText() == "" || item.getDisplayName().toLowerCase().contains(this.searchField.getText().toLowerCase()))) {
- if (i >= (page - 1) * 48 && i < page * 48 && x >= this.guiLeft + 88 + 20 * (i % 6) && x < this.guiLeft + 108 + 20 * (i % 6) && y >= this.guiTop + 9 + 17 * (i / 6) - 136 * (page - 1) && y < this.guiTop + 25 + 17 * (i / 6) - 136 * (page - 1)) {
+ if (item != null && item.getItem() != null
+ && (this.searchField.getText() == ""
+ || item.getDisplayName().toLowerCase()
+ .contains(this.searchField.getText()
+ .toLowerCase()))) {
+ if (i >= (page - 1) * 48 && i < page * 48
+ && x >= this.guiLeft + 88 + 20 * (i % 6)
+ && x < this.guiLeft + 108 + 20 * (i % 6)
+ && y >= this.guiTop + 9 + 17 * (i / 6)
+ - 136 * (page - 1)
+ && y < this.guiTop + 25 + 17 * (i / 6)
+ - 136 * (page - 1)) {
list.add(item.getDisplayName());
- if (item.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips) != null) this.renderToolTip(item, x, y);
- else this.drawHoveringText(list, x, y, this.fontRendererObj);
+ if (item.getTooltip(mc.thePlayer,
+ mc.gameSettings.advancedItemTooltips) != null)
+ this.renderToolTip(item, x, y);
+ else
+ this.drawHoveringText(list, x, y,
+ this.fontRendererObj);
}
i++;
}