Solved Still Dropping redstone?

Discussion in 'Plugin Development' started by michael566, Apr 28, 2014.

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

    michael566

    So I am making a plugin where you mine a ore and it doesn't drop it, but instead gives it to you in your inventory. But for some reason it still drops redstone ore. All the other ores don't drop. Is this something with Bukkit or..?

    Code:java
    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent e) {
    3. ItemStack diamondore = new ItemStack(Material.DIAMOND_ORE, 5);
    4. ItemStack ironingot = new ItemStack(Material.IRON_INGOT, 5);
    5. ItemStack goldingot = new ItemStack(Material.GOLD_INGOT, 5);
    6. ItemStack emeralore = new ItemStack(Material.EMERALD, 5);
    7. ItemStack lapis = new ItemStack(Material.LAPIS_ORE, 5);
    8. ItemStack redstone = new ItemStack(Material.REDSTONE, 5);
    9. Player p = (Player) e.getPlayer();
    10. if (e.getBlock().getType() == Material.DIAMOND_ORE) {
    11. e.getBlock().setType(Material.AIR);
    12. p.getInventory().addItem(diamondore);
    13.  
    14. }
    15.  
    16. if (e.getBlock().getType() == Material.GOLD_ORE) {
    17. e.getBlock().setType(Material.AIR);
    18. p.getInventory().addItem(goldingot);
    19. }
    20.  
    21. if (e.getBlock().getType() == Material.IRON_ORE) {
    22. e.getBlock().setType(Material.AIR);
    23. p.getInventory().addItem(ironingot);
    24. }
    25.  
    26. if (e.getBlock().getType() == Material.EMERALD_ORE) {
    27. e.getBlock().setType(Material.AIR);
    28. p.getInventory().addItem(emeralore);
    29.  
    30. }
    31.  
    32. if (e.getBlock().getType() == Material.LAPIS_ORE) {
    33. e.getBlock().setType(Material.AIR);
    34. p.getInventory().addItem(lapis);
    35. }
    36.  
    37. if (e.getBlock().getType() == Material.REDSTONE_ORE) {
    38. e.getBlock().setType(Material.AIR);
    39. p.getInventory().addItem(redstone);
    40. }
    41.  
    42. }
     
  2. Offline

    Kryptonix2Shot

    In my experiences adding event.setCancelled(true) worked. But I'm a beginner developer so that may or may not help you.
     
  3. Offline

    BillyGalbreath

    Because there are two states for redstone ore. Off and on.
     
  4. Offline

    kennethbgoodin

    Cancel the block break event; you're setting the block to air, but the block break event is still going, meaning item drops can still occur.
     
  5. Offline

    michael566


    BillyGalbreath Oh, how would you make it check for if it was off?
     
  6. Offline

    chromestone

  7. Offline

    BillyGalbreath

    Its on if its being mined.... Not off.. GLOWING_REDSTONE_ORE but its best to check for both anyways.
     
  8. Offline

    michael566


    Alright Thanks!
     
Thread Status:
Not open for further replies.

Share This Page