Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CompostPoisonousPotato implements Listener {
- @EventHandler
- public void compostPoisonousPotato(PlayerInteractEvent event) {
- if (Config.compostPoisonousPotato) {
- if (event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.COMPOSTER
- && event.getAction() == Action.RIGHT_CLICK_BLOCK) {
- Levelled data = ((Levelled) event.getClickedBlock().getBlockData());
- if (event.getHand() == EquipmentSlot.HAND && event.getMaterial() == Material.POISONOUS_POTATO
- || event.getHand() == EquipmentSlot.OFF_HAND
- && event.getMaterial() == Material.POISONOUS_POTATO) {
- if (data.getLevel() < 8) {
- if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
- event.getItem().setAmount(event.getItem().getAmount() - 1);
- }
- if (Math.random() <= 0.65F) {
- data.setLevel(data.getLevel() + 1);
- event.getClickedBlock().setBlockData(data);
- }
- event.getPlayer().getWorld().playSound(event.getClickedBlock().getLocation(),
- Sound.BLOCK_COMPOSTER_FILL, 1.0F, 1.0F);
- event.getPlayer().getWorld().playEffect(event.getClickedBlock().getLocation().add(0, 0.98D, 0),
- Effect.VILLAGER_PLANT_GROW, 10);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement