Esempio n. 1
0
  public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
    int dir = world.getBlockMetadata(i, j, k);

    if (dir == 0) {
      if (!world.isBlockOpaqueCube(i, j, k + 1)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 1) {
      if (!world.isBlockOpaqueCube(i - 1, j, k)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 2) {
      if (!world.isBlockOpaqueCube(i, j, k - 1)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    } else if (dir == 3) {
      if (!world.isBlockOpaqueCube(i + 1, j, k)) {
        this.breakBlock(world, i, j, k, blockID, dir);
        world.setBlock(i, j, k, 0);
      }
    }
  }
  public void generate(
      Random random, int i, int k, World world, IChunkProvider provider, IChunkProvider provider2) {
    int x = i * 16;
    int z = k * 16;

    try {
      if (world.getBlockId(x + 4, 0, z) == Block.bedrock.blockID
          && world.getWorldInfo().getTerrainType() != WorldType.FLAT) {
        if (world.getBlockMetadata(x + 4, 0, z) == 0) {
          for (int it = 0; it < 1; it++) {

            world.setBlockMetadataWithNotify(x + 4, 0, z, 0x1, 2);

            x = i * 16;
            z = k * 16;

            int y = EmasherGas.flatBedrockTop;
            if (!EmasherGas.flatBedrock) y = random.nextInt(2) + 3;

            x += random.nextInt(16);
            z += random.nextInt(16);

            if (world.provider.dimensionId != -1) {
              if (random.nextInt(8) == 0) {
                world.setBlock(x, y, z, EmasherGas.shaleResource.blockID, 0, 2);
                // System.out.println("Gen: " + x + ", " + y + ", " + z);

              } else if (Loader.isModLoaded("BuildCraft|Energy") && random.nextInt(12) == 0) {
                world.setBlock(x, y, z, EmasherGas.shaleResource.blockID, 1, 2);
              }
            } else {
              if (random.nextInt(6) == 0)
                world.setBlock(x, y, z, EmasherGas.shaleResource.blockID, 2, 2);
            }
          }
        }
      }
    } catch (Exception e) {
      System.out.println("[GasCraft] Error generating shale resorces for chunk @" + i + ", " + k);
    }
  }
 private static void pathto(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> portals = Lists.newLinkedList();
   List<ChunkCoordinates> repath = Lists.newLinkedList();
   List<ChunkCoordinates> redraw = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while ((portals.size() > 0) || (blocks.size() > 0)) {
     while (blocks.size() > 0) {
       ChunkCoordinates coords = blocks.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       redraw.add(coords);
     }
     if (portals.size() > 0) {
       ChunkCoordinates coords = portals.remove(0);
       directPortal(world, coords.posX + 1, coords.posY, coords.posZ, 5, blocks, portals);
       directPortal(world, coords.posX, coords.posY + 1, coords.posZ, 1, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ + 1, 3, blocks, portals);
       directPortal(world, coords.posX - 1, coords.posY, coords.posZ, 6, blocks, portals);
       directPortal(world, coords.posX, coords.posY - 1, coords.posZ, 2, blocks, portals);
       directPortal(world, coords.posX, coords.posY, coords.posZ - 1, 4, blocks, portals);
       if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
         repath.add(coords);
       }
     }
   }
   while (repath.size() > 0) {
     ChunkCoordinates coords = repath.remove(0);
     if (world.getBlock(coords.posX, coords.posY, coords.posZ) == NailedBlocks.portal) {
       if (!BlockPortal.isValidPortal(world, coords.posX, coords.posY, coords.posZ)) {
         repathNeighbors(world, coords.posX, coords.posY, coords.posZ);
         world.setBlock(coords.posX, coords.posY, coords.posZ, Blocks.air, 0, 0);
         addSurrounding(repath, coords.posX, coords.posY, coords.posZ);
       } else {
         redraw.add(coords);
       }
     }
   }
   for (ChunkCoordinates coords : redraw) {
     if (world.blockExists(coords.posX, coords.posY, coords.posZ)) {
       world.markBlockForUpdate(coords.posX, coords.posY, coords.posZ);
       world.notifyBlocksOfNeighborChange(
           coords.posX,
           coords.posY,
           coords.posZ,
           world.getBlock(coords.posX, coords.posY, coords.posZ));
     }
   }
 }
 private static void depolarize(World world, int i, int j, int k, List<ChunkCoordinates> blocks) {
   Block block = world.getBlock(i, j, k);
   if (isValidLinkPortalBlock(block) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) == 0) {
     return;
   }
   world.setBlockMetadataWithNotify(i, j, k, 0, 0);
   if ((block == NailedBlocks.portal) && (!BlockPortal.isValidPortal(world, i, j, k))) {
     world.setBlock(i, j, k, Blocks.air, 0, 2);
   }
   blocks.add(new ChunkCoordinates(i, j, k));
 }
 @Override
 public void updateTick(World world, int i, int j, int k, Random rand) {
   if (!world.isRemote) {
     if (!world.isBlockOpaqueCube(i, j - 1, k)) {
       if (world.getBlockId(i + 1, j, k) != blockID
           && world.getBlockId(i - 1, j, k) != blockID
           && world.getBlockId(i, j, k + 1) != blockID
           && world.getBlockId(i, j, k - 1) != blockID
           && world.getBlockId(i + 1, j, k + 1) != blockID
           && world.getBlockId(i + 1, j, k - 1) != blockID
           && world.getBlockId(i - 1, j, k + 1) != blockID
           && world.getBlockId(i - 1, j, k - 1) != blockID) {
         world.setBlock(i, j, k, 0);
       }
     }
   }
 }
