ID & Data to Name

Discussion in 'Plugin Development' started by Haias, Jul 16, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    Haias

    I'm writing a shop plugin, and I want to display an object's name given an ID and data. My current method (return new ItemStack(id).getType().name();) isn't adequate for items with data.

    I plan to go through and just write a ton of if statements for each ID & data value, but before wasting my time, I wanna ask: has anyone already written a function to convert an id and data to a name?

    Or, if you could point me in the direction of an open source mod that does this, that would be great, too. I don't run a server, so I have no idea what mods do what.
     
  2. Offline

    Afforess

  3. Offline

    Haias

    Oh, cool. I'll just have to take the code I need out of it, though, because there are a few mistakes. Some things I think you should be aware of:
    itemNames.put(new ItemData(17), "Wood");
    Wood can be Regular, Spruce, or Birch. You should add byte data for wood.
    Also, itemNames.put(new ItemData(19), "Spone");

    EDIT: On second though, I don't need to take pieces out of your code because you have the handy setItemName functions. Thanks. ;) (but I still advise that you fix the mistakes)
     
  4. Offline

    Emperor_Face

    spone = sponge
    though = thought

    typing too fast = spelling mistakes.
     
Thread Status:
Not open for further replies.

Share This Page