Enchantment Modifier

Discussion in 'Plugin Development' started by 97WaterPolo, Oct 23, 2014.

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

    97WaterPolo

    Hello!

    I was wondering where I should look to find out how the enchantments are generated? Basically if you put in a sword and click level 30, how are the enchantments as well as their level generated? Not exactly sure where to look, tried ContainerEnchantTableInventory, ContainerEnchantTable, EnchantmentInstance. Am I looking in the wrong place or am I stupid? :p
     
  2. So you want to know at which point in the code of bukkit the level and the enchantment is generated? Or do you want to know how to generate and add an enchantment? this would be item.addEnchantment(Entchantment.type, level). If your question is equals to the first one, i would say if you put the item int he slot the enchantmenttable looks how much bookshelves are arround it and knows a value-range for every amount of bookshelves. like there is the maximum of bookshelves so level 27-30 or something like this. then it generates a random number between highest and lowest and picks a random entchantment type. maybe some types have a higher chance than others to be picked, but thats how it should work.

    Could i help you?
     
  3. Offline

    fireblast709

    97WaterPolo the second ;3. It's in ContainerEnchantmentTableInventory, look for a static invocation to (iirc) Enchantment.a(...).
     
  4. Offline

    97WaterPolo

    fireblast709
    Will check when I get home! <3

    Shmobi
    Yea, I am trying to figure out the weighting and how it is randomly generated! :).Thanks for the help
     
  5. Offline

    97WaterPolo

    fireblast709
    Okay, thanks! I found the a() method that modifies the level, and I was wondering where should I begin to look for where the enchants are generated? I am guessing it takes the level you click and generates the enchants based on that, so where should I look?

    fireblast709
    Used that, it doesn't actually do anything besides return a list. How would I add it to the item then? :confused:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 25, 2018
  6. Offline

    fireblast709

    97WaterPolo EnchantmentManager.b(Random, ItemStack, int)?

    97WaterPolo use the infinite wisdom of the souce \o/. The List is a List of EnchantmentInstances, which each have an Enchantment and a level. The enchantment has an ID which matches the Bukkit Enchantment ID. Combined, they can be added to a Bukkit ItemStack :3.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Aug 25, 2018
Thread Status:
Not open for further replies.

Share This Page