Package org.spout.api.geo.cuboid

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


    }
    BlockFace facing = VanillaMaterials.END_PORTAL_FRAME.getFacing(frameBlock);
    // Rotates the facing 90 degrees to the left
    BlockFace lookDirection = BlockFaces.NESW.previous(facing);
    // Get the corner piece
    Block corner = frameBlock;
    for (int i = 0; i < 4 && isEndFrame(corner, facing, false); i++) {
      corner = corner.translate(lookDirection);
    }
    // Now go two steps back and two steps towards the middle (facing)
    return corner.translate(lookDirection, -2).translate(facing, 2);
  }
View Full Code Here


      chestObject.setRandom(random);
      byte chestCount = 0;
      for (byte attempts = 0; attempts < 6; attempts++) {
        final int xx = random.nextInt(radiusX * 2 + 1) - radiusX + x;
        final int zz = random.nextInt(radiusZ * 2 + 1) - radiusZ + z;
        final Block middle = w.getBlock(xx, y, zz);
        if (!middle.getMaterial().isMaterial(VanillaMaterials.AIR)) {
          continue;
        }
        byte adjacentSolidBlockCount = 0;
        for (final BlockFace face : BlockFaces.NESW) {
          if (middle.translate(face).getMaterial().isOpaque()) {
            adjacentSolidBlockCount++;
          }
        }
        if (adjacentSolidBlockCount != 1) {
          continue;
View Full Code Here

    return corner.translate(lookDirection, -2).translate(facing, 2);
  }

  private boolean findFrame(Block origin, boolean withEnderEye) {
    for (BlockFace face : BlockFaces.NESW) {
      Block frame = origin.translate(face, 2);
      BlockFace facing = face.getOpposite();
      if (!isEndFrame(frame, facing, withEnderEye)) {
        return false;
      }
      if (!isEndFrame(frame.translate(BlockFaces.NESW.previous(face)), facing, withEnderEye)) {
        return false;
      }
      if (!isEndFrame(frame.translate(BlockFaces.NESW.next(face)), facing, withEnderEye)) {
        return false;
      }
    }
    return true;
  }
View Full Code Here

    final List<Block> liquids = new ArrayList<Block>();
    for (byte count = 0; count < waterAttempts; count++) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(height - 8) + 8;
      final int z = chunk.getBlockZ(random);
      final Block block = world.getBlock(x, y, z);
      if (isValidSourcePoint(block)) {
        block.setMaterial(VanillaMaterials.WATER);
        liquids.add(block);
      }
    }
    for (byte count = 0; count < lavaAttempts; count++) {
      final int x = chunk.getBlockX(random);
      final int y = random.nextInt(height - 8) + 8;
      final int z = chunk.getBlockZ(random);
      final Block block = world.getBlock(x, y, z);
      if (isValidSourcePoint(block)) {
        block.setMaterial(VanillaMaterials.LAVA);
        liquids.add(block);
      }
    }
    Liquid.performInstantFlow(liquids);
  }
View Full Code Here

    }
  }

  public void setActive(World w, int x, int y, int z, boolean active) {
    // No portal found
    Block origin = getOrigin(w.getBlock(x, y, z));
    if (origin != null && findFrame(origin, false)) {
      setEyesActive(origin, active);
      setPortalActive(origin, active);
    }
  }
View Full Code Here

      setPortalActive(origin, active);
    }
  }

  public boolean isActive(World w, int x, int y, int z) {
    Block origin = getOrigin(w.getBlock(x, y, z));
    return origin != null && findFrame(origin, true);
  }
View Full Code Here

    return origin != null && findFrame(origin, true);
  }

  @Override
  public void placeObject(World w, int x, int y, int z) {
    Block origin = w.getBlock(x, y, z);

    // Generate the frames
    for (BlockFace face : BlockFaces.NESW) {
      Block frame = origin.translate(face, 2);
      BlockFace facing = face.getOpposite();
      // Place the three pieces
      placeFrame(frame, facing);
      placeFrame(frame.translate(BlockFaces.NESW.previous(face)), facing);
      placeFrame(frame.translate(BlockFaces.NESW.next(face)), facing);
    }

    // Set to a random state
    setRandomActive(origin, 0.1f);
  }
View Full Code Here

    return true;
  }

  @Override
  public void placeObject(World w, int x, int y, int z) {
    final Block block = w.getBlock(x, y, z);
    VanillaMaterials.CHEST.onPlacement(block, (short) 0, null, null, false, null);
    final ChestInventory inventory = block.get(Chest.class).getInventory();
    final int numberOfStack = random.nextInt(maxNumberOfStacks - minNumberOfStacks + 1) + minNumberOfStacks;
    final int size = inventory.size();
    for (int i = 0; i < numberOfStack; i++) {
      inventory.set(random.nextInt(size), MathHelper.chooseWeightedRandom(random, loot).getRandomStack(random));
    }
View Full Code Here

          world.setBlockMaterial(px + x, py + y, pz + z, VanillaMaterials.AIR, (short) 0, null);
        }
        if (stonyTop) {
          for (byte py = 1; py < 5; py++) {
            if (isWallBlock(px, py, pz, topHeightMap)) {
              final Block block = world.getBlock(px + x, py + y - 1, pz + z);
              if (random.nextBoolean() && block.getMaterial().isOpaque()) {
                block.setMaterial(VanillaMaterials.STONE);
              }
            }
          }
        }
        if (sandy && columnHasLiquid) {
View Full Code Here

  private void finalizeSurface(World world, int x, int y, int z) {
    for (byte px = 0; px < 16; px++) {
      for (byte pz = 0; pz < 16; pz++) {
        for (byte py = -1; py < 4; py++) {
          final Block block = world.getBlock(x + px, y + py, z + pz);
          if (block.isAtSurface()) {
            final BlockMaterial material = block.getMaterial();
            if (material == VanillaMaterials.DIRT) {
              final BlockMaterial top;
              final Biome biome = block.getBiomeType();
              if (biome instanceof GrassyBiome) {
                top = ((GrassyBiome) biome).getGroundCover()[0].getMaterial(true);
              } else {
                top = VanillaMaterials.GRASS;
              }
              block.setMaterial(top);
            } else if (material == VanillaMaterials.STATIONARY_WATER
                && block.translate(0, 1, 0).isMaterial(VanillaMaterials.AIR)) {
              if (block.getBiomeType() instanceof SnowyBiome) {
                block.setMaterial(VanillaMaterials.ICE);
              }
            }
          }
        }
      }
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.