Package org.spout.api.event.cause

Examples of org.spout.api.event.cause.BlockCause


        return true;
      }
    } else if (item.getMaterial().equals(VanillaMaterials.FLINT_AND_STEEL)) {
      if (facingBlock.getMaterial().equals(VanillaMaterials.TNT)) {
        // Detonate TntBlock
        VanillaMaterials.TNT.onIgnite(block, new BlockCause(block));
        slot.addData(1);
        return true;
      } else {
        // Default fire placement
        if (VanillaMaterials.FIRE.canCreate(facingBlock, (short) 0, new BlockCause(block))) {
          VanillaMaterials.FIRE.onCreate(facingBlock, (short) 0, new BlockCause(block));
          slot.addData(1);
          return true;
        }
      }
    } else if (item.getMaterial().equals(VanillaMaterials.BUCKET)) {
      if (facingBlock.getMaterial() instanceof Liquid) {
        Liquid liquid = (Liquid) facingBlock.getMaterial();
        if (liquid.isSource(facingBlock)) {
          item.setMaterial(liquid.getContainerMaterial());
          facingBlock.setMaterial(VanillaMaterials.AIR);
          //TODO: physics update necessary here
          return true;
        }
      }
    } else if (item.getMaterial() instanceof Armor) {
      for (Player player : block.getWorld().getNearbyPlayers(block.getPosition(), 2)) {
        if (player.getPhysics().getPosition().getBlock().equals(facingBlock)) {
          PlayerInventory inv = player.get(PlayerInventory.class);
          int armorSlot = ((Armor) item.getMaterial()).getEquipableSlot();
          if (inv.getArmor().get(armorSlot) != null) {
            return false;
          }
          boolean canSet = inv.getArmor().canSet(armorSlot, item);
          InventoryCanSetEvent event = player.getEngine().getEventManager().callEvent(new InventoryCanSetEvent(inv.getArmor(), new BlockCause(block), armorSlot, item, !canSet));
          if (event.isCancelled()) {
            return false;
          }
          inv.getArmor().set(armorSlot, item, true);
          slot.addAmount(-1);
View Full Code Here

TOP

Related Classes of org.spout.api.event.cause.BlockCause

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.