Random Set Location

Discussion in 'Plugin Development' started by stonebloodtv, Mar 5, 2014.

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

    stonebloodtv

    Hi !

    Code:java
    1. skull.setLocation(loc.getX() + 0.0D + 0.0D, loc.getY() + 1.0D + 55.0D, loc.getZ() + 0.0D + 0.0D, 0.0F, 0.0F);


    I need to include values random between 1 and 9

    Code:java
    1. skull.setLocation(loc.getX() + 0.#RANDOM#D + 0.#RANDOM#D, loc.getY() + 1.0D + 55.0D, loc.getZ() + 0.#RANDOM#D + 0.#RANDOM#D, 0.0F, 0.0F);


    #RANDOM# = Rand (1-9)

    How make this please ? :/
     
  2. Offline

    Minecrafter_NL

    random int:
    Code:java
    1. Random random = new Random();
    2. int random_int = random.nextInt(9);


    this will generate an integer between 0 and 9
     
  3. Offline

    stonebloodtv

    Ok thank and how to include in
    Code:java
    1. skull.setLocation(loc.getX() + 0.0D + 0.0D, loc.getY() + 1.0D + 55.0D, loc.getZ() + 0.0D + 0.0D, 0.0F, 0.0F);
     
  4. Offline

    Barinade

    Random.nextInt(9) is 0-8, to achieve 1-9, add 1
    Random.nextInt(9)+1
    The text here
    "(Random.nextInt(9)+1)" represents a number. Remove the number where you want the random number and just write that
     
  5. Offline

    stonebloodtv


    Thanks, hum
    Code:java
    1. skull.setLocation(loc.getX(), loc.getY() + 1.0D + 55.0D, loc.getZ() + 1.0D + 1.0D, 0.0F, 0.0F);

    To
    Code:java
    1. skull.setLocation(loc.getX(), loc.getY() + 1.0D + 55.(Random.nextInt(9)+1)D, loc.getZ() + 1.0D + 1.0D, 0.0F, 0.0F);


    Not working ^,^
     
  6. Offline

    Barinade

    you want between 55 and 56?
    (55d + random.nextDouble())
     
  7. Offline

    stonebloodtv

    Yes but i dont understand how to including your code on the script :(
     
Thread Status:
Not open for further replies.

Share This Page