コード例 #1
0
 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));
 }
コード例 #2
0
 private static void redirectPortal(
     World world,
     TileEntity tileentity,
     int i,
     int j,
     int k,
     int meta,
     List<ChunkCoordinates> blocks) {
   if (isValidLinkPortalBlock(world.getBlock(i, j, k)) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) == meta) {
     for (int m = 1; m < 7; m++) {
       if (m != meta) {
         world.setBlockMetadataWithNotify(i, j, k, m, 2);
         TileEntity local = getTileEntity(world, i, j, k);
         if ((local == tileentity) || ((local != null) && (tileentity == null))) {
           return;
         }
       }
     }
     world.setBlockMetadataWithNotify(i, j, k, 0, 2);
   }
 }
コード例 #3
0
 private static void repathNeighbors(World world, int i, int j, int k) {
   TileEntity tileentity = getTileEntity(world, i, j, k);
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   world.setBlockMetadataWithNotify(i, j, k, 8, 2);
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     redirectPortal(world, tileentity, coords.posX + 1, coords.posY, coords.posZ, 5, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY + 1, coords.posZ, 1, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY, coords.posZ + 1, 3, blocks);
     redirectPortal(world, tileentity, coords.posX - 1, coords.posY, coords.posZ, 6, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY - 1, coords.posZ, 2, blocks);
     redirectPortal(world, tileentity, coords.posX, coords.posY, coords.posZ - 1, 4, blocks);
   }
 }
コード例 #4
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);
    }
  }
コード例 #5
0
 private static void directPortal(
     World world,
     int i,
     int j,
     int k,
     int meta,
     List<ChunkCoordinates> blocks,
     List<ChunkCoordinates> portals) {
   if (isValidLinkPortalBlock(world.getBlock(i, j, k)) == 0) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) != 0) {
     return;
   }
   world.setBlockMetadataWithNotify(i, j, k, meta, 0);
   if (world.getBlock(i, j, k) == NailedBlocks.portal) {
     portals.add(new ChunkCoordinates(i, j, k));
   } else {
     blocks.add(new ChunkCoordinates(i, j, k));
   }
 }
コード例 #6
0
  private boolean moveToBlock(World world, int x, int y, int z, int x2, int y2, int z2) {
    int blockID2 = world.getBlockId(x2, y2, z2);
    int originMeta = world.getBlockMetadata(x, y, z);
    int destMeta = world.getBlockMetadata(x2, y2, z2);
    if (blockID2 == this.blockID) {
      if (destMeta > originMeta || y > y2) {
        if (originMeta < 7 && destMeta > 0) {
          world.setBlockMetadata(x, y, z, originMeta + 1);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else if (destMeta > 0) {
          world.setBlockWithNotify(x, y, z, 0);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else if (liquidCanDisplaceBlock(world, x2, y2, z2)) {
      if (blockID2 > 0) {
        if (this.blockMaterial == Material.lava) {
          this.triggerLavaMixEffects(world, x2, y2, z2);
        } else if (blockID2 == Block.waterMoving.blockID || blockID2 == Block.waterStill.blockID) {
          if (originMeta < 7) {
            world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
            world.markBlockForUpdate(x, y, z);
            return true;
          } else {
            world.setBlockWithNotify(x, y, z, 0);
            world.markBlockForUpdate(x, y, z);
            return true;
          }
        } else {
          Block.blocksList[blockID2].dropBlockAsItem(
              world, x2, y2, z2, world.getBlockMetadata(x2, y2, z2), 0);
        }
      }

      if (y2 < y) {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, originMeta);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
      if (originMeta < 7) {
        world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      } else if (world.getBlockId(x - 1, y, z) != this.blockID
          && world.getBlockId(x + 1, y, z) != this.blockID
          && world.getBlockId(x, y + 1, z) != this.blockID
          && world.getBlockId(x, y, z - 1) != this.blockID
          && world.getBlockId(x, y, z + 1) != this.blockID) {
        world.setBlockWithNotify(x, y, z, 0);
        return true;
      } else {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
    } else {
      return false;
    }
  }