Esempio n. 6
0
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   boolean check = false;
   for (int h = -1; h <= 1; h++) {
     for (int g = -1; g <= 1; g++) {
       for (int f = -1; f <= 1; f++) {
         if (world.getBlockId(i + h, j + g, k + f) == blockID
             && world.getBlockMetadata(i + h, j + g, k + f) == world.getBlockMetadata(i, j, k)) {
           check = true;
         }
       }
     }
   }
   if (!check) {
     world.setBlock(i, j, k, 0);
   }
 }
 private static void onpulse(World world, int i, int j, int k) {
   List<ChunkCoordinates> set = Lists.newLinkedList();
   Stack<ChunkCoordinates> validate = new Stack<ChunkCoordinates>();
   addSurrounding(set, i, j, k);
   while (set.size() > 0) {
     ChunkCoordinates coords = set.remove(0);
     expandPortal(world, coords.posX, coords.posY, coords.posZ, set, validate);
   }
   while (validate.size() > 0) {
     ChunkCoordinates coords = validate.pop();
     i = coords.posX;
     j = coords.posY;
     k = coords.posZ;
     if (!BlockPortal.checkPortalTension(world, i, j, k)) {
       world.setBlock(i, j, k, Blocks.air, 0, 0);
     }
   }
 }
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   boolean check = false;
   for (int h = -2; h <= 2; h++) {
     for (int g = -2; g <= 2; g++) {
       for (int f = -2; f <= 2; f++) {
         if (world.getBlockId(i + h, j + g, k + f) == blockID
             && world.getBlockMetadata(i + h, j + g, k + f) == world.getBlockMetadata(i, j, k)) {
           check = true;
         }
       }
     }
   }
   if (!check) {
     world.setBlock(i, j, k, 0);
     dropBlockAsItem_do(world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
   }
 }
  private static void expandPortal(
      World world,
      int i,
      int j,
      int k,
      Collection<ChunkCoordinates> set,
      Stack<ChunkCoordinates> created) {
    if (!world.isAirBlock(i, j, k)) {
      return;
    }

    int score =
        isValidLinkPortalBlock(world.getBlock(i + 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i - 1, j, k))
            + isValidLinkPortalBlock(world.getBlock(i, j + 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j - 1, k))
            + isValidLinkPortalBlock(world.getBlock(i, j, k + 1))
            + isValidLinkPortalBlock(world.getBlock(i, j, k - 1));
    if (score > 1) {
      world.setBlock(i, j, k, NailedBlocks.portal, 0, 0);
      created.push(new ChunkCoordinates(i, j, k));
      addSurrounding(set, i, j, k);
    }
  }
  private void scanLogs(
      World world,
      int i,
      int j,
      int k,
      int l,
      boolean[][][] checkArray,
      int x,
      int y,
      int z,
      ItemStack stack) {
    if (y >= 0) {
      checkArray[x][y][z] = true;
      int offsetX = 0;
      int offsetY = 0;
      int offsetZ = 0;

      for (offsetY = 0; offsetY <= 1; offsetY++) {
        for (offsetX = -2; offsetX <= 2; offsetX++) {
          for (offsetZ = -2; offsetZ <= 2; offsetZ++) {
            if (x + offsetX < 11
                && x + offsetX >= 0
                && z + offsetZ < 11
                && z + offsetZ >= 0
                && y + offsetY < 50
                && y + offsetY >= 0) {
              if (checkOut(world, i + offsetX, j + offsetY, k + offsetZ, l)
                  && !checkArray[x + offsetX][y + offsetY][z + offsetZ]) {
                scanLogs(
                    world,
                    i + offsetX,
                    j + offsetY,
                    k + offsetZ,
                    l,
                    checkArray,
                    x + offsetX,
                    y + offsetY,
                    z + offsetZ,
                    stack);
              }
            }
          }
        }
      }

      damage++;
      if (stack != null) {
        if (damage + stack.getItemDamage() <= stack.getMaxDamage()) {
          world.setBlock(i, j, k, 0);
          world.markBlockForUpdate(i, j, k);
          if ((isStone && world.rand.nextInt(10) != 0) || !isStone)
            dropBlockAsItem_do(
                world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
        }
      } else {
        world.setBlock(i, j, k, 0);
        world.markBlockForUpdate(i, j, k);
        dropBlockAsItem_do(
            world, i, j, k, new ItemStack(Item.itemsList[TFCItems.Logs.itemID], 1, l));
      }
    }
  }