Package org.spout.api.material

Examples of org.spout.api.material.BlockMaterial


      for (AtomicBoolean bool : this.mainDirection) {
        if (bool.get()) {
          x += this.dX;
          z += this.dZ;
          int fullState = world.getBlockFullState(x, y, z);
          BlockMaterial mat = BlockFullState.getMaterial(fullState);
          if (Liquid.isLiquidObstacle(mat) || (VanillaMaterials.WATER.isMaterial(mat) && VanillaMaterials.WATER.isSource(BlockFullState.getData(fullState)))) {
            this.state = State.BLOCKED;
            this.holeDistance = Integer.MAX_VALUE;
          } else if (!Liquid.isLiquidObstacle(world.getBlockMaterial(x, y - 1, z))) {
            this.state = State.HOLE;
View Full Code Here


          for (int y = end.getFloorY() - 1; y >= start.getFloorY(); y--) {
            final double yOffset = (y + 0.5 - target.getY()) / verticalSize;
            if ((xOffset * xOffset + zOffset * zOffset) * horizontalScales[y] + (yOffset * yOffset) / 6 < 1) {
              final int xx = chunk.getFloorX() + x;
              final int zz = chunk.getFloorZ() + z;
              final BlockMaterial material = blockData.get(xx, y, zz);
              if (material.equals(VanillaMaterials.STONE) || material.equals(VanillaMaterials.DIRT)
                  || material.equals(VanillaMaterials.GRASS)) {
                if (y < 10) {
                  blockData.set(xx, y, zz, VanillaMaterials.STATIONARY_LAVA);
                } else {
                  if (material.equals(VanillaMaterials.GRASS)
                      && blockData.get(xx, y - 1, zz).equals(VanillaMaterials.DIRT)) {
                    blockData.set(xx, y - 1, zz, VanillaMaterials.GRASS);
                  }
                  blockData.set(xx, y, zz, VanillaMaterials.AIR);
                }
View Full Code Here

    randomize();
  }

  @Override
  public boolean canPlaceObject(World w, int x, int y, int z) {
    final BlockMaterial below = w.getBlockMaterial(x, y - 1, z);
    return w.getBlockMaterial(x, y, z).isMaterial(VanillaMaterials.AIR)
        && below.isMaterial(VanillaMaterials.DIRT, VanillaMaterials.GRASS, VanillaMaterials.SAND)
        && (w.getBlockMaterial(x - 1, y - 1, z) instanceof Water
        || w.getBlockMaterial(x + 1, y - 1, z) instanceof Water
        || w.getBlockMaterial(x, y - 1, z - 1) instanceof Water
        || w.getBlockMaterial(x, y - 1, z + 1) instanceof Water);
  }
View Full Code Here

      if (center <= 1 || v.getW() != center) {
        continue;
      }

      BlockMaterial m = material.get(v.getX(), v.getY(), v.getZ());

      if (m == BlockMaterial.UNGENERATED) {
        continue;
      }

      final boolean boundary = v.getX() == baseX || v.getX() == (topX - 1) || v.getY() == baseY || v.getY() == topY - 1 || v.getZ() == baseZ || v.getZ() == topZ - 1;

      for (BlockFace face : allFaces) {
        IntVector3 off = face.getIntOffset();
        int nx = v.getX() + off.getX();
        int ny = v.getY() + off.getY();
        int nz = v.getZ() + off.getZ();
        if (boundary && (nx < baseX || nx >= topX || ny <= baseY || ny >= topY || nz < baseZ || nz >= topZ)) {
          continue;
        }

        BlockMaterial other = material.get(nx, ny, nz);

        log("(Higher) checking neighbor: material=" + other, nx, ny, nz);

        if (other.isOpaque() || other.getOcclusion(other.getData()).get(face.getOpposite())) {
          continue;
        }

        int oldLevel = getLightLevel(light, nx, ny, nz);

        log("(Higher) old light", nx, ny, nz, oldLevel);

        if (oldLevel == 15) {
          continue;
        }

        int opacity = other.getOpacity() + 1;

        int newLevel = center - opacity;

        log("(Higher) new level", nx, ny, nz, newLevel);
View Full Code Here

    while ((v = fifo.read()) != null) {
      int center = v.getW();

      log("(Lower) checking center (W = " + v.getW() + ")", v, center);

      BlockMaterial m = material.get(v.getX(), v.getY(), v.getZ());

      if (m == BlockMaterial.UNGENERATED) {
        continue;
      }

      final boolean boundary = v.getX() == baseX || v.getX() == (topX - 1) || v.getY() == baseY || v.getY() == topY - 1 || v.getZ() == baseZ || v.getZ() == topZ - 1;

      for (BlockFace face : allFaces) {

        IntVector3 off = face.getIntOffset();
        int nx = v.getX() + off.getX();
        int ny = v.getY() + off.getY();
        int nz = v.getZ() + off.getZ();
        if (boundary && (nx < baseX || nx >= topX || ny <= baseY || ny >= topY || nz < baseZ || nz >= topZ)) {
          continue;
        }
        BlockMaterial other = material.get(nx, ny, nz);

        if (other == BlockMaterial.UNGENERATED) {
          continue;
        }

        log("(Lower) checking neighbor: material=" + other, nx, ny, nz);

        int oldLevel = getLightLevel(light, nx, ny, nz);

        log("(Lower) old light", nx, ny, nz, oldLevel);

        if (oldLevel > 0) {
          int opacity = other.getOpacity() + 1;

          int oldSupportLevel = center - opacity;

          log("(Lower) supported light", nx, ny, nz, oldSupportLevel);
View Full Code Here

  }

  protected abstract int getEmittedLight(ImmutableCuboidBlockMaterialBuffer material, ImmutableHeightMapBuffer height, int x, int y, int z);

  protected int computeLightLevel(ChunkCuboidLightBufferWrapper<VanillaCuboidLightBuffer> light, ImmutableCuboidBlockMaterialBuffer material, ImmutableHeightMapBuffer height, int x, int y, int z) {
    BlockMaterial m = material.get(x, y, z);
    short data = material.getData(x, y, z);

    ByteBitSet occlusionSet = m.getOcclusion(data);

    int neighborLight = getEmittedLight(material, height, x, y, z);

    if (m.isOpaque() || occlusionSet.get(BlockFaces.NESWBT)) {
      return neighborLight;
    }

    int opacity = m.getOpacity() + 1;

    for (int i = 0; i < 6; i++) {
      BlockFace face = allFaces[i];
      int faceLight = getIncomingLight(light, material, x, y, z, occlusionSet, face) - opacity;
      neighborLight = Math.max(neighborLight, faceLight);
View Full Code Here

      if (yy == 1 || yy == totalHeight - 1) {
        radiusToCheck++;
      }
      for (byte xx = (byte) -radiusToCheck; xx < radiusToCheck + 1; xx++) {
        for (byte zz = (byte) -radiusToCheck; zz < radiusToCheck + 1; zz++) {
          final BlockMaterial material = w.getBlockMaterial(x + xx, y + yy, z + zz);
          if (!overridable.contains(material)) {
            if (yy == 0 && material instanceof Water) {
              continue;
            }
            return false;
View Full Code Here

    if (id == BlockMaterial.UNGENERATED.getId()) {
      return 0;
    }
    short data = material.getData(nx, ny, nz);

    BlockMaterial m = BlockMaterial.get(id, data);

    ByteBitSet neighborOcclusionSet = m.getOcclusion(data);
    if (neighborOcclusionSet.get(face.getOpposite())) {
      return 0;
    }

    return getLightLevel(light, nx, ny, nz);
View Full Code Here

      int x = v.getX();
      int y = v.getY();
      int z = v.getZ();

      BlockMaterial m = buffer.get(x + baseX - 1, y + baseY - 1, z + baseZ - 1);

      ByteBitSet occulusion = m.getOcclusion(m.getData());

      int center = newLight[x][y][z];

      for (BlockFace face : allFaces) {
        if (occulusion.get(face)) {
          continue;
        }
        IntVector3 off = face.getIntOffset();
        int nx = x + off.getX();
        int ny = y + off.getY();
        int nz = z + off.getZ();
        if (nx <= 0 || nx > sizeX || ny <= 0 || ny > sizeY || nz <= 0 || nz > sizeZ) {
          continue;
        }
        BlockMaterial other = buffer.get(nx + baseX - 1, ny + baseY - 1, nz + baseZ - 1);

        int opacity = other.getOpacity() + 1;

        int newLevel = center - opacity;

        if (newLevel > newLight[nx][ny][nz] && !other.getOcclusion(other.getData()).get(face.getOpposite())) {
          newLight[nx][ny][nz] = newLevel;
          if (!dirty[nx][ny][nz]) {
            dirty[nx][ny][nz] = true;
            fifo.write(nx, ny, nz);
          }
View Full Code Here

    z -= 8;
    for (byte px = 0; px < 16; px++) {
      for (byte pz = 0; pz < 16; pz++) {
        for (byte py = 1; py < 5; py++) {
          if (isWallBlock(px, py, pz, holeHeightMap)) {
            final BlockMaterial material = world.getBlockMaterial(x + px, y - py, z + pz);
            if (!(material instanceof Solid) && material != liquid) {
              return false;
            }
          } else if (isWallBlock(px, py, pz, topHeightMap)) {
            if (world.getBlockMaterial(x + px, y + py, z + pz) instanceof Liquid) {
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.