I need to generate a Random Item and Entity How?

Discussion in 'Plugin Development' started by EspoDev, Sep 4, 2011.

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

    EspoDev

    I mean I just forgot it i know theres something Math.Random(); but i need to extend it so i can put Items and data in it,,, help
     
  2. Offline

    Haias

    I would make an array of paired objects.

    Code:
    Pair<Integer, Byte>[200] Items;
    Items[0] = new Pair<Integer, Byte>(17, 2); // I think that's birch wood?
    Include all the items you want, then you can use
    Code:
    Items[Math.floor(Math.random()*200)]
    to get a pair.

    Btw, the Pair class isn't included. You can search the web for a generic one that you can use object values for.

    Include all the items you want in there.
     
  3. Offline

    escape

    I would try this to get a random material:
    Code:java
    1. Material mat = Material.values()[(int)(Math.random() * Material.values().length)];
     
Thread Status:
Not open for further replies.

Share This Page