Dictionary! :)

This commit is contained in:
Aidan Brady 2013-12-09 20:52:49 -05:00
parent 3c4d776e24
commit 250ddadcf0
11 changed files with 322 additions and 4 deletions

View file

@ -8,6 +8,7 @@ import mekanism.client.gui.GuiCombiner;
import mekanism.client.gui.GuiConfiguration; import mekanism.client.gui.GuiConfiguration;
import mekanism.client.gui.GuiCredits; import mekanism.client.gui.GuiCredits;
import mekanism.client.gui.GuiCrusher; import mekanism.client.gui.GuiCrusher;
import mekanism.client.gui.GuiDictionary;
import mekanism.client.gui.GuiDigitalMiner; import mekanism.client.gui.GuiDigitalMiner;
import mekanism.client.gui.GuiDynamicTank; import mekanism.client.gui.GuiDynamicTank;
import mekanism.client.gui.GuiElectricChest; import mekanism.client.gui.GuiElectricChest;
@ -296,6 +297,8 @@ public class ClientProxy extends CommonProxy
switch(ID) switch(ID)
{ {
case 0:
return new GuiDictionary(player.inventory);
case 1: case 1:
return new GuiCredits(); return new GuiCredits();
case 2: case 2:

View file

@ -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);
}
}

View file

@ -3,6 +3,7 @@ package mekanism.common;
import java.io.File; import java.io.File;
import mekanism.common.inventory.container.ContainerAdvancedElectricMachine; import mekanism.common.inventory.container.ContainerAdvancedElectricMachine;
import mekanism.common.inventory.container.ContainerDictionary;
import mekanism.common.inventory.container.ContainerDigitalMiner; import mekanism.common.inventory.container.ContainerDigitalMiner;
import mekanism.common.inventory.container.ContainerDynamicTank; import mekanism.common.inventory.container.ContainerDynamicTank;
import mekanism.common.inventory.container.ContainerElectricMachine; import mekanism.common.inventory.container.ContainerElectricMachine;
@ -262,6 +263,8 @@ public class CommonProxy
switch(ID) switch(ID)
{ {
case 0:
return new ContainerDictionary(player.inventory);
case 2: case 2:
return new ContainerDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity); return new ContainerDigitalMiner(player.inventory, (TileEntityDigitalMiner)tileEntity);
case 3: case 3:

View file

@ -48,6 +48,7 @@ import mekanism.common.item.ItemBlockOre;
import mekanism.common.item.ItemBlockTransmitter; import mekanism.common.item.ItemBlockTransmitter;
import mekanism.common.item.ItemClump; import mekanism.common.item.ItemClump;
import mekanism.common.item.ItemConfigurator; import mekanism.common.item.ItemConfigurator;
import mekanism.common.item.ItemDictionary;
import mekanism.common.item.ItemDirtyDust; import mekanism.common.item.ItemDirtyDust;
import mekanism.common.item.ItemDust; import mekanism.common.item.ItemDust;
import mekanism.common.item.ItemElectricBow; import mekanism.common.item.ItemElectricBow;
@ -90,13 +91,11 @@ import mekanism.common.network.PacketWalkieTalkieState;
import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock; import mekanism.common.tileentity.TileEntityAdvancedBoundingBlock;
import mekanism.common.tileentity.TileEntityBoundingBlock; import mekanism.common.tileentity.TileEntityBoundingBlock;
import mekanism.common.tileentity.TileEntityElectricBlock; import mekanism.common.tileentity.TileEntityElectricBlock;
import mekanism.common.tileentity.TileEntityTeleporter;
import mekanism.common.transporter.TransporterManager; import mekanism.common.transporter.TransporterManager;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType; import mekanism.common.util.MekanismUtils.ResourceType;
import mekanism.common.voice.VoiceServerManager; import mekanism.common.voice.VoiceServerManager;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager; import net.minecraft.item.crafting.CraftingManager;
@ -221,6 +220,7 @@ public class Mekanism
public static ItemJetpack Jetpack; public static ItemJetpack Jetpack;
public static ItemScubaTank ScubaTank; public static ItemScubaTank ScubaTank;
public static ItemGasMask GasMask; public static ItemGasMask GasMask;
public static Item Dictionary;
//Blocks //Blocks
public static Block BasicBlock; public static Block BasicBlock;
@ -478,6 +478,9 @@ public class Mekanism
CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(Jetpack.getEmptyItem(), new Object[] { 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() "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()) for(RecipeType type : RecipeType.values())
{ {
@ -566,7 +569,8 @@ public class Mekanism
//Declarations //Declarations
configuration.load(); configuration.load();
ElectricBow = (ItemElectricBow)new ItemElectricBow(configuration.getItem("ElectricBow", 11200).getInt()).setUnlocalizedName("ElectricBow"); 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); Dust = new ItemDust(configuration.getItem("Dust", 11204).getInt()-256);
Ingot = new ItemIngot(configuration.getItem("Ingot", 11205).getInt()-256); Ingot = new ItemIngot(configuration.getItem("Ingot", 11205).getInt()-256);
EnergyTablet = (ItemEnergized)new ItemEnergized(configuration.getItem("EnergyTablet", 11206).getInt(), 1000000, 120).setUnlocalizedName("EnergyTablet"); 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(NetworkReader, "NetworkReader");
GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie"); GameRegistry.registerItem(WalkieTalkie, "WalkieTalkie");
GameRegistry.registerItem(Jetpack, "Jetpack"); GameRegistry.registerItem(Jetpack, "Jetpack");
GameRegistry.registerItem(Dictionary, "Dictionary");
} }
/** /**

View file

@ -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;
}
}

View file

@ -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;
}
}

View file

@ -868,7 +868,7 @@ public class TileEntityDigitalMiner extends TileEntityElectricBlock implements I
@Override @Override
public boolean renderUpdate() public boolean renderUpdate()
{ {
return true; return false;
} }
@Override @Override

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -25,6 +25,7 @@ item.WalkieTalkie.name=Walkie-Talkie
item.Jetpack.name=Jetpack item.Jetpack.name=Jetpack
item.ScubaTank.name=Scuba Tank item.ScubaTank.name=Scuba Tank
item.GasMask.name=Gas Mask item.GasMask.name=Gas Mask
item.Dictionary.name=Dictionary
//Gas Tank //Gas Tank
tile.GasTank.GasTank.name=Gas Tank tile.GasTank.GasTank.name=Gas Tank
@ -166,6 +167,9 @@ gui.input=Input
gui.slots=Slots gui.slots=Slots
gui.state=State gui.state=State
gui.dictionary.noKey=No key.
gui.dictionary.key=Key
gui.configuration=Configuration gui.configuration=Configuration
gui.configuration.strictInput=Strict Input gui.configuration.strictInput=Strict Input

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB