diff --git a/common/mekanism/client/ClientProxy.java b/common/mekanism/client/ClientProxy.java index 0228c7fd4..9d43d2778 100644 --- a/common/mekanism/client/ClientProxy.java +++ b/common/mekanism/client/ClientProxy.java @@ -8,6 +8,7 @@ import mekanism.client.gui.GuiCombiner; import mekanism.client.gui.GuiConfiguration; import mekanism.client.gui.GuiCredits; import mekanism.client.gui.GuiCrusher; +import mekanism.client.gui.GuiDictionary; import mekanism.client.gui.GuiDigitalMiner; import mekanism.client.gui.GuiDynamicTank; import mekanism.client.gui.GuiElectricChest; @@ -296,6 +297,8 @@ public class ClientProxy extends CommonProxy switch(ID) { + case 0: + return new GuiDictionary(player.inventory); case 1: return new GuiCredits(); case 2: diff --git a/common/mekanism/client/gui/GuiDictionary.java b/common/mekanism/client/gui/GuiDictionary.java new file mode 100644 index 000000000..6fa10d839 --- /dev/null +++ b/common/mekanism/client/gui/GuiDictionary.java @@ -0,0 +1,155 @@ +package mekanism.client.gui; + +import mekanism.common.inventory.container.ContainerDictionary; +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import org.lwjgl.input.Keyboard; +import org.lwjgl.opengl.GL11; + +public class GuiDictionary extends GuiMekanism +{ + public ItemStack itemType; + + public String oreDictName; + + public GuiDictionary(InventoryPlayer inventory) + { + super(new ContainerDictionary(inventory)); + } + + @Override + protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + fontRenderer.drawString(MekanismUtils.localize("item.Dictionary.name"), 64, 5, 0x404040); + fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, ySize - 96 + 2, 0x404040); + + if(itemType != null) + { + if(oreDictName != null && !oreDictName.isEmpty()) + { + fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.key") + ": " + oreDictName, 9, 57, 0x00CD00); + } + else { + fontRenderer.drawString(MekanismUtils.localize("gui.dictionary.noKey"), 9, 57, 0x00CD00); + } + } + + if(itemType != null) + { + GL11.glPushMatrix(); + GL11.glEnable(GL11.GL_LIGHTING); + itemRenderer.renderItemAndEffectIntoGUI(fontRenderer, mc.getTextureManager(), itemType, 80, 23); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glPopMatrix(); + } + + super.drawGuiContainerForegroundLayer(mouseX, mouseY); + } + + @Override + protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) + { + super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); + + mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDictionary.png")); + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + int guiWidth = (width - xSize) / 2; + int guiHeight = (height - ySize) / 2; + drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); + + int xAxis = mouseX - guiWidth; + int yAxis = mouseY - guiHeight; + + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39) + { + GL11.glPushMatrix(); + GL11.glDisable(GL11.GL_LIGHTING); + GL11.glDisable(GL11.GL_DEPTH_TEST); + + int x = guiWidth + 80; + int y = guiHeight + 23; + drawGradientRect(x, y, x + 16, y + 16, -2130706433, -2130706433); + + GL11.glEnable(GL11.GL_LIGHTING); + GL11.glEnable(GL11.GL_DEPTH_TEST); + GL11.glPopMatrix(); + } + } + + @Override + public boolean doesGuiPauseGame() + { + return false; + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int button) + { + int xAxis = (mouseX - (width - xSize) / 2); + int yAxis = (mouseY - (height - ySize) / 2); + + if(button == 0) + { + if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + Slot hovering = null; + + for(int i = 0; i < inventorySlots.inventorySlots.size(); i++) + { + Slot slot = (Slot)inventorySlots.inventorySlots.get(i); + + if(isMouseOverSlot(slot, mouseX, mouseY)) + { + hovering = slot; + break; + } + } + + if(hovering != null) + { + ItemStack stack = hovering.getStack(); + + if(stack != null) + { + itemType = stack.copy(); + itemType.stackSize = 1; + + oreDictName = MekanismUtils.getOreDictName(itemType); + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + + return; + } + } + } + + if(xAxis >= 80 && xAxis <= 96 && yAxis >= 23 && yAxis <= 39) + { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + + if(stack != null && !Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + itemType = stack.copy(); + itemType.stackSize = 1; + + oreDictName = MekanismUtils.getOreDictName(itemType); + } + else if(stack == null && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)) + { + itemType = null; + oreDictName = null; + } + + mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F); + } + } + + super.mouseClicked(mouseX, mouseY, button); + } +} diff --git a/common/mekanism/common/CommonProxy.java b/common/mekanism/common/CommonProxy.java index 98e2ff217..f73706628 100644 --- a/common/mekanism/common/CommonProxy.java +++ b/common/mekanism/common/CommonProxy.java @@ -3,6 +3,7 @@ package mekanism.common; import java.io.File; import mekanism.common.inventory.container.ContainerAdvancedElectricMachine; +import mekanism.common.inventory.container.ContainerDictionary; import mekanism.common.inventory.container.ContainerDigitalMiner; import mekanism.common.inventory.container.ContainerDynamicTank; import mekanism.common.inventory.container.ContainerElectricMachine; @@ -262,6 +263,8 @@ public class CommonProxy switch(ID) { + case 0: + return new ContainerDictionary(player.inventory); case 2: return new ContainerDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity); case 3: diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index 6613333ac..f0facbb33 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -48,6 +48,7 @@ import mekanism.common.item.ItemBlockOre; import mekanism.common.item.ItemBlockTransmitter; import mekanism.common.item.ItemClump; import mekanism.common.item.ItemConfigurator; +import mekanism.common.item.ItemDictionary; import mekanism.common.item.ItemDirtyDust; import mekanism.common.item.ItemDust; import mekanism.common.item.ItemElectricBow; @@ -90,13 +91,11 @@ import mekanism.common.network.PacketWalkieTalkieState; import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock; import mekanism.common.tileentity.TileEntityBoundingBlock; import mekanism.common.tileentity.TileEntityElectricBlock; -import mekanism.common.tileentity.TileEntityTeleporter; import mekanism.common.transporter.TransporterManager; import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.voice.VoiceServerManager; import net.minecraft.block.Block; -import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; @@ -221,6 +220,7 @@ public class Mekanism public static ItemJetpack Jetpack; public static ItemScubaTank ScubaTank; public static ItemGasMask GasMask; + public static Item Dictionary; //Blocks public static Block BasicBlock; @@ -478,6 +478,9 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(Jetpack.getEmptyItem(), new Object[] { "SCS", "TGT", " T ", Character.valueOf('S'), "ingotSteel", Character.valueOf('C'), "circuitBasic", Character.valueOf('T'), "ingotTin", Character.valueOf('G'), MekanismUtils.getEmptyGasTank() })); + CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(Dictionary), new Object[] { + "C", "B", Character.valueOf('C'), "circuitBasic", Character.valueOf('B'), Item.book + })); for(RecipeType type : RecipeType.values()) { @@ -566,7 +569,8 @@ public class Mekanism //Declarations configuration.load(); ElectricBow = (ItemElectricBow)new ItemElectricBow(configuration.getItem("ElectricBow", 11200).getInt()).setUnlocalizedName("ElectricBow"); - //OPEN 11201-11203 + Dictionary = new ItemDictionary(configuration.getItem("Dictionary", 11201).getInt()).setUnlocalizedName("Dictionary"); + //OPEN 11202-11203 Dust = new ItemDust(configuration.getItem("Dust", 11204).getInt()-256); Ingot = new ItemIngot(configuration.getItem("Ingot", 11205).getInt()-256); EnergyTablet = (ItemEnergized)new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 1000000, 120).setUnlocalizedName("EnergyTablet"); @@ -614,6 +618,7 @@ public class Mekanism GameRegistry.registerItem(NetworkReader, "NetworkReader"); GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie"); GameRegistry.registerItem(Jetpack, "Jetpack"); + GameRegistry.registerItem(Dictionary, "Dictionary"); } /** diff --git a/common/mekanism/common/inventory/container/ContainerDictionary.java b/common/mekanism/common/inventory/container/ContainerDictionary.java new file mode 100644 index 000000000..bc289b23b --- /dev/null +++ b/common/mekanism/common/inventory/container/ContainerDictionary.java @@ -0,0 +1,85 @@ +package mekanism.common.inventory.container; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerDictionary extends Container +{ + public ContainerDictionary(InventoryPlayer inventory) + { + int slotX; + + for(slotX = 0; slotX < 3; ++slotX) + { + for(int slotY = 0; slotY < 9; ++slotY) + { + addSlotToContainer(new Slot(inventory, slotY + slotX * 9 + 9, 8 + slotY * 18, 84 + slotX * 18)); + } + } + + for(slotX = 0; slotX < 9; ++slotX) + { + addSlotToContainer(new Slot(inventory, slotX, 8 + slotX * 18, 142)); + } + } + + @Override + public boolean canInteractWith(EntityPlayer entityplayer) + { + return true; + } + + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slotID) + { + ItemStack stack = null; + Slot currentSlot = (Slot)inventorySlots.get(slotID); + + if(currentSlot != null && currentSlot.getHasStack()) + { + ItemStack slotStack = currentSlot.getStack(); + stack = slotStack.copy(); + + if(slotID >= 0 && slotID <= 26) + { + if(!mergeItemStack(slotStack, 27, inventorySlots.size(), false)) + { + return null; + } + } + else if(slotID > 26) + { + if(!mergeItemStack(slotStack, 0, 26, false)) + { + return null; + } + } + else { + if(!mergeItemStack(slotStack, 0, inventorySlots.size(), true)) + { + return null; + } + } + + if(slotStack.stackSize == 0) + { + currentSlot.putStack((ItemStack)null); + } + else { + currentSlot.onSlotChanged(); + } + + if(slotStack.stackSize == stack.stackSize) + { + return null; + } + + currentSlot.onPickupFromSlot(player, slotStack); + } + + return stack; + } +} diff --git a/common/mekanism/common/item/ItemDictionary.java b/common/mekanism/common/item/ItemDictionary.java new file mode 100644 index 000000000..2b609c74b --- /dev/null +++ b/common/mekanism/common/item/ItemDictionary.java @@ -0,0 +1,63 @@ +package mekanism.common.item; + +import mekanism.api.EnumColor; +import mekanism.api.transmitters.ITransmitter; +import mekanism.api.transmitters.TransmitterNetworkRegistry; +import mekanism.common.Mekanism; +import mekanism.common.util.MekanismUtils; +import net.minecraft.block.Block; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ChatMessageComponent; +import net.minecraft.world.World; + +public class ItemDictionary extends ItemMekanism +{ + public ItemDictionary(int id) + { + super(id); + setMaxStackSize(1); + } + + @Override + public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) + { + if(!player.isSneaking()) + { + Block block = Block.blocksList[world.getBlockId(x, y, z)]; + + if(block != null) + { + if(world.isRemote) + { + ItemStack testStack = new ItemStack(block, 1, world.getBlockMetadata(x, y, z)); + String name = MekanismUtils.getOreDictName(testStack); + + if(name != null && !name.isEmpty()) + { + player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " Key found: " + EnumColor.DARK_GREEN + name); + } + else { + player.addChatMessage(EnumColor.DARK_BLUE + "[Mekanism]" + EnumColor.GREY + " No key."); + } + } + + return true; + } + } + + return false; + } + + @Override + public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer entityplayer) + { + if(entityplayer.isSneaking()) + { + entityplayer.openGui(Mekanism.instance, 0, world, 0, 0, 0); + } + + return itemstack; + } +} diff --git a/common/mekanism/common/tileentity/TileEntityDigitalMiner.java b/common/mekanism/common/tileentity/TileEntityDigitalMiner.java index 7ce0e125e..239d10e4d 100644 --- a/common/mekanism/common/tileentity/TileEntityDigitalMiner.java +++ b/common/mekanism/common/tileentity/TileEntityDigitalMiner.java @@ -868,7 +868,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I @Override public boolean renderUpdate() { - return true; + return false; } @Override diff --git a/resources/assets/mekanism/gui/GuiCrusher.png b/resources/assets/mekanism/gui/GuiCrusher.png index 017bf15fe..384b876f6 100644 Binary files a/resources/assets/mekanism/gui/GuiCrusher.png and b/resources/assets/mekanism/gui/GuiCrusher.png differ diff --git a/resources/assets/mekanism/gui/GuiDictionary.png b/resources/assets/mekanism/gui/GuiDictionary.png new file mode 100644 index 000000000..b096a39e2 Binary files /dev/null and b/resources/assets/mekanism/gui/GuiDictionary.png differ diff --git a/resources/assets/mekanism/lang/en_US.lang b/resources/assets/mekanism/lang/en_US.lang index 621faad0c..5dff38305 100644 --- a/resources/assets/mekanism/lang/en_US.lang +++ b/resources/assets/mekanism/lang/en_US.lang @@ -25,6 +25,7 @@ item.WalkieTalkie.name=Walkie-Talkie item.Jetpack.name=Jetpack item.ScubaTank.name=Scuba Tank item.GasMask.name=Gas Mask +item.Dictionary.name=Dictionary //Gas Tank tile.GasTank.GasTank.name=Gas Tank @@ -166,6 +167,9 @@ gui.input=Input gui.slots=Slots gui.state=State +gui.dictionary.noKey=No key. +gui.dictionary.key=Key + gui.configuration=Configuration gui.configuration.strictInput=Strict Input diff --git a/resources/assets/mekanism/textures/items/Dictionary.png b/resources/assets/mekanism/textures/items/Dictionary.png new file mode 100644 index 000000000..3b4a09c35 Binary files /dev/null and b/resources/assets/mekanism/textures/items/Dictionary.png differ