diff options
author | Alkalus <draknyte1@hotmail.com> | 2017-11-18 05:46:28 +1000 |
---|---|---|
committer | Alkalus <draknyte1@hotmail.com> | 2017-11-18 05:46:28 +1000 |
commit | 04344136279524749cc07dc979c18baee6a72e4d (patch) | |
tree | b6e41ba36e4dc701f8590d5fcf8cdb3199b8a5a9 /src/Java/gtPlusPlus/core | |
parent | e8fa34d3ba219a21bcce0cdb07ede8dcdfe9dcb9 (diff) | |
download | GT5-Unofficial-04344136279524749cc07dc979c18baee6a72e4d.tar.gz GT5-Unofficial-04344136279524749cc07dc979c18baee6a72e4d.tar.bz2 GT5-Unofficial-04344136279524749cc07dc979c18baee6a72e4d.zip |
+ Added the Grindle, a portable E-reader for Data-Sticks.
Diffstat (limited to 'src/Java/gtPlusPlus/core')
6 files changed, 665 insertions, 0 deletions
diff --git a/src/Java/gtPlusPlus/core/container/Container_Grindle.java b/src/Java/gtPlusPlus/core/container/Container_Grindle.java new file mode 100644 index 0000000000..8b218f5993 --- /dev/null +++ b/src/Java/gtPlusPlus/core/container/Container_Grindle.java @@ -0,0 +1,182 @@ +package gtPlusPlus.core.container; + +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.slots.SlotDataStick; +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 Container_Grindle extends Container +{ + /** The Item Inventory for this Container, only needed if you want to reference isUseableByPlayer */ + public final BaseInventoryGrindle inventory; + + /** Using these will make transferStackInSlot easier to understand and implement + * INV_START is the index of the first slot in the Player's Inventory, so our + * BaseInventoryBackpack's number of slots (e.g. 5 slots is array indices 0-4, so start at 5) + * Notice how we don't have to remember how many slots we made? We can just use + * BaseInventoryBackpack.INV_SIZE and if we ever change it, the Container updates automatically. */ + private static final int INV_START = BaseInventoryGrindle.INV_SIZE, INV_END = INV_START+0, + HOTBAR_START = INV_END, HOTBAR_END = HOTBAR_START+8; + + // If you're planning to add armor slots, put those first like this: + // ARMOR_START = BaseInventoryBackpack.INV_SIZE, ARMOR_END = ARMOR_START+3, + // INV_START = ARMOR_END+1, and then carry on like above. + + public Container_Grindle(final EntityPlayer par1Player, final InventoryPlayer inventoryPlayer, final BaseInventoryGrindle inventoryItem) + { + this.inventory = inventoryItem; + + int i; + + //Actual Scan Slot + this.addSlotToContainer(new SlotDataStick(this.inventory, 0, 152, 5)); + + for (i = 1; i < BaseInventoryGrindle.INV_SIZE; ++i){ + this.addSlotToContainer(new SlotDataStick(this.inventory, i, 153, 30+(18*i))); + } + + // PLAYER ACTION BAR - uses default locations for standard action bar texture file + for (i = 0; i < 9; ++i) + { + this.addSlotToContainer(new Slot(inventoryPlayer, i, 8 + (i * 18), 142)); + } + } + + @Override + public boolean canInteractWith(final EntityPlayer entityplayer) + { + // be sure to return the inventory's isUseableByPlayer method + // if you defined special behavior there: + return this.inventory.isUseableByPlayer(entityplayer); + } + + /** + * Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that. + */ + @Override + public ItemStack transferStackInSlot(final EntityPlayer par1EntityPlayer, final int index) + { + ItemStack itemstack = null; + final Slot slot = (Slot) this.inventorySlots.get(index); + + if ((slot != null) && slot.getHasStack()) + { + final ItemStack itemstack1 = slot.getStack(); + itemstack = itemstack1.copy(); + + // If item is in our custom Inventory or armor slot + if (index < INV_START) + { + // try to place in player inventory / action bar + if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END+1, true)) + { + return null; + } + + slot.onSlotChange(itemstack1, itemstack); + } + // Item is in inventory / hotbar, try to place in custom inventory or armor slots + else + { + /* + If your inventory only stores certain instances of Items, + you can implement shift-clicking to your inventory like this: + + // Check that the item is the right type + if (itemstack1.getItem() instanceof ItemCustom) + { + // Try to merge into your custom inventory slots + // We use 'BaseInventoryBackpack.INV_SIZE' instead of INV_START just in case + // you also add armor or other custom slots + if (!this.mergeItemStack(itemstack1, 0, BaseInventoryBackpack.INV_SIZE, false)) + { + return null; + } + } + // If you added armor slots, check them here as well: + // Item being shift-clicked is armor - try to put in armor slot + if (itemstack1.getItem() instanceof ItemArmor) + { + int type = ((ItemArmor) itemstack1.getItem()).armorType; + if (!this.mergeItemStack(itemstack1, ARMOR_START + type, ARMOR_START + type + 1, false)) + { + return null; + } + } + Otherwise, you have basically 2 choices: + 1. shift-clicking between player inventory and custom inventory + 2. shift-clicking between action bar and inventory + + Be sure to choose only ONE of the following implementations!!! + */ + /** + * Implementation number 1: Shift-click into your custom inventory + */ + if (index >= INV_START) + { + // place in custom inventory + if (!this.mergeItemStack(itemstack1, 0, INV_START, false)) + { + return null; + } + } + + /** + * Implementation number 2: Shift-click items between action bar and inventory + */ + // item is in player's inventory, but not in action bar + if ((index >= INV_START) && (index < HOTBAR_START)) + { + // place in action bar + if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END+1, false)) + { + return null; + } + } + // item in action bar - place in player inventory + else if ((index >= HOTBAR_START) && (index < (HOTBAR_END+1))) + { + if (!this.mergeItemStack(itemstack1, INV_START, INV_END+1, false)) + { + return null; + } + } + } + + if (itemstack1.stackSize == 0) + { + slot.putStack((ItemStack) null); + } + else + { + slot.onSlotChanged(); + } + + if (itemstack1.stackSize == itemstack.stackSize) + { + return null; + } + + slot.onPickupFromSlot(par1EntityPlayer, itemstack1); + } + + return itemstack; + } + + /** + * You should override this method to prevent the player from moving the stack that + * opened the inventory, otherwise if the player moves it, the inventory will not + * be able to save properly + */ + @Override + public ItemStack slotClick(final int slot, final int button, final int flag, final EntityPlayer player) { + // this will prevent the player from interacting with the item that opened the inventory: + if ((slot >= 0) && (this.getSlot(slot) != null) && (this.getSlot(slot).getStack() == player.getHeldItem())) { + return null; + } + return super.slotClick(slot, button, flag, player); + } +} diff --git a/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java new file mode 100644 index 0000000000..798b74b48f --- /dev/null +++ b/src/Java/gtPlusPlus/core/gui/item/GuiBaseGrindle.java @@ -0,0 +1,141 @@ +package gtPlusPlus.core.gui.item; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL12; + +import gregtech.api.util.GT_Utility; +import gregtech.api.util.GT_Utility.ItemNBT; +import gtPlusPlus.core.container.Container_BackpackBase; +import gtPlusPlus.core.container.Container_Grindle; +import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; +import gtPlusPlus.core.util.nbt.NBTUtils; +import net.minecraft.client.gui.FontRenderer; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.client.renderer.OpenGlHelper; +import net.minecraft.client.renderer.RenderHelper; +import net.minecraft.client.renderer.entity.RenderManager; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.nbt.NBTTagString; +import net.minecraft.util.ResourceLocation; + +public class GuiBaseGrindle extends GuiContainer { + + /** The FontRenderer used by GuiScreen */ + protected FontRenderer fontRenderer; + + private static final ResourceLocation iconLocation = new ResourceLocation(CORE.MODID, "textures/gui/itemGrindle.png"); + + /** The inventory to render on screen */ + private final BaseInventoryGrindle inventory; + + public GuiBaseGrindle(final Container_Grindle containerItem){ + super(containerItem); + this.inventory = containerItem.inventory; + } + + /** + * Draws the screen and all the components in it. + */ + @Override + public void drawScreen(final int par1, final int par2, final float par3){ + super.drawScreen(par1, par2, par3); + } + + /** + * Draw the foreground layer for the GuiContainer (everything in front of the items) + */ + @Override + protected void drawGuiContainerForegroundLayer(final int par1, final int par2){ + final String s = "Git"; + //Title + this.fontRendererObj.drawStringWithShadow(I18n.format("Gregtech Information Transponder", new Object[0]), 0, -12, Utils.rgbtoHexValue(255, 255, 255)); + + if (this.inventory.getStackInSlot(0) != null){ + this.fontRendererObj.drawString(I18n.format(""+NBTUtils.getBookTitle(this.inventory.getStackInSlot(0)), new Object[0]), 10, 8, Utils.rgbtoHexValue(125, 255, 125)); + + if (!NBTUtils.tryIterateNBTData(this.inventory.getStackInSlot(0))){ + this.fontRendererObj.drawString(I18n.format("Very Bad prospection data.", new Object[0]), 10, 38, Utils.rgbtoHexValue(255, 125, 125)); + } + + NBTTagCompound tNBT = ItemNBT.getNBT(this.inventory.getStackInSlot(0)); + byte tTier = tNBT.getByte("prospection_tier"); + //List Tier + //this.fontRendererObj.drawStringWithShadow(I18n.format("Tier: "+tTier, new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); + + if (tTier == 0) { // basic prospection data + String tData = tNBT.getString("prospection"); + //List prospection + //this.fontRendererObj.drawStringWithShadow(I18n.format("Prospection : "+tData, new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 255, 125)); + + String[] tDataArray = tData.split(","); + if (tDataArray.length > 6) { + tNBT.setString("author", "X: " + tDataArray[0] + " Y: " + tDataArray[1] + " Z: " + tDataArray[2] + " Dim: " + tDataArray[3]); + //List prospection + this.fontRendererObj.drawString(I18n.format("X: " + tDataArray[0], new Object[0]), 10, 28, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Y: " + tDataArray[1], new Object[0]), 10, 38, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Z: " + tDataArray[2], new Object[0]), 10, 48, Utils.rgbtoHexValue(125, 125, 255)); + this.fontRendererObj.drawString(I18n.format("Dim: " + tDataArray[3], new Object[0]), 10, 58, Utils.rgbtoHexValue(125, 125, 255)); + + //Divider + this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 63, Utils.rgbtoHexValue(125, 125, 255)); + + NBTTagList tNBTList = new NBTTagList(); + String[] mOreTypes = new String[50]; + String tOres = " Prospected Ores: "; + for (int i = 6; tDataArray.length > i; i++) { + mOreTypes[i] = (tDataArray[i] + " "); + if ((68+(i-6)*8) < (68+56)){ + this.fontRendererObj.drawString(I18n.format(mOreTypes[i], new Object[0]), 10, 68+((i-6)*8), Utils.rgbtoHexValue(125, 255, 125)); + } + } + Utils.LOG_INFO("test - "+tOres); + tNBTList.appendTag(new NBTTagString("Prospection Data From: X" + tDataArray[0] + " Z:" + tDataArray[2] + " Dim:" + tDataArray[3] + " Produces " + tDataArray[4] + "L " + tDataArray[5] + " " + tOres)); + tNBT.setTag("pages", tNBTList); + + + //List prospection + this.fontRendererObj.drawString(I18n.format("Tier: "+tTier+ " | Pages: "+tNBTList.tagCount(), new Object[0]), 10, 18, Utils.rgbtoHexValue(125, 255, 125)); + //Divider + this.fontRendererObj.drawString(I18n.format("-------------------", new Object[0]), 10, 23, Utils.rgbtoHexValue(125, 125, 255)); + + } + else { + this.fontRendererObj.drawString(I18n.format("Bad prospection data.", new Object[0]), 10, 68, Utils.rgbtoHexValue(255, 125, 125)); + } + } + } + else { + //Valid Datastick? + this.fontRendererObj.drawStringWithShadow(I18n.format("Insert device into port.", new Object[0]), 10, 8, Utils.rgbtoHexValue(255, 125, 125)); + } + + + + //Inventory Label + this.fontRendererObj.drawStringWithShadow(I18n.format("container.inventory", new Object[0]), 8, 131, Utils.rgbtoHexValue(255, 255, 255)); + + //this.fontRenderer.drawString(s, this.xSize / 2 - this.fontRenderer.getStringWidth(s) / 2, 0, 4210752); + //this.fontRenderer.drawString(I18n.translate("container.inventory"), 26, this.ySize - 96 + 4, 4210752); + } + + /** + * Draw the background layer for the GuiContainer (everything behind the items) + */ + @Override + protected void drawGuiContainerBackgroundLayer(final float par1, final int par2, final int par3) + { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.getTextureManager().bindTexture(iconLocation); + final int k = (this.width - this.xSize) / 2; + final int l = (this.height - this.ySize) / 2; + this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize); + final int i1; + //drawPlayerModel(k + 51, l + 75, 30, k + 51 - this.xSize_lo, (l + 75) - 50 - this.ySize_lo, this.mc.thePlayer); + } +} diff --git a/src/Java/gtPlusPlus/core/handler/GuiHandler.java b/src/Java/gtPlusPlus/core/handler/GuiHandler.java index 70e2934349..124b01a2c0 100644 --- a/src/Java/gtPlusPlus/core/handler/GuiHandler.java +++ b/src/Java/gtPlusPlus/core/handler/GuiHandler.java @@ -7,9 +7,11 @@ import gtPlusPlus.core.container.*; import gtPlusPlus.core.gui.beta.Gui_ID_Registry; import gtPlusPlus.core.gui.beta.MU_GuiId; import gtPlusPlus.core.gui.item.GuiBaseBackpack; +import gtPlusPlus.core.gui.item.GuiBaseGrindle; import gtPlusPlus.core.gui.machine.*; import gtPlusPlus.core.interfaces.IGuiManager; import gtPlusPlus.core.inventories.BaseInventoryBackpack; +import gtPlusPlus.core.inventories.BaseInventoryGrindle; import gtPlusPlus.core.tileentities.base.TileEntityBase; import gtPlusPlus.core.tileentities.general.TileEntityFishTrap; import gtPlusPlus.core.tileentities.machines.TileEntityModularityTable; @@ -33,6 +35,7 @@ public class GuiHandler implements IGuiHandler { public static final int GUI6 = 5; //Fish trap public static final int GUI7 = 6; //Trade table public static final int GUI8 = 7; // + public static final int GUI9 = 8; // @@ -80,6 +83,10 @@ public class GuiHandler implements IGuiHandler { return new Container_TradeTable(player.inventory, (TileEntityTradeTable)te); } } + + if (ID == GUI9){ + return new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem())); + } @@ -125,6 +132,10 @@ public class GuiHandler implements IGuiHandler { return new GUI_TradeTable(player.inventory, (TileEntityTradeTable)te, ((TileEntityBase) te).getOwner()); } } + + if (ID == GUI9){ + return new GuiBaseGrindle(new Container_Grindle(player, player.inventory, new BaseInventoryGrindle(player.getHeldItem()))); + } return null; } diff --git a/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java new file mode 100644 index 0000000000..ca7fcd6d03 --- /dev/null +++ b/src/Java/gtPlusPlus/core/inventories/BaseInventoryGrindle.java @@ -0,0 +1,240 @@ +package gtPlusPlus.core.inventories; + +import java.util.UUID; + +import gtPlusPlus.core.item.base.BaseItemBackpack; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.util.Constants; + +public class BaseInventoryGrindle implements IInventory{ + + private final String name = "Inventory Item"; + + /** Provides NBT Tag Compound to reference */ + private final ItemStack invItem; + + /** Defining your inventory size this way is handy */ + public static final int INV_SIZE = 6; + + /** Inventory's size must be same as number of slots you add to the Container class */ + private final ItemStack[] inventory = new ItemStack[INV_SIZE]; + + // declaration of variable: + protected String uniqueID; + + /** + * @param itemstack - the ItemStack to which this inventory belongs + */ + public BaseInventoryGrindle(final ItemStack stack) + { + this.invItem = stack; + + /** initialize variable within the constructor: */ + this.uniqueID = ""; + + if (!stack.hasTagCompound()) + { + stack.setTagCompound(new NBTTagCompound()); + // no tag compound means the itemstack does not yet have a UUID, so assign one: + this.uniqueID = UUID.randomUUID().toString(); + } + + // Create a new NBT Tag Compound if one doesn't already exist, or you will crash + if (!stack.hasTagCompound()) { + stack.setTagCompound(new NBTTagCompound()); + } + // note that it's okay to use stack instead of invItem right there + // both reference the same memory location, so whatever you change using + // either reference will change in the other + + // Read the inventory contents from NBT + this.readFromNBT(stack.getTagCompound()); + } + @Override + public int getSizeInventory() + { + return this.inventory.length; + } + + @Override + public ItemStack getStackInSlot(final int slot) + { + return this.inventory[slot]; + } + + @Override + public ItemStack decrStackSize(final int slot, final int amount) + { + ItemStack stack = this.getStackInSlot(slot); + if(stack != null) + { + if(stack.stackSize > amount) + { + stack = stack.splitStack(amount); + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + else + { + // this method also calls markDirty, so we don't need to call it again + this.setInventorySlotContents(slot, null); + } + } + return stack; + } + + @Override + public ItemStack getStackInSlotOnClosing(final int slot) + { + final ItemStack stack = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return stack; + } + + @Override + public void setInventorySlotContents(final int slot, final ItemStack stack) + { + this.inventory[slot] = stack; + + if ((stack != null) && (stack.stackSize > this.getInventoryStackLimit())) + { + stack.stackSize = this.getInventoryStackLimit(); + } + + // Don't forget this line or your inventory will not be saved! + this.markDirty(); + } + + // 1.7.2+ renamed to getInventoryName + @Override + public String getInventoryName() + { + return this.name; + } + + // 1.7.2+ renamed to hasCustomInventoryName + @Override + public boolean hasCustomInventoryName() + { + return this.name.length() > 0; + } + + @Override + public int getInventoryStackLimit() + { + return 1; + } + + /** + * This is the method that will handle saving the inventory contents, as it is called (or should be called!) + * anytime the inventory changes. Perfect. Much better than using onUpdate in an Item, as this will also + * let you change things in your inventory without ever opening a Gui, if you want. + */ + // 1.7.2+ renamed to markDirty + @Override + public void markDirty() + { + for (int i = 0; i < this.getSizeInventory(); ++i) + { + if ((this.getStackInSlot(i) != null) && (this.getStackInSlot(i).stackSize == 0)) { + this.inventory[i] = null; + } + } + + // This line here does the work: + this.writeToNBT(this.invItem.getTagCompound()); + } + + @Override + public boolean isUseableByPlayer(final EntityPlayer entityplayer) + { + return true; + } + + // 1.7.2+ renamed to openInventory(EntityPlayer player) + @Override + public void openInventory() {} + + // 1.7.2+ renamed to closeInventory(EntityPlayer player) + @Override + public void closeInventory() {} + + /** + * This method doesn't seem to do what it claims to do, as + * items can still be left-clicked and placed in the inventory + * even when this returns false + */ + @Override + public boolean isItemValidForSlot(final int slot, final ItemStack itemstack) + { + // Don't want to be able to store the inventory item within itself + // Bad things will happen, like losing your inventory + // Actually, this needs a custom Slot to work + return !(itemstack.getItem() instanceof BaseItemBackpack); + } + + /** + * A custom method to read our inventory from an ItemStack's NBT compound + */ + public void readFromNBT(final NBTTagCompound compound) + { + // Gets the custom taglist we wrote to this compound, if any + // 1.7.2+ change to compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + final NBTTagList items = compound.getTagList("ItemInventory", Constants.NBT.TAG_COMPOUND); + + if ("".equals(this.uniqueID)) + { + // try to read unique ID from NBT + this.uniqueID = compound.getString("uniqueID"); + // if it's still "", assign a new one: + if ("".equals(this.uniqueID)) + { + this.uniqueID = UUID.randomUUID().toString(); + } + } + + for (int i = 0; i < items.tagCount(); ++i) + { + // 1.7.2+ change to items.getCompoundTagAt(i) + final NBTTagCompound item = items.getCompoundTagAt(i); + final int slot = item.getInteger("Slot"); + + // Just double-checking that the saved slot index is within our inventory array bounds + if ((slot >= 0) && (slot < this.getSizeInventory())) { + this.inventory[slot] = ItemStack.loadItemStackFromNBT(item); + } + } + } + + /** + * A custom method to write our inventory to an ItemStack's NBT compound + */ + public void writeToNBT(final NBTTagCompound tagcompound) + { + // Create a new NBT Tag List to store itemstacks as NBT Tags + final NBTTagList items = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + // Only write stacks that contain items + if (this.getStackInSlot(i) != null) + { + // Make a new NBT Tag Compound to write the itemstack and slot index to + final NBTTagCompound item = new NBTTagCompound(); + item.setInteger("Slot", i); + // Writes the itemstack in slot(i) to the Tag Compound we just made + this.getStackInSlot(i).writeToNBT(item); + + // add the tag compound to our tag list + items.appendTag(item); + } + } + tagcompound.setString("uniqueID", this.uniqueID); + // Add the TagList to the ItemStack's Tag Compound with the name "ItemInventory" + tagcompound.setTag("ItemInventory", items); + } +}
\ No newline at end of file diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index ec0e21c7bb..851db25325 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -240,6 +240,8 @@ public final class ModItems { public static Item itemModularBauble; public static Item itemCustomBook; + + public static Item itemGrindleTablet; public static final void init(){ @@ -616,6 +618,8 @@ public final class ModItems { itemAirFilter = new ItemAirFilter(); itemLavaFilter = new ItemLavaFilter(); + + itemGrindleTablet = new BaseItemGrindle(); //Chemistry CoalTar.run(); diff --git a/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java new file mode 100644 index 0000000000..66fd6968e4 --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/general/BaseItemGrindle.java @@ -0,0 +1,87 @@ +package gtPlusPlus.core.item.general; + +import java.util.List; + +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import gregtech.api.util.GT_OreDictUnificator; +import gtPlusPlus.GTplusplus; +import gtPlusPlus.core.creative.AddToCreativeTab; +import gtPlusPlus.core.handler.GuiHandler; +import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.item.ItemUtils; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.EnumRarity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.world.World; + +public class BaseItemGrindle extends Item{ + + protected final String unlocalName; + + + public BaseItemGrindle(){ + this.unlocalName = "itemGrindleTablet"; + this.setUnlocalizedName("itemGrindleTablet"); + this.setTextureName(CORE.MODID + ":" + "itemTablet"); + GameRegistry.registerItem(this, "itemGrindleTablet"); + GT_OreDictUnificator.registerOre("tabletGit", ItemUtils.getSimpleStack(this)); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabOther); + } + + @Override + public int getMaxItemUseDuration(final ItemStack stack) { + return 1; + } + + @Override + public ItemStack onItemRightClick(final ItemStack itemstack, final World world, final EntityPlayer player) + { + if (!world.isRemote){ + if (!player.isSneaking()) { + player.openGui(GTplusplus.instance, GuiHandler.GUI9, world, 0, 0, 0); + } + } + + return itemstack; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return ("Git"); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(final IIconRegister iconRegister) + { + this.itemIcon = iconRegister.registerIcon(CORE.MODID + ":" + "itemTablet"); + } + + @Override + public String getPotionEffect(ItemStack p_150896_1_) { + // TODO Auto-generated method stub + return super.getPotionEffect(p_150896_1_); + } + + @Override + public void addInformation(ItemStack p_77624_1_, EntityPlayer p_77624_2_, + List p_77624_3_, boolean p_77624_4_) { + // TODO Auto-generated method stub + super.addInformation(p_77624_1_, p_77624_2_, p_77624_3_, p_77624_4_); + } + + @Override + public EnumRarity getRarity(ItemStack i) { + return EnumRarity.uncommon; + } + + @Override + public boolean isRepairable() { + return false; + } +} |