@Override
  public BlockFunction rotate() {
    BlockFunction rotatedBlock = new BlockFunction();
    rotatedBlock.x = z;
    rotatedBlock.y = y;
    rotatedBlock.z = -x;
    rotatedBlock.material = material.rotate();
    rotatedBlock.hasMetaData = hasMetaData;
    rotatedBlock.metaDataTag = metaDataTag;
    rotatedBlock.metaDataName = metaDataName;

    return rotatedBlock;
  }
Exemplo n.º 2
0
  @Override
  public void spawn(LocalWorld world, Random rand, boolean villageInChunk, int x, int z) {
    int y = rand.nextInt(maxAltitude - minAltitude) + minAltitude;

    if (!sourceBlocks.contains(world.getMaterial(x, y + 1, z))) return;
    if (!sourceBlocks.contains(world.getMaterial(x, y - 1, z))) return;

    if (!world.isEmpty(x, y, z) && (!sourceBlocks.contains(world.getMaterial(x, y, z)))) return;

    int i = 0;
    int j = 0;

    LocalMaterialData tempBlock = world.getMaterial(x - 1, y, z);

    i = (sourceBlocks.contains(tempBlock)) ? i + 1 : i;
    j = (tempBlock.isMaterial(DefaultMaterial.AIR)) ? j + 1 : j;

    tempBlock = world.getMaterial(x + 1, y, z);

    i = (sourceBlocks.contains(tempBlock)) ? i + 1 : i;
    j = (tempBlock.isMaterial(DefaultMaterial.AIR)) ? j + 1 : j;

    tempBlock = world.getMaterial(x, y, z - 1);

    i = (sourceBlocks.contains(tempBlock)) ? i + 1 : i;
    j = (tempBlock.isMaterial(DefaultMaterial.AIR)) ? j + 1 : j;

    tempBlock = world.getMaterial(x, y, z + 1);

    i = (sourceBlocks.contains(tempBlock)) ? i + 1 : i;
    j = (tempBlock.isMaterial(DefaultMaterial.AIR)) ? j + 1 : j;

    if ((i == 3) && (j == 1)) {
      world.setBlock(x, y, z, material);
    }
  }