Jump to content
Search In
  • More options...
Find results that contain...
Find results in...


  • Posts

  • Joined

  • Last visited

Everything posted by Atijaf

  1. As I understand, there is only one instance of each item. So how would I differentiate between the itemstacks and their nbt data? I want to have an item that stores 1 integer.
  2. I'm unable to implement IUpdatePlayerListBox. Must it be used on a TileEntity? I don't have a TileEntity, because it's an item that accesses an inventory.
  3. Thanks! I'll take a look at that when I get back home. Would that method happen to come from TileEntity? I have a class that just implements IInventory, so I could extend TileEntity if that's the case.
  4. Is there a class that I can implement so that I may call the method, "onUpdate"? I need something checked within an inventory every few ticks. If I can call that method from within a class that extends container, or a class that implements IInventory, that would be ideal.
  5. Thankyou! It's working for the most part. I'm going to work on saving the items after I figure out how many items the itemstack can hold. I am, however, having a different problem. When I shift click an item from my inventory while I have the gui open, it disappears. Same thing happens when I shift click from it's inventory. When I drag and drop an item into the itemstacks inventory, the stack size is doubled. It's getting late and I've checked many locations for the error, but am still unsure as to what it is. Any help is greatly appreciated! Thanks a bunch! ItemStack. -- It's messy:( Sorry http://pastebin.com/WZ3jY6VT ContainerTunneler http://pastebin.com/WspW5Tbc GUITunneler http://pastebin.com/wLQL2M4k
  6. I have stopped my Item from breaking, but I want the tool to stop being useful once it has hit it's max damage. The tool would act as if it's just an item.. i.e. a stick.
  7. How can I create a tool that has an inventory? I have some experience with tools and tile entities, but am unsure how I would combine them.
  8. Alright, so it is impossible to find the current crafting inventory instance and check if it matches my requirements to update the output? 63 copper = no output and that works. https://gyazo.com/cb7982241d5fded81eb30e89c1ec1827 64 copper = 1 silver coin output. https://gyazo.com/eb23e0aefd07f5be75e797b9019dbbd5 But if I add 1 to the 63 copper in the crafting matrix to make it 64, it doesn't update. https://gyazo.com/ac6f51eafbf7e1621782ca330cbdbad6 I'm fine with it being impossible for me to find the instance to update it, just say so. CustomShapedRecipe http://pastebin.com/BxjZn9Ye
  9. So, what automatically calls "matches"? If I can solve this, I won't have to make another crafting table for just this one thing. Recipes: The recipes are added into a custom recipe handler, so it can accept both of those. I just need the output in the crafting table to update when the player adds items to a slot that already has items. i.e. slot currently has 63 silver coins, if the player makes it 64, it doesn't say he can make a gold coin. While he could just remove the item and put it pack completely, if he doesn't do that, there is a problem after that. The player will receive 64 copper coins and it will remove all 64 silver coins.
  10. How can I have the player's crafting instance refreshed if he changes the size of the Itemstack from within the crafting grid. i.e. How can I call the matches method from IRecipe, and how can I check if the player changed the size of the stack? I have a custom Recipe that depends on the size of the ItemStack.
  11. Thanks everyone on the lesson. Everything is solved
  12. new Info, when adding testItem to the hashMap, testItem has an id of 4097. I add this during "FMLInitializationEvent". Later on, I use hashMap.get(newMyItemStack(testItem)), //hashMap being static variable.. But this time, testItem has id value of 4105. Should I be doing this in post init? What would change the id of the block between initEvent and during the game? That is most definitely the problem. I thought about checking within the hash method, of MyItemStack, to see if it is one of my items and just add 8 to the id, but that isn't constant among my other items.. i.e. testItem2 is registered immediately after testItem and initially has and id value of 4098. It later then has a value of 4108.
  13. I have just tested that hashmap with vanilla item, Diamond Block, and default mod item, testItem. testItem = new Item().setUnlocalizedName("testItem");//Other classGameRegistry.registerItem(testItem, "testItem");//Testing hashMap//Note, it doesn't store integers, but instances. that is not the part i'm focusing on, so I made it simple.public static HashMap<MyItemStack, Integer> requiredLevel = new HashMap(200);ItemStack DiamondBlockStack = new ItemStack(Blocks.diamond_block);ItemStack testBlock = new ItemStack(MCAItems.testBlock);requiredLevel.put(new MyItemStack(DiamondBlockStack), 1);requiredLevel.put(new MyItemStack(testBlock), 2);requiredLevel.get(new MyItemStack(DiamondBlockStack));//Returns 1requiredLevel.get(new MyItemStack(testBlock));//Returns null
  14. I changed it like so. public class MyItemStack { private short id; private short meta; public MyItemStack(ItemStack stack){ this.id = (short) Item.getIdFromItem(stack.getItem()); this.meta = (short) stack.getMetadata(); } public int getMeta(){ return this.meta; } public int getId(){ return this.id; } public void setIdAndMeta(ItemStack stack){ this.id = (short) Item.getIdFromItem(stack.getItem()); this.meta = (short) stack.getMetadata(); } /** Compares two MyItemStacks */ public boolean equals(Object object){ if (!(object instanceof MyItemStack)){ return false; } MyItemStack otherKey = (MyItemStack) object; return this.id == otherKey.id && this.meta == otherKey.meta; } /** Used to compare MyItemStacks */ public int hashCode(){ return this.id + this.meta * 500; // if it was just meta, granite would equal 2.. Thats grass. } } I'm not sure why, but it doesn't work with my new Items that I add. I'll add a pastebin in a little. It works with vanilla Items.
  15. I would just like to compare the id and meta of the block. As for the 31 * all that stuff, idk. I saw it used and it seemed to work...
  16. I wish to fill a HashMap with the key being the ItemStack. I understand that I must override hashCode and equals, and it seems to work part of the time. I created a wrapper class that I put into the hashMap, called MyItemStack. It holds the stack. Here is my HashCode override public int hashCode(){ //int result = 17 int result = 13; result = 31 * result + Integer.valueOf(this.stack.getMetadata()); result = 31 * result + Integer.valueOf(Item.getIdFromItem(stack.getItem())); return result; } This code works for vanilla items and blocks, but as soon as I attempt this with a item from my mod, it doesn't work.. My Custom Item only holds one extra item, but I'm only checking if the two items being compared have the same metadata and block Id, so that shouldn't matter, right? Equals override public boolean equals(Object object){ if (!(object instanceof MyItemStack)){ return false; } MyItemStack otherKey = (MyItemStack) object; return this.stack.isItemEqual(otherKey.stack); } I copy the vanilla code I use when adding a key to the hashmap to the customItem that I have. Is there anything wrong with this bit of code, or must it be somewhere else?
  17. Got it working. I had actually forgotten I followed a tutorial showing me how to make requirements for crafting. I can't remember who made the tutorial though:( Sorry! From within my class that implements IRecipe, i Override "GetRemainingItems" to remove the required amount from the slot, so in this case 64. A little more complicated than that, but mostly just ifs. @Override public ItemStack[] getRemainingItems(InventoryCrafting inv) //getRecipeLeftovers { EntityPlayer player = findPlayer(inv); CraftingRequirements crafting_requirements = CraftingRequirements.getObject(new MyItemStack(output)); if(player != null && crafting_requirements != null){ byte amountRequired = (byte) crafting_requirements.getAmountRequired(); if(amountRequired > 1 && amountRequired <= 64){ ItemStack[] ret = new ItemStack[inv.getSizeInventory()]; for(int i = 0; i < ret.length; i++){ ret[i] = inv.getStackInSlot(i); if(ret[i] != null){ ret[i].stackSize -= amountRequired; if(ret[i].stackSize == 0){ ret[i] = null; } } } return ret; } } //Vanilla method for when it needs to be handled the Vanilla way! return ForgeHooks.defaultRecipeGetRemainingItems(inv); } I also had to override "matches" to check if the slot has the amount required to make the item. Thanks everyone!
  18. When the item hits 0 durability, set the item to null.
  19. Is it possible to add a shapeless recipe that requires multiple itemStacks in one slot to create? Basically, put 64 gold nuggets in one slot and that 64 will create 1 gold ingot. Is that possible?
  20. I'm unsure if this is it l, because json stuff... But try renaming the json file from sharpStick to SharpStick. I haven't messed with textures lately, but I vaguely remember doing something similar to that and it fixed it. I'm also on my phone, so if that doesn't work, I'll check back in a little bit when I get back home.
  21. Oooops! Make your mod ID all lower case. That's probably part, if not all of your problem with the texture
  22. From within the constructor inside your item class, type "this." And it should give you a list of things that you can mess around with. I believe stack size is in there. Another thing that you can do, at least if you're in eclipse, is hold control and click on the class you are extending, or any class for that matter, and it will open and you can see many of the methods they use and override them in your own class.
  23. That's great! I also knew mostly c and c++ before going into this. One thing to note is that some actions that you want to happen would probably be better inside the blocks themselves. Example from within a block that can be created public class testBlock extends Block{ private IBlockState state; public testBlock(Material material, IBlockState state){ super(material); this.state = state; //This could be the block you want it to be changed to when it is right Clicked } //When the block is right clicked, basically. @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ){ //This will be called when the block is right clicked. So it's changed to the state you passed in the constructor. //Also, only make changes with blocks on the server. To check, do this. if(!worldIn.isRemote){ worldIn.setBlockState(pos, this.state); //You could also have the player drop items from here, but I'll let you figure that out (You already did in the event handler!) } I have not tested the above code, but I am pretty sure it would work! I know you're messing around with events for the most part, but I thought that this would help you some how. Events are definitely good when working with vanilla blocks, but if you do end up creating new items, know that this is an option! Either way, good luck with everything! I hope this helps you.
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.