Jump to content

ilan321

Members
  • Posts

    18
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

ilan321's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. Will it show the tooltip when the player has the recipe in place but hasn't "crafted" it yet? (When you mouse over the result but haven't taken it out yet)
  2. Hello! I am making rewriting my mod called Transmutation. I have an item called tStone. I would like this item to have different tooltips in different places. For example, if you mouse over the tStone in the creative menu or NEI, then it should say "Infinite Uses". If you're crafting it, then it should have the crafter's name (looks like "Owner: {playername}"). Is there a way to achieve this?
  3. I have not. Thanks! I didn't know it was because of my IDE.
  4. Hello! I have tried to add some localization and textures for my custom item but it does not work. Package structure is as follows: en_US.lang: item.tStone.name=Transmutation Stone itemGroup.transmutation=Transmutation Registering the item renderer thingamajig: @Mod.EventHandler public void init(FMLInitializationEvent e) { if (e.getSide() == Side.CLIENT) { RenderItem rI = Minecraft.getMinecraft().getRenderItem(); rI.getItemModelMesher().register(ModItems.tStone, 0, new ModelResourceLocation("transmutation:tStone", "inventory")); } } In the game, the creative tab is literally called "itemGroup.transmutation" and not "Transmutation", and the item itself is called "item.tStone.name" instead of "Transmutation Stone". The item's texture is a purple and black block. Any idea as to why the game isn't reading this? (Funny side-note, overriding the addInformation() method, clearing the tooltip List and adding a String to it makes it act as the item title!)
  5. Where do I edit the nbt while crafting? The craft event? Edit: Never mind! I figured it out myself! Apparently you override the getContainerItem method and do what you wish with it. Here's my end result: @Override public ItemStack getContainerItem(ItemStack itemStack) { int uses = itemStack.getTagCompound().getInteger("uses")-1; String owner = itemStack.getTagCompound().getString("owner"); if (uses < 1) { return null; } ItemStack cItem = new ItemStack(getContainerItem()); cItem.setTagCompound(new NBTTagCompound()); cItem.getTagCompound().setInteger("uses", uses); cItem.getTagCompound().setString("owner", owner); return cItem; }
  6. Here's a line of code that adds a shapeless recipe for blaze rods using ender pearls: GameRegistry.addShapelessRecipe(new ItemStack(Items.blaze_rod), new ItemStack(Items.ender_pearl)); Here's a line of code that adds a shaped recipe for 4 blaze rods using ender pearls and string: GameRegistry.addShapedRecipe(new ItemStack(Items.blaze_rod, 4), "XOX", "OXO", "XOX", 'X', new ItemStack(Items.ender_pearl), 'O', new ItemStack(Items.string)); Basically you use an ItemStack with your custom item.
  7. It seems that when I craft with the item (i set the container item to itself) that the NBT tags are erased, but the item stays in the crafting grid. How can I edit the NBT while crafting?
  8. Hello! I am rewriting my Transmutation mod, and I still cannot figure out how to leave an item in the craftMatrix. According to this post, I am supposed to call matrix.setInventorySlotContents(int i, ItemStack k) , but when I do so, the item does not stay in the crafting grid! My event subscription method is as follows: public class CraftingHandler { @SubscribeEvent public void ItemCraftedEvent(PlayerEvent.ItemCraftedEvent e) { Transmutation.logger.info("Attempting to craft"); for (int i = 0; i < e.craftMatrix.getSizeInventory(); i++) { if (e.craftMatrix.getStackInSlot(i) == null) continue; if (e.craftMatrix.getStackInSlot(i).getItem() == Recipes.tStone) { Transmutation.logger.info("Crafting with a transmutation stone"); ItemStack stone = e.craftMatrix.getStackInSlot(i); if (!stone.hasTagCompound()) return; // debug stone Transmutation.logger.info("Crafting complete"); stone.getTagCompound().setInteger("uses", stone.getTagCompound().getInteger("uses")-1); if (stone.getTagCompound().getInteger("uses") < 1) stone = new ItemStack(Blocks.air); else { Transmutation.logger.info("Attempting to leave the itemstack in the matrix.."); e.craftMatrix.setInventorySlotContents(i, stone); } return; } } } } As you can see, I am calling e.craftMatrix.setInventorySlotContents(i, stone); but the item does not stay in the crafting grid. How can I fix this? On a side note, is there a way to "remove" an itemstack from the crafting grid? I don't know if setting it to an air block is something that's good or not.
  9. How do I do this? Do I have to set the container item for the itemstack?
  10. Hello, I have an item I want to keep in the crafting grid after you craft with it (sort of like IC2's hammer, or EE3's minium stone). This is my item class. How can I keep it in the crafting grid?
  11. I think I found it, I have to override the onCraft method and set the slot contents manually. I'll test soon, I'm not home either Edit: never mind, that was a method for an old version of Forge (it used ICraftingHandler). I tried removing the isContainer method and placing the transmutation stone in the crafting grid during the ItemCrafted event but it just disappears.
  12. I see. But I want the item to remain in the crafting grid, is that possible to insert it there after the crafting has finished?
  13. I set it as a container item, and set false to shouldReturnToInventory.
  14. Hello, I am making a transmutation stone. It has a limited number of uses (stored in nbt). I have subscribed to the ItemCrafted event, and I can assign NBT to the item and have it display the 'lore' - being the number of uses. When the item is crafted, it shows the uses ('Uses: 128', etc). However, after crafting with the item (for example, the stone + 1 gold ingot = 4 iron ingot), it does not display any of the information. The addInformation method: @Override public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { if (stack.stackTagCompound != null) { String owner = stack.stackTagCompound.getString("owner"); Integer uses = stack.stackTagCompound.getInteger("uses"); list.add("Owner: " + owner); if (uses > 95) { list.add("Uses: " + EnumChatFormatting.GREEN + uses); } if ((uses > 63) && (uses < 96)) { list.add("Uses: " + EnumChatFormatting.YELLOW + uses); } if ((uses < 64) && (uses > 2)) { list.add("Uses: " + EnumChatFormatting.RED + uses); } if (uses.equals(1)) { list.add("Uses: " + EnumChatFormatting.DARK_RED + uses); } } } The code for the itemcrafted event: for (int i = 0; i < e.craftMatrix.getSizeInventory(); i++) { if (e.craftMatrix.getStackInSlot(i) != null) { if (e.craftMatrix.getStackInSlot(i).getItem() == Transmutation.bStone) { if (e.craftMatrix.getStackInSlot(i).stackTagCompound != null) { e.craftMatrix.getStackInSlot(i).stackTagCompound.setInteger("uses", (e.craftMatrix.getStackInSlot(i).stackTagCompound.getInteger("uses") - 1)); if (e.craftMatrix.getStackInSlot(i).stackTagCompound.getInteger("uses") < 1) { e.craftMatrix.setInventorySlotContents(i, null); return; } } return; } } } How can I reassign the extra info after the item is crafted with?
  15. That is not the problem. The e.crafting block is for when the player is crafting a transmutation stone. My problem is when the player crafts with the transmutation stone, for example 'stone + 1 iron = 4 ender pearl'. That is when it crashes. Edit: ah nvm, it works now. I added the null check for the second block and it works. Thanks!
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.