brake clay drops gold help

Discussion in 'Plugin Development' started by connor2011minimega, Jun 29, 2013.

Thread Status:
Not open for further replies.
  1. Hey I am making a plugin and I need it so someone brakes a block of clay that have a 50% chase of it dropping a not of gold help
     
  2. Offline

    caseif

    Generate a random int from 0 to 1, and if it's a certain value, call .getDrops().clear() followed by .getDrops().add(new ItemStack(Material.GOLD_NUGGET, 1) on the block variable. This is assuming you understand to listen to the event and get the block from it.
     
  3. Offline

    MehrPvM

    connor2011minimega Some code: :)
    Code:java
    1. import java.util.Random;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Location;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.Listener;
    7. import org.bukkit.event.block.BlockBreakEvent;
    8. import org.bukkit.plugin.java.JavaPlugin;
    9.  
    10. public class Main extends JavaPlugin implements Listener{
    11.  
    12. @EventHandler
    13. public void claygold(BlockBreakEvent event){
    14. Location blocloc = event.getBlock().getLocation();
    15. event.getBlock().getDrops().clear();
    16. Random randomGenerator = new Random();
    17. int randomInt = randomGenerator.nextInt(1);
    18.  
    19. switch (randomInt) { //The cases can work in conjuntion with ' int randomInt = randomGenerator.nextInt(1);',
    20. case 0: //Because that code will produce either 1/0, if you were to change it it could be 2/1/0.
    21. //Drop Clay //This means you can add more cases, and therefore more combinations of what they'll drop.
    22. break;
    23. case 1:
    24. //Drop Gold
    25. break;
    26. }
    27. }
    28. }
     
Thread Status:
Not open for further replies.

Share This Page