Solved Calculating drop amount from unsafe fortune enchants

Discussion in 'Plugin Development' started by SuperOriginal, Jun 30, 2014.

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

    SuperOriginal

    Hello, i'm making a plugin in which a player mines a block and it goes straight into their inventory with fortune enchantments applied. Due to this the BlockBreakEvent is cancelled, therefore I need to manually calculate the amount of an item to add to the player's inventory. I have an equation that can use for fortune 1-3 but I need to be able to apply it to any unsafe fortune enchantment such as Fortune 10. I've looked into getDrops() and the other methods that I might be able to use but there doesn't seem to be anything to help me with. Can anybody help me out with an equation or something that I can use to calculate based on any enchantment level? Thanks.
     
  2. Offline

    oscarshi1995

    Prison Server? I've made the exact same plugin for a prison server lol...


    Code:java
    1. public int getDropCount(int i, Random random) {
    2. int j = random.nextInt(i + 2) - 1;
    3.  
    4. if (j < 0) {
    5. j = 0;
    6. }
    7.  
    8. return (j + 1);
    9. }
     
  3. Offline

    SuperOriginal

    Perfect! And yes it is.... lol
     
Thread Status:
Not open for further replies.

Share This Page