Some clean up of some code
This commit is contained in:
parent
9e4151f5fa
commit
43da219936
7 changed files with 171 additions and 169 deletions
|
@ -1,6 +1,9 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
|
||||
|
@ -12,74 +15,76 @@ public class ContainerIDSU extends TechRebornContainer {
|
|||
TileIDSU tile;
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int euOut;
|
||||
public int storedEu;
|
||||
public int euChange;
|
||||
public int channel;
|
||||
|
||||
public ContainerIDSU(TileIDSU tileIDSU,
|
||||
EntityPlayer player)
|
||||
{
|
||||
EntityPlayer player) {
|
||||
tile = tileIDSU;
|
||||
this.player = player;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
for (i = 0; i < 3; ++i) {
|
||||
for (int j = 0; j < 9; ++j) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9
|
||||
+ 9, 7 + j * 16, 84 + i * 18 + 30));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
for (i = 0; i < 9; ++i) {
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 7 + i * 16,
|
||||
142 + 30));
|
||||
}
|
||||
}
|
||||
//
|
||||
// @Override
|
||||
// public void detectAndSendChanges() {
|
||||
// super.detectAndSendChanges();
|
||||
// for (int i = 0; i < this.crafters.size(); i++) {
|
||||
// ICrafting icrafting = (ICrafting)this.crafters.get(i);
|
||||
// if(this.euOut != tile.output){
|
||||
// icrafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||
// }
|
||||
// if(this.storedEu != tile.energy){
|
||||
// icrafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
|
||||
// }
|
||||
// if(this.euChange != tile.getEuChange() && tile.getEuChange() != -1){
|
||||
// icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void addCraftingToCrafters(ICrafting crafting) {
|
||||
// super.addCraftingToCrafters(crafting);
|
||||
// crafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||
// crafting.sendProgressBarUpdate(this, 1, (int) tile.energy);
|
||||
// crafting.sendProgressBarUpdate(this, 2 , (int) tile.getEuChange());
|
||||
// }
|
||||
//
|
||||
// @SideOnly(Side.CLIENT)
|
||||
// @Override
|
||||
// public void updateProgressBar(int id, int value) {
|
||||
// if(id == 0){
|
||||
// this.euOut = value;
|
||||
// } else if(id == 1){
|
||||
// this.storedEu = value;
|
||||
// } else if(id == 2){
|
||||
// this.euChange = value;
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges() {
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++) {
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.euOut != tile.output) {
|
||||
icrafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||
}
|
||||
if (this.storedEu != (int) tile.getEnergy()) {
|
||||
icrafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
||||
}
|
||||
if (this.euChange != tile.getEuChange() && tile.getEuChange() != -1) {
|
||||
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||
}
|
||||
if (this.channel != tile.channelID) {
|
||||
icrafting.sendProgressBarUpdate(this, 3, tile.channelID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCraftingToCrafters(ICrafting crafting) {
|
||||
super.addCraftingToCrafters(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 0, tile.output);
|
||||
crafting.sendProgressBarUpdate(this, 1, (int) tile.getEnergy());
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEuChange());
|
||||
crafting.sendProgressBarUpdate(this, 3, tile.channelID);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value) {
|
||||
if (id == 0) {
|
||||
this.euOut = value;
|
||||
} else if (id == 1) {
|
||||
this.storedEu = value;
|
||||
} else if (id == 2) {
|
||||
this.euChange = value;
|
||||
} else if (id == 3) {
|
||||
this.channel = value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,25 +4,16 @@ import net.minecraft.client.gui.GuiButton;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
import net.minecraft.world.World;
|
||||
import techreborn.client.container.ContainerIDSU;
|
||||
import techreborn.client.gui.componets.TabIDConfig;
|
||||
import techreborn.cofhLib.gui.GuiBase;
|
||||
import techreborn.cofhLib.gui.element.ElementListBox;
|
||||
import techreborn.cofhLib.gui.element.ElementTextField;
|
||||
import techreborn.cofhLib.gui.element.ElementTextFieldLimited;
|
||||
import techreborn.cofhLib.gui.element.listbox.IListBoxElement;
|
||||
import techreborn.cofhLib.gui.element.listbox.ListBoxElementText;
|
||||
import techreborn.packets.PacketHandler;
|
||||
import techreborn.packets.PacketIdsu;
|
||||
import techreborn.tiles.idsu.ClientSideIDSUManager;
|
||||
import techreborn.tiles.idsu.IDSUManager;
|
||||
import techreborn.tiles.idsu.TileIDSU;
|
||||
import techreborn.util.LogHelper;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
public class GuiIDSU extends GuiBase {
|
||||
|
||||
|
||||
|
@ -36,15 +27,13 @@ public class GuiIDSU extends GuiBase {
|
|||
ElementTextField nameFeild;
|
||||
|
||||
|
||||
|
||||
public GuiIDSU(EntityPlayer player,
|
||||
TileIDSU tileIDSU)
|
||||
{
|
||||
TileIDSU tileIDSU) {
|
||||
super(new ContainerIDSU(tileIDSU, player));
|
||||
this.xSize = 156;
|
||||
this.ySize = 200;
|
||||
idsu = tileIDSU;
|
||||
this.containerIDSU = (ContainerIDSU) this.inventorySlots;
|
||||
this.containerIDSU = (ContainerIDSU) this.inventorySlots;
|
||||
texture = new ResourceLocation(
|
||||
"techreborn", "textures/gui/aesu.png");
|
||||
drawTitle = false;
|
||||
|
@ -60,17 +49,18 @@ public class GuiIDSU extends GuiBase {
|
|||
int l = (this.height - this.ySize) / 2;
|
||||
this.buttonList.add(new GuiButton(0, k + 96, l + 8, 18, 20, "++"));
|
||||
this.buttonList.add(new GuiButton(1, k + 96, l + 8 + 22, 18, 20, "+"));
|
||||
this.buttonList.add(new GuiButton(2, k + 96, l + 8 + (22*2), 18, 20, "-"));
|
||||
this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22*3), 18, 20, "--"));
|
||||
this.buttonList.add(new GuiButton(2, k + 96, l + 8 + (22 * 2), 18, 20, "-"));
|
||||
this.buttonList.add(new GuiButton(3, k + 96, l + 8 + (22 * 3), 18, 20, "--"));
|
||||
this.buttonList.add(new GuiButton(4, k + 40, l + 10, 10, 10, "+"));
|
||||
|
||||
listBox.gui = this;
|
||||
listBox.setSelectedIndex(containerIDSU.channel);
|
||||
|
||||
// listBox.borderColor = new GuiColor(120, 120, 120, 0).getColor();
|
||||
// listBox.backgroundColor = new GuiColor(0, 0, 0, 32).getColor();
|
||||
addElement(listBox);
|
||||
|
||||
idFeild = new ElementTextFieldLimited(this, 10, 10, 30, 10, (short) 4);
|
||||
idFeild = new ElementTextFieldLimited(this, 10, 10, 30, 10, (short) 4);
|
||||
idFeild.setFilter("1234567890", false);
|
||||
|
||||
addElement(idFeild);
|
||||
|
@ -87,7 +77,7 @@ public class GuiIDSU extends GuiBase {
|
|||
@Override
|
||||
protected void actionPerformed(GuiButton button) {
|
||||
super.actionPerformed(button);
|
||||
if(isInteger(idFeild.getText())){
|
||||
if (isInteger(idFeild.getText())) {
|
||||
PacketHandler.sendPacketToServer(new PacketIdsu(button.id, idsu, Integer.parseInt(idFeild.getText()), nameFeild.getText()));
|
||||
} else {
|
||||
LogHelper.info("There was an issue in the gui!, Please report this to the TechReborn Devs");
|
||||
|
@ -96,17 +86,17 @@ public class GuiIDSU extends GuiBase {
|
|||
}
|
||||
|
||||
public static boolean isInteger(String s) {
|
||||
return isInteger(s,10);
|
||||
return isInteger(s, 10);
|
||||
}
|
||||
|
||||
public static boolean isInteger(String s, int radix) {
|
||||
if(s.isEmpty()) return false;
|
||||
for(int i = 0; i < s.length(); i++) {
|
||||
if(i == 0 && s.charAt(i) == '-') {
|
||||
if(s.length() == 1) return false;
|
||||
if (s.isEmpty()) return false;
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
if (i == 0 && s.charAt(i) == '-') {
|
||||
if (s.length() == 1) return false;
|
||||
else continue;
|
||||
}
|
||||
if(Character.digit(s.charAt(i),radix) < 0) return false;
|
||||
if (Character.digit(s.charAt(i), radix) < 0) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue