How do I make it so that when a player breaks one blocks, a different one is dropped. Like if you broke a diamond block it would drop a dirt block. I need help. EDIT by Moderator: merged posts, please use the edit button instead of double posting.
1928i 13 minute bump? Patience, please. Back on tropic, just listen to the blockbreakevent, and you should be able to get the right methods from that.
1928i untested, but it should work Code: @EventHandler public void onBlockBreak(BlockBreakEvent e){ if(e.getBlock().getType() == Material.DIAMOND_BLOCK){ e.setCancelled(true); e.getBlock().setType(Material.DIRT); e.getBlock().breakNaturally(); } } }
kmecpp What about if someone mined it with their fist? It would still drop the dirt. How could you prevent that?
1928i The simplest way would probably to just check if the player is holding a pickaxe: Code: if(e.getBlock().getType() == Material.DIAMOND_BLOCK){ if(e.getPlayer().getItemInHand().getTypeId() == 257 || e.getPlayer().getItemInHand().getTypeId() == 278){ e.setCancelled(true); e.getBlock().setType(Material.DIRT); e.getBlock().breakNaturally(); } } The item ID 257 is an iron pick and 278 is a diamond pick. I don't think anything else can break diamond blocks...