Ejemplo n.º 1
0
 @Override
 public void onInteractBy(
     Entity entity, Block block, PlayerInteractEvent.Action type, BlockFace clickedFace) {
   super.onInteractBy(entity, block, type, clickedFace);
   if (type != PlayerInteractEvent.Action.RIGHT_CLICK) {
     return;
   }
   Slot inv = PlayerUtil.getHeldSlot(entity);
   if (inv != null && inv.get() != null && inv.get().isMaterial(Dye.BONE_MEAL)) {
     if (!PlayerUtil.isCostSuppressed(entity)) {
       inv.addAmount(-1);
     }
     final BlockMaterial mushroomType = block.getMaterial();
     final VariableHeightObject mushroom;
     if (mushroomType == VanillaMaterials.RED_MUSHROOM) {
       mushroom = new HugeMushroomObject(HugeMushroomType.RED);
     } else {
       mushroom = new HugeMushroomObject(HugeMushroomType.BROWN);
     }
     final World world = block.getWorld();
     final int x = block.getX();
     final int y = block.getY();
     final int z = block.getZ();
     if (mushroom.canPlaceObject(world, x, y, z)) {
       mushroom.placeObject(world, x, y, z);
     }
   }
 }
Ejemplo n.º 2
0
 @Override
 public void onInteractBy(
     Entity entity, Block block, PlayerInteractEvent.Action type, BlockFace clickedFace) {
   super.onInteractBy(entity, block, type, clickedFace);
   Slot inv = PlayerUtil.getHeldSlot(entity);
   if (inv != null && inv.get() != null && inv.get().isMaterial(Dye.BONE_MEAL)) {
     if (this.getGrowthStage(block) != 0x7) {
       if (!PlayerUtil.isCostSuppressed(entity)) {
         inv.addAmount(-1);
       }
       this.setGrowthStage(block, 0x7);
     }
   }
 }