Package org.spout.api.material

Examples of org.spout.api.material.BlockMaterial


      if (level < 0) {
        return false;
      }
    }
    Block spread = block.getWorld().getBlock(block.getX(), block.getY(), block.getZ()).translate(to);
    BlockMaterial spreadMat = spread.getMaterial();
    if (this.isMaterial(spreadMat)) {
      if (this.isMaximumLevel(spread)) {
        // If the block above was a non-flowing source, return false to make it spread outwards
        // If the block above was not a source, return true to stop spreading
        return !this.isSource(block);
View Full Code Here


    if (liquids.isEmpty()) {
      return;
    }
    final TInt21TripleHashSet ignoredBlocks = new TInt21TripleHashSet();
    final List<Block> tmpBlocks = new ArrayList<Block>();
    BlockMaterial material;
    while (!liquids.isEmpty()) {
      for (Block liquid : liquids) {
        material = liquid.getMaterial();
        if (!ignoredBlocks.add(liquid.getX(), liquid.getY(), liquid.getZ())) {
          continue;
View Full Code Here

   * @return the block of the hook, or null if not find
   */
  public Block findHook(Block wire, BlockFace direction) {
    for (int i = 0; i < MAX_DISTANCE; i++) {
      wire = wire.translate(direction);
      BlockMaterial material = wire.getMaterial();
      if (material.isMaterial(VanillaMaterials.TRIPWIRE_HOOK) && VanillaMaterials.TRIPWIRE_HOOK.getAttachedFace(wire) == direction) {
        return wire;
      } else if (!material.isMaterial(VanillaMaterials.TRIPWIRE)) {
        break;
      }
    }
    return null;
  }
View Full Code Here

    box.setPicker(picker);
    box.setMinMax(-1, 1, 1, 8, 4, 13).randomFill(0.07f);
    // Place bookshelves on the walls
    for (int zz = 1; zz <= 13; zz++) {
      final boolean planks = (zz - 1) % 4 == 0;
      final BlockMaterial material = planks ? VanillaMaterials.PLANK : VanillaMaterials.BOOKSHELF;
      picker.setOuterInnerMaterials(material, material);
      box.setMinMax(-2, 1, zz, -2, 4, zz).fill();
      box.offsetMinMax(11, 0, 0, 11, 0, 0).fill();
      if (planks) {
        attachMaterial(-1, 3, zz, VanillaMaterials.TORCH);
View Full Code Here

  }

  @Override
  public boolean onDestroy(Block block, Cause<?> cause) {
    block = block.translate(this.getFacing(block).getOpposite());
    BlockMaterial mat = block.getMaterial();
    if (mat instanceof PistonBlock) {
      return mat.onDestroy(block, cause);
    } else {
      return super.onDestroy(block, cause);
    }
  }
View Full Code Here

  }

  @Override
  public boolean canCreate(Block block, short data, Cause<?> cause) {
    if (super.canCreate(block, data, cause) && VanillaConfiguration.FIRE_PHYSICS.getBoolean()) {
      BlockMaterial mat;
      for (BlockFace face : BlockFaces.BTNSWE) {
        mat = block.translate(face).getMaterial();
        if (mat instanceof VanillaBlockMaterial) {
          if (((VanillaBlockMaterial) mat).canSupport(this, face.getOpposite())) {
            return true;
View Full Code Here

   * @param block of the fire
   * @param to the face the source is
   * @return True if it has a source there, False if not
   */
  public boolean hasBurningSource(Block block, BlockFace to) {
    BlockMaterial material = block.translate(to).getMaterial();
    return material instanceof Burnable && ((Burnable) material).getBurnPower() > 0;
  }
View Full Code Here

   *
   * @param block of the fire
   * @return True if it can degrade, False if not
   */
  public boolean canDegrade(Block block) {
    BlockMaterial below = block.translate(BlockFace.BOTTOM).getMaterial();
    if (below.equals(VanillaMaterials.NETHERRACK)) {
      return false;
    }
    return !(below.equals(VanillaMaterials.BEDROCK) && block.getWorld().getData().get(VanillaData.DIMENSION) == Dimension.THE_END);
  }
View Full Code Here

  }

  @Override
  public boolean canDecayAt(Block block) {
    block = block.translate(BlockFace.TOP);
    BlockMaterial mat = block.getMaterial();
    if ((!(mat instanceof Snow)) || (!(mat.isMaterial(VanillaMaterials.SLAB)))) {
      return (block.getMaterial().getOpacity() > 0 && VanillaLighting.getLight(block) < 4);
    }
    return false;
  }
View Full Code Here

    // Try to instantly combust surrounding blocks
    Block sBlock;
    for (BlockFace face : BlockFaces.NESWBT) {
      int chance = BlockFaces.TB.contains(face) ? 250 : 300;
      sBlock = b.translate(face);
      BlockMaterial mat = sBlock.getMaterial();
      if (mat instanceof Burnable && rand.nextInt(chance) < ((Burnable) mat).getCombustChance()) {
        // Destroy the old block
        if (mat instanceof TntBlock) {
          ((TntBlock) mat).onIgnite(sBlock, toCause(b)); // Ignite TntBlock
        } else if (mat instanceof VanillaBlockMaterial) {
          VanillaBlockMaterial sVanillaBlock = (VanillaBlockMaterial) mat; // Destroy vanilla blocks without drops
          sVanillaBlock.getDrops().clear();
          sVanillaBlock.destroy(sBlock, toCause(b));
        } else {
          sBlock.setMaterial(VanillaMaterials.AIR); // Set non vanilla blocks to air
        }
        // Put fire in it's place?
        if (rand.nextInt(blockData + 10) < 5 && hasBurningSource(sBlock) && !VanillaBlockMaterial.isRaining(sBlock)) {
          sBlock.setMaterial(this, Math.min(15, blockData + rand.nextInt(5) / 4));
        }
      }
    }

    // Spreading component
    int chanceFactor, firePower, netChance;
    for (IntVector3 offset : SPREAD_RANGE) {

      // Don't spread to the middle or to non-air and other fire blocks
      if (offset.getX() == 0 && offset.getY() == 0 && offset.getZ() == 0) {
        continue;
      }
      sBlock = b.translate(offset);
      if (!sBlock.isMaterial(VanillaMaterials.AIR)) {
        continue;
      }

      // Get power level for this fire
      firePower = 0;
      for (BlockFace face : BlockFaces.NESWBT) {
        BlockMaterial mat = sBlock.translate(face).getMaterial();
        if (mat instanceof Burnable) {
          firePower = Math.max(firePower, ((Burnable) mat).getBurnPower());
        }
      }
      if (firePower == 0) {
View Full Code Here

TOP

Related Classes of org.spout.api.material.BlockMaterial

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.