diff --git a/src/common/net/uberkat/obsidian/common/BlockMulti.java b/src/common/net/uberkat/obsidian/common/BlockMulti.java index d57c683ad..1adfb3155 100644 --- a/src/common/net/uberkat/obsidian/common/BlockMulti.java +++ b/src/common/net/uberkat/obsidian/common/BlockMulti.java @@ -3,11 +3,13 @@ package net.uberkat.obsidian.common; import java.util.List; import java.util.Random; +import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.Side; import cpw.mods.fml.common.asm.SideOnly; import net.minecraft.src.*; import net.minecraftforge.common.ForgeChunkManager; +import net.uberkat.obsidian.client.GuiControlPanel; /** * Block class for handling multiple metal block IDs. @@ -72,6 +74,7 @@ public class BlockMulti extends Block if(entityplayer.isSneaking()) { entityplayer.openGui(ObsidianIngots.instance, 1, world, x, y, z); + //FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiControlPanel(entityplayer, world)); return true; } } diff --git a/src/common/net/uberkat/obsidian/common/ContainerAdvancedElectricMachine.java b/src/common/net/uberkat/obsidian/common/ContainerAdvancedElectricMachine.java index ef8a4e7a0..f238b4b17 100644 --- a/src/common/net/uberkat/obsidian/common/ContainerAdvancedElectricMachine.java +++ b/src/common/net/uberkat/obsidian/common/ContainerAdvancedElectricMachine.java @@ -1,7 +1,7 @@ package net.uberkat.obsidian.common; import obsidian.api.IEnergizedItem; -import obsidian.api.IMachineUpgrade; +import obsidian.api.ItemMachineUpgrade; import ic2.api.IElectricItem; import universalelectricity.implement.IItemElectric; import net.minecraft.src.*; @@ -142,7 +142,7 @@ public class ContainerAdvancedElectricMachine extends Container } } } - else if(slotStack.getItem() instanceof IMachineUpgrade) + else if(slotStack.getItem() instanceof ItemMachineUpgrade) { if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3 && slotID != 4) { diff --git a/src/common/net/uberkat/obsidian/common/ContainerElectricMachine.java b/src/common/net/uberkat/obsidian/common/ContainerElectricMachine.java index 503d8f219..1246619a0 100644 --- a/src/common/net/uberkat/obsidian/common/ContainerElectricMachine.java +++ b/src/common/net/uberkat/obsidian/common/ContainerElectricMachine.java @@ -1,7 +1,7 @@ package net.uberkat.obsidian.common; import obsidian.api.IEnergizedItem; -import obsidian.api.IMachineUpgrade; +import obsidian.api.ItemMachineUpgrade; import ic2.api.IElectricItem; import universalelectricity.implement.IItemElectric; import net.minecraft.src.*; @@ -99,7 +99,7 @@ public class ContainerElectricMachine extends Container } } } - else if(slotStack.getItem() instanceof IMachineUpgrade) + else if(slotStack.getItem() instanceof ItemMachineUpgrade) { if(slotID != 0 && slotID != 1 && slotID != 2 && slotID != 3) { diff --git a/src/common/net/uberkat/obsidian/common/ContainerGenerator.java b/src/common/net/uberkat/obsidian/common/ContainerGenerator.java index f83e3fe7c..311aa0133 100644 --- a/src/common/net/uberkat/obsidian/common/ContainerGenerator.java +++ b/src/common/net/uberkat/obsidian/common/ContainerGenerator.java @@ -2,7 +2,6 @@ package net.uberkat.obsidian.common; import ic2.api.IElectricItem; import obsidian.api.IEnergizedItem; -import obsidian.api.IMachineUpgrade; import universalelectricity.implement.IItemElectric; import net.minecraft.src.*; diff --git a/src/common/net/uberkat/obsidian/common/ItemMachineUpgrade.java b/src/common/net/uberkat/obsidian/common/ItemMachineUpgrade.java deleted file mode 100644 index 2dcb3e9d7..000000000 --- a/src/common/net/uberkat/obsidian/common/ItemMachineUpgrade.java +++ /dev/null @@ -1,17 +0,0 @@ -package net.uberkat.obsidian.common; - -import java.util.List; - -import net.minecraft.src.CreativeTabs; -import net.minecraft.src.ItemStack; -import obsidian.api.IMachineUpgrade; - -public class ItemMachineUpgrade extends ItemObsidian implements IMachineUpgrade -{ - public ItemMachineUpgrade(int i) - { - super(i); - setMaxStackSize(1); - setCreativeTab(ObsidianIngots.tabOBSIDIAN); - } -} diff --git a/src/common/net/uberkat/obsidian/common/MachineryManager.java b/src/common/net/uberkat/obsidian/common/MachineryManager.java index ce5e4625c..2d5e4fad8 100644 --- a/src/common/net/uberkat/obsidian/common/MachineryManager.java +++ b/src/common/net/uberkat/obsidian/common/MachineryManager.java @@ -93,6 +93,11 @@ public class MachineryManager } } + public int size() + { + return machines.size(); + } + /** * Resets the manager -- removing all machines from the ArrayList */ diff --git a/src/common/net/uberkat/obsidian/common/ObsidianIngots.java b/src/common/net/uberkat/obsidian/common/ObsidianIngots.java index dd7e0f143..31562d08f 100644 --- a/src/common/net/uberkat/obsidian/common/ObsidianIngots.java +++ b/src/common/net/uberkat/obsidian/common/ObsidianIngots.java @@ -14,6 +14,8 @@ import java.util.Properties; import java.util.Random; import java.util.logging.Logger; +import obsidian.api.ItemMachineUpgrade; + import net.minecraftforge.common.*; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.oredict.OreDictionary; @@ -1018,7 +1020,7 @@ public class ObsidianIngots proxy.loadUtilities(); proxy.loadTickHandler(); - LanguageRegistry.instance().addStringLocalization(tabOBSIDIAN.getTranslatedTabLabel(), "Obsidian Ingots"); + LanguageRegistry.instance().addStringLocalization("itemGroup.tabObsidian", "Obsidian Ingots"); //Attempt to load server commands try { diff --git a/src/common/net/uberkat/obsidian/common/SlotMachineUpgrade.java b/src/common/net/uberkat/obsidian/common/SlotMachineUpgrade.java index 2c8961ac8..ca5ffc2a0 100644 --- a/src/common/net/uberkat/obsidian/common/SlotMachineUpgrade.java +++ b/src/common/net/uberkat/obsidian/common/SlotMachineUpgrade.java @@ -1,7 +1,7 @@ package net.uberkat.obsidian.common; import net.minecraft.src.*; -import obsidian.api.IMachineUpgrade; +import obsidian.api.ItemMachineUpgrade; public class SlotMachineUpgrade extends Slot { @@ -12,6 +12,6 @@ public class SlotMachineUpgrade extends Slot public boolean isItemValid(ItemStack itemstack) { - return itemstack.getItem() instanceof IMachineUpgrade; + return itemstack.getItem() instanceof ItemMachineUpgrade; } } diff --git a/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java b/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java index 2ebcd5b75..156baaad2 100644 --- a/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java +++ b/src/common/net/uberkat/obsidian/common/TileEntityEnrichmentChamber.java @@ -3,10 +3,6 @@ package net.uberkat.obsidian.common; import java.util.List; import java.util.Vector; -import cpw.mods.fml.common.FMLCommonHandler; - -import net.minecraftforge.common.ISidedInventory; -import net.minecraftforge.common.ForgeDirection; import net.minecraft.src.*; public class TileEntityEnrichmentChamber extends TileEntityElectricMachine diff --git a/src/common/obsidian/api/IAccessibleGui.java b/src/common/obsidian/api/IAccessibleGui.java new file mode 100644 index 000000000..2d33d48db --- /dev/null +++ b/src/common/obsidian/api/IAccessibleGui.java @@ -0,0 +1,8 @@ +package obsidian.api; + +public interface IAccessibleGui +{ + public int getGuiID(); + + public Object getModInstance(); +} diff --git a/src/common/obsidian/api/IMachineUpgrade.java b/src/common/obsidian/api/IMachineUpgrade.java deleted file mode 100644 index cc4cae216..000000000 --- a/src/common/obsidian/api/IMachineUpgrade.java +++ /dev/null @@ -1,11 +0,0 @@ -package obsidian.api; - -/** - * Empty interface 'IMachineUpgrade' used for handling machine upgrade slots. - * @author AidanBrady - * - */ -public interface IMachineUpgrade -{ - -} diff --git a/src/common/obsidian/api/ItemMachineUpgrade.java b/src/common/obsidian/api/ItemMachineUpgrade.java new file mode 100644 index 000000000..14ce15008 --- /dev/null +++ b/src/common/obsidian/api/ItemMachineUpgrade.java @@ -0,0 +1,14 @@ +package obsidian.api; + +import net.minecraft.src.*; +import net.uberkat.obsidian.common.ObsidianIngots; + +public class ItemMachineUpgrade extends Item +{ + public ItemMachineUpgrade(int id) + { + super(id); + setMaxStackSize(1); + setCreativeTab(ObsidianIngots.tabOBSIDIAN); + } +} diff --git a/src/minecraft/net/uberkat/obsidian/client/GuiControlPanel.java b/src/minecraft/net/uberkat/obsidian/client/GuiControlPanel.java new file mode 100644 index 000000000..c9ad7a812 --- /dev/null +++ b/src/minecraft/net/uberkat/obsidian/client/GuiControlPanel.java @@ -0,0 +1,139 @@ +package net.uberkat.obsidian.client; + +import org.lwjgl.opengl.GL11; + +import obsidian.api.IAccessibleGui; +import net.minecraft.src.EntityPlayer; +import net.minecraft.src.GuiButton; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.GuiTextField; +import net.minecraft.src.World; +import net.uberkat.obsidian.common.EnumColor; +import net.uberkat.obsidian.common.ObsidianUtils; + +public class GuiControlPanel extends GuiScreen +{ + public EntityPlayer usingPlayer; + public World worldObj; + public String displayText = "Control Panel"; + public int ticker = 0; + public boolean useTicker = false; + + private GuiTextField xField; + private GuiTextField yField; + private GuiTextField zField; + + public GuiControlPanel(EntityPlayer player, World world) + { + usingPlayer = player; + worldObj = world; + } + + public void initGui() + { + super.initGui(); + controlList.clear(); + controlList.add(new GuiButton(0, width / 2 - 80, height / 4 + 72 + 12, 60, 20, "Access")); + + xField = new GuiTextField(fontRenderer, 50, 30, 45, 12); + xField.setMaxStringLength(4); + xField.setText("" + 0); + xField.setFocused(true); + xField.setVisible(true); + + yField = new GuiTextField(fontRenderer, 50, 50, 45, 12); + yField.setMaxStringLength(4); + yField.setText("" + 0); + yField.setVisible(true); + + zField = new GuiTextField(fontRenderer, 50, 80, 45, 12); + zField.setMaxStringLength(4); + zField.setText("" + 0); + zField.setVisible(true); + } + + public void drawScreen(int i, int j, float f) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int k = mc.renderEngine.getTexture("/gui/GuiControlPanel.png"); + mc.renderEngine.bindTexture(k); + drawTexturedModalRect(width / 2 - 100, height / 2 - 100, 0, 0, 176, 166); + super.drawScreen(i, j, f); + fontRenderer.drawString(displayText, 50, 96, 0x404040); + GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); + GL11.glEnable(GL11.GL_CULL_FACE); + GL11.glEnable(GL11.GL_ALPHA_TEST); + GL11.glEnable(GL11.GL_DEPTH_TEST); + } + + public void keyTyped(char c, int i) + { + super.keyTyped(c, i); + + if(Character.isDigit(c) || c == '-') + { + xField.textboxKeyTyped(c, i); + yField.textboxKeyTyped(c, i); + zField.textboxKeyTyped(c, i); + } + else { + useTicker = true; + } + } + + public void updateScreen() + { + xField.updateCursorCounter(); + yField.updateCursorCounter(); + zField.updateCursorCounter(); + + if(useTicker) + { + if(ticker < 40) + { + ticker++; + } + else { + useTicker = false; + ticker = 0; + displayText = "Control Panel"; + } + } + } + + public void mouseClicked(int x, int y, int z) + { + super.mouseClicked(x, y, z); + xField.mouseClicked(x, y, z); + yField.mouseClicked(x, y, z); + zField.mouseClicked(x, y, z); + } + + public void actionPerformed(GuiButton guibutton) + { + if(!guibutton.enabled) + { + return; + } + + if(guibutton.id == 0) + { + if(worldObj.getBlockTileEntity(Integer.parseInt(xField.getText()), Integer.parseInt(yField.getText()), Integer.parseInt(zField.getText())) != null) + { + if(worldObj.getBlockTileEntity(Integer.parseInt(xField.getText()), Integer.parseInt(yField.getText()), Integer.parseInt(zField.getText())) instanceof IAccessibleGui) + { + IAccessibleGui gui = (IAccessibleGui)worldObj.getBlockTileEntity(Integer.parseInt(xField.getText()), Integer.parseInt(yField.getText()), Integer.parseInt(zField.getText())); + usingPlayer.openGui(gui.getModInstance(), gui.getGuiID(), worldObj, Integer.parseInt(xField.getText()), Integer.parseInt(yField.getText()), Integer.parseInt(zField.getText())); + } + else { + displayText = EnumColor.DARK_RED + "Tile entity isn't available."; + useTicker = true; + } + } + else { + displayText = EnumColor.DARK_RED + "Tile entity doesn't exist."; + useTicker = true; + } + } + } +}