Package org.spout.api.geo.cuboid

Examples of org.spout.api.geo.cuboid.Block


  }

  @Override
  public boolean canPlace(Block block, short data, BlockFace against, Vector3f clickedPos, boolean isClickedBlock, Cause<?> cause) {
    if (against == BlockFace.BOTTOM && super.canPlace(block, data, against, clickedPos, isClickedBlock, cause)) {
      Block below = block.translate(BlockFace.BOTTOM);
      BlockMaterial material = below.getMaterial();
      Block headBlock = block.translate(PlayerUtil.getFacing(cause));
      if (!VanillaMaterials.AIR.equals(headBlock)) {
        return false;
      }
      if (material instanceof VanillaBlockMaterial) {
        return ((VanillaBlockMaterial) material).canSupport(this, BlockFace.TOP);
View Full Code Here


  }

  @Override
  public boolean isValidPosition(Block block, BlockFace attachedFace, boolean seekAlternative) {
    if (super.isValidPosition(block, attachedFace, seekAlternative)) {
      final Block under = block.translate(BlockFace.BOTTOM);
      return under.isMaterial(VanillaMaterials.MYCELIUM) || VanillaLighting.getLight(block) <= 12 && under.getMaterial().isOpaque();
    }
    return false;
  }
View Full Code Here

          return;
        }
      }
      Cause<?> cause = toCause(block);
      // spread from the source (4 times)
      Block newShroom;
      for (int i = 0; i < 4; i++) {
        newShroom = block.translate(rand.nextInt(3) - 1, rand.nextInt(2) - rand.nextInt(2), rand.nextInt(3) - 1);
        if (newShroom.isMaterial(VanillaMaterials.AIR) && this.canCreate(newShroom, (short) 0, cause)) {
          block = newShroom;
        }
      }
      // try to place at last
      if (block.isMaterial(VanillaMaterials.AIR) && this.canCreate(block, (short) 0, cause)) {
View Full Code Here

  public boolean shootItem(Block block, Slot slot) {
    if (slot == null) {
      GeneralEffects.RANDOM_CLICK2.playGlobal(block.getPosition());
      return false;
    }
    Block facingBlock = block.translate(this.getFacing(block));
    if (facingBlock.getMaterial().getShape() != null) {
      Item item = facingBlock.getWorld().createEntity(facingBlock.getPosition(), Item.class).add(Item.class);
      item.setItemStack(slot.get().clone());
      item.getItemStack().setAmount(1);
      facingBlock.getWorld().spawnEntity(item.getOwner());

      GeneralEffects.RANDOM_CLICK1.playGlobal(block.getPosition());
      GeneralEffects.SMOKE.playGlobal(facingBlock.getPosition());
      slot.addAmount(-1);
      return true;
    }
    return false;
  }
View Full Code Here

    int chance = VanillaBlockMaterial.getCropGrowthChance(block) + 1;
    final Random rand = GenericMath.getRandom();
    if (rand.nextInt(chance) == 0) {
      if (isFullyGrown(block)) {
        for (int i = 0; i < BlockFaces.NESW.size(); i++) {
          Block spread = block.translate(BlockFaces.NESW.get(i));
          BlockMaterial material = spread.getMaterial();
          if (material == VanillaMaterials.AIR) {
            BlockMaterial belowSpread = spread.translate(BlockFace.BOTTOM).getMaterial();
            if (belowSpread.isMaterial(VanillaMaterials.FARMLAND, VanillaMaterials.DIRT, VanillaMaterials.GRASS)) {
              spread.setMaterial(this.getLastStageMaterial());
              break;
            }
          } else if (material == getLastStageMaterial()) {
            break;
          }
View Full Code Here

    if (rand.nextInt(1000) == 0) {
      EffectIterator iterator = EffectRange.NEIGHBORS.iterator();
      while (iterator.hasNext()) {
        if (!(block.translate(iterator.next()).getMaterial() instanceof Water)) {
          //Make sure you don't eliminate water below
          Block below = block.translate(BlockFace.BOTTOM);
          if (below.getMaterial() == VanillaMaterials.WATER) {
            below.setMaterial(getStationaryMaterial());
          }
          block.setMaterial(VanillaMaterials.ICE);
          return;
        }
      }
View Full Code Here

      BlockIterator iterator = head.getBlockView();
      if (iterator == null || !iterator.hasNext()) {
        return;
      }
      while (iterator.hasNext()) {
        Block block = iterator.next();
        if (!(block.getMaterial() instanceof Water)) {
          continue;
        }
        block = block.translate(BlockFace.TOP);
        Cause<Entity> cause;
        if (entity instanceof Player) {
          cause = new PlayerBreakCause((Player) entity, block);
        } else {
          cause = new EntityCause(entity);
View Full Code Here

          facing = face.getOpposite();
        }
      }
    }
    // search for neighbor and align
    Block neigh;
    for (BlockFace face : BlockFaces.NESW) {
      if ((neigh = block.translate(face)).getMaterial().equals(this)) {
        if (face == facing || face == facing.getOpposite()) {
          if (facing == BlockFace.NORTH || facing == BlockFace.SOUTH) {
            facing = BlockFace.WEST;
View Full Code Here

   * @param block to get source of power of
   * @return Source of redstone power, or null if none
   */
  public static Block getReceivingPowerLocation(Block block) {
    for (BlockFace face : BlockFaces.NESWBT) {
      Block b = block.translate(face);
      if (isEmittingPower(b, face.getOpposite())) {
        return b;
      }
    }
    return null;
View Full Code Here

      setBlockMaterial(1, 0, sectionZ + random.nextInt(3), VanillaMaterials.MONSTER_SPAWNER);
    }
    // bridge gaps
    for (byte xx = 0; xx <= 2; xx++) {
      for (byte zz = 0; zz <= lenght; zz++) {
        final Block block = getBlock(xx, -1, zz);
        if (block.isMaterial(VanillaMaterials.AIR)) {
          block.setMaterial(VanillaMaterials.PLANK);
        }
      }
    }
    // rails
    if (hasRails) {
View Full Code Here

TOP

Related Classes of org.spout.api.geo.cuboid.Block

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.