[SOLVED] addEnchantment Help!

Discussion in 'Plugin Development' started by bartboy8, Jun 10, 2012.

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

    bartboy8

    I am having problems adding an enchantment to a crafting recipe. Any help would be appreciated.
    Code:
        ItemStack enchant = new ItemStack(Material.DIAMOND_BOOTS , 1).addEnchantment(Enchantment.PROTECTION_FALL, 1);
        ShapelessRecipe grinderRecipe16 = new ShapelessRecipe(new ItemStack(enchant)).addIngredient(Material.DIRT);
     
  2. Offline

    r0306

    bartboy8
    Try this instead
    Code:
    ItemStack enchant = new ItemStack(Material.DIAMOND_BOOTS , 1);
    enchant.addEnchantment(Enchantment.PROTECTION_FALL, 1);
     
  3. Offline

    bartboy8

    r0306
    Syntax error on tokens, TypeArgument1 expected instead
    It didn't work I got this error.
     
  4. Offline

    r0306

    bartboy8
    What line was the error on?
     
  5. Offline

    bartboy8

    2nd one
     
  6. Offline

    ZeusAllMighty11

    Just for the heck of it, try adding an unsafe enchantment instead of enchantment and see what happens.
     
  7. Offline

    bartboy8

    I did, it works. Thanks. Regarding my other topic you helped me on... I can't get it to work. Whenever it looks like it should work it always tells me to insert or remove "}"
     
  8. Offline

    ZeusAllMighty11

    Sorry, I don't have much experience with schedulers yet, I plan to learn them after exams. Try asking r0306 or Digi they're really smart. :3

    And I'm not sure why unsafe enchantment worked but the regular didn't... hmmmm

    also, can you set your topic title to [SOLVED] prefix? Helps everyone see that you found your problem, and possibly addressed it in the thread.
     
  9. If it's a syntax error it's pretty much a syntax error (typos and stuff) and it's unrelated to using unsafe or not since they have the same arguments.
    Or you copy pasted it wrong or eclipse bugged out, I dunno, because If I paste:
    Code:
    ItemStack enchant = new ItemStack(Material.DIAMOND_BOOTS , 1);
    enchant.addEnchantment(Enchantment.PROTECTION_FALL, 1);
    It's just fine in the IDE and it should work just fine in the game as well.

    Or maybe you imported net.minecraft.server.Enchantment; ? That's the wrong one.
     
Thread Status:
Not open for further replies.

Share This Page