public static void unpath(World world, int i, int j, int k) {
   List<ChunkCoordinates> blocks = Lists.newLinkedList();
   List<ChunkCoordinates> notify = Lists.newLinkedList();
   blocks.add(new ChunkCoordinates(i, j, k));
   while (blocks.size() > 0) {
     ChunkCoordinates coords = blocks.remove(0);
     depolarize(world, coords.posX + 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY + 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ + 1, blocks);
     depolarize(world, coords.posX - 1, coords.posY, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY - 1, coords.posZ, blocks);
     depolarize(world, coords.posX, coords.posY, coords.posZ - 1, blocks);
     notify.add(coords);
   }
   for (ChunkCoordinates coords : notify) {
     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));
     }
   }
 }
Esempio n. 2
0
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityplayer,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    super.onBlockActivated(world, x, y, z, entityplayer, side, hitX, hitY, hitZ);
    TileEntityQuern te = (TileEntityQuern) world.getBlockTileEntity(x, y, z);
    if (!world.isRemote) {
      if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.storage[2] != null) {
        te.shouldRotate = true;
        world.playSoundEffect(x, y, z, TFC_Sounds.STONEDRAG, 1, 1);
      } else if ((!te.shouldRotate && (hitX < 0.65 || hitZ < 0.65)) || te.storage[2] == null) {
        entityplayer.openGui(TerraFirmaCraft.instance, 33, world, x, y, z);
      }
    } else if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.hasQuern) {
      te.shouldRotate = true;
    }

    return true;
  }
Esempio n. 3
0
 @Override
 public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
   if (world.getBlockId(i, j - 1, k) == this.blockID || world.isBlockOpaqueCube(i, j - 1, k)) {
     return AxisAlignedBB.getBoundingBox(i + 0.3, j, k + 0.3, i + 0.7, j + 1, k + 0.7);
   }
   return AxisAlignedBB.getBoundingBox(i, j + 0.4, k, i + 1, j + 0.6, k + 1);
 }
Esempio n. 4
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);
      }
    }
  }
  @Override
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
    ChunkCoordinates coord =
        getBase(par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
    if (par1World.getBlock(coord.posX, coord.posY, coord.posZ) != NailedBlocks.portalCrystal) {
      this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
      par1World.setBlockToAir(par2, par3, par4);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, block);
  }
  @Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure the player has the correct tool out
    boolean isAxeorSaw = false;
    boolean isHammer = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (!world.isRemote) {
      if (equip != null) {
        for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Axes[cnt]) {
            isAxeorSaw = true;
            if (cnt < 4) isStone = true;
          }
        }
        //				for(int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++)
        //				{
        //					if(equip.getItem() == Recipes.Saws[cnt])
        //					{
        //						isAxeorSaw = true;
        //					}
        //				}
        for (int cnt = 0; cnt < Recipes.Hammers.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Hammers[cnt]) {
            isHammer = true;
          }
        }
      }
      if (isAxeorSaw) {
        damage = -1;
        ProcessTree(world, i, j, k, l, equip);

        if (damage + equip.getItemDamage() > equip.getMaxDamage()) {
          int ind = entityplayer.inventory.currentItem;
          entityplayer.inventory.setInventorySlotContents(ind, null);
          world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
        } else {
          equip.damageItem(damage, entityplayer);
        }
      } else if (isHammer) {
        EntityItem item =
            new EntityItem(
                world,
                i + 0.5,
                j + 0.5,
                k + 0.5,
                new ItemStack(Item.stick, 1 + world.rand.nextInt(3)));
        world.spawnEntityInWorld(item);
      } else {
        world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
      }
    }
  }
Esempio n. 7
0
  /**
   * Returns a boolean array indicating which flow directions are optimal based on each direction's
   * calculated flow cost. Each array index corresponds to one of the four cardinal directions. A
   * value of true indicates the direction is optimal.
   */
  private boolean[] getOptimalFlowDirections(World par1World, int par2, int par3, int par4) {
    int var5;
    int var6;

    for (var5 = 0; var5 < 4; ++var5) {
      this.flowCost[var5] = 1000;
      var6 = par2;
      int var8 = par4;

      if (var5 == 0) {
        var6 = par2 - 1;
      }

      if (var5 == 1) {
        ++var6;
      }

      if (var5 == 2) {
        var8 = par4 - 1;
      }

      if (var5 == 3) {
        ++var8;
      }

      if (!this.blockBlocksFlow(par1World, var6, par3, var8)
          && (par1World.getBlockId(var6, par3, var8) != this.blockID
              || par1World.getBlockMetadata(var6, par3, var8) != 0)) {
        if (!this.blockBlocksFlow(par1World, var6, par3 - 1, var8)) {
          this.flowCost[var5] = 0;
        } else {
          this.flowCost[var5] = this.calculateFlowCost(par1World, var6, par3, var8, 1, var5);
        }
      }
    }

    var5 = this.flowCost[0];

    for (var6 = 1; var6 < 4; ++var6) {
      if (this.flowCost[var6] < var5) {
        var5 = this.flowCost[var6];
      }
    }

    for (var6 = 0; var6 < 4; ++var6) {
      this.isOptimalFlowDirection[var6] = this.flowCost[var6] == var5;
    }

    return this.isOptimalFlowDirection;
  }
 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));
 }
Esempio n. 9
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);

    //        if (par1World.getBlockId(par2, par3, par4) == this.blockID)
    //        {
    par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
    //        }
  }
Esempio n. 10
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);
   }
 }
 @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 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));
   }
 }
  private void ProcessTree(World world, int i, int j, int k, int l, ItemStack stack) {
    int x = i;
    int y = 0;
    int z = k;
    boolean checkArray[][][] = new boolean[11][50][11];

    boolean reachedTop = false;
    while (!reachedTop) {
      if (l != 9 && l != 15 && world.getBlockId(x, j + y + 1, z) == 0) {
        reachedTop = true;
      } else if ((l == 9 || l == 15)
          && world.getBlockId(x, j + y + 1, z) == 0
          && world.getBlockId(x + 1, j + y + 1, z) != blockID
          && world.getBlockId(x - 1, j + y + 1, z) != blockID
          && world.getBlockId(x, j + y + 1, z + 1) != blockID
          && world.getBlockId(x, j + y + 1, z - 1) != blockID
          && world.getBlockId(x - 1, j + y + 1, z - 1) != blockID
          && world.getBlockId(x - 1, j + y + 1, z + 1) != blockID
          && world.getBlockId(x + 1, j + y + 1, z + 1) != blockID
          && world.getBlockId(x + 1, j + y + 1, z - 1) != blockID) {
        reachedTop = true;
      }

      scanLogs(world, i, j + y, k, l, checkArray, 6, y, 6, stack);

      y++;
    }
  }
Esempio n. 14
0
  private void scanLogs(
      World world, int i, int j, int k, int l, boolean[][][] checkArray, int x, int y, int z) {
    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 = -1; offsetX <= 1; offsetX++) {
          for (offsetZ = -1; offsetZ <= 1; 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);
              }
            }
          }
        }
      }

      world.setBlockWithNotify(i, j, k, 0);
      world.markBlockForUpdate(i, j, k);
    }
  }
Esempio n. 15
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World world, int x, int y, int z, Random random) {
    // Initialize variables
    int volume = 0;
    int remainder = 0;
    int direction = 0;
    boolean[] optimal = new boolean[4];

    int meta = world.getBlockMetadata(x, y, z);

    // Try to move down
    if (moveToBlock(world, x, y, z, x, y - 1, z)) {
      return;
    }

    // Get optimal flow direction
    optimal = getOptimalFlowDirections(world, x, y, z);

    // Move
    if (optimal[0]) {
      if (!moveToBlock(world, x, y, z, x - 1, y, z))
        if (!moveToBlock(world, x, y, z, x, y, z + 1))
          if (!moveToBlock(world, x, y, z, x, y, z - 1))
            if (!moveToBlock(world, x, y, z, x + 1, y, z)) ;
    } else if (optimal[1]) {
      if (!moveToBlock(world, x, y, z, x + 1, y, z))
        if (!moveToBlock(world, x, y, z, x, y, z + 1))
          if (!moveToBlock(world, x, y, z, x, y, z - 1))
            if (!moveToBlock(world, x, y, z, x - 1, y, z)) ;
    } else if (optimal[2]) {
      if (!moveToBlock(world, x, y, z, x, y, z - 1))
        if (!moveToBlock(world, x, y, z, x - 1, y, z))
          if (!moveToBlock(world, x, y, z, x + 1, y, z))
            if (!moveToBlock(world, x, y, z, x, y, z + 1)) ;
    } else if (optimal[3]) {
      if (!moveToBlock(world, x, y, z, x, y, z + 1))
        if (!moveToBlock(world, x, y, z, x - 1, y, z))
          if (!moveToBlock(world, x, y, z, x + 1, y, z))
            if (!moveToBlock(world, x, y, z, x, y, z - 1)) ;
    }

    //		if (meta == world.getBlockMetadata(x, y, z) && meta > 5)
    //		{
    //		    if(random.nextInt(100) < 10)
    //		    {
    //		        if(meta > 1)
    //		            world.setBlockMetadata(x, y, z, meta-1);
    //		        else
    //		            world.setBlock(x, y, z, 0);
    //		    }
    //		}
  }
 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 void updateTileEntityOrientation(World world, int i, int j, int k) {
    TileEntityPortalController controller =
        (TileEntityPortalController) world.getTileEntity(i, j, k);
    int metadata = world.getBlockMetadata(i, j, k);

    if (metadata == 1) {
      controller.pitch = -90;
      controller.yaw = -90;
      /*}else if(metadata == 1){
      controller.pitch = 90;
      controller.yaw = -90;*/
    } else if (metadata == 2) {
      controller.yaw = 270;
    } else if (metadata == 3) {
      controller.yaw = 90;
    } else if (metadata == 4) {
      controller.yaw = 0;
    } else if (metadata == 5) {
      controller.yaw = 180;
    }

    controller.markDirty();
  }
 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);
   }
 }
 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);
   }
 }
Esempio n. 20
0
  @Override
  public AxisAlignedBB getSelectedBoundingBoxFromPool(World world, int i, int j, int k) {
    int dir = world.getBlockMetadata(i, j, k);

    if (dir == 0) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.85F, i + 1F, j + 1F, k + 1F);
    } else if (dir == 1) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.0F, i + 0.15F, j + 1F, k + 1F);
    } else if (dir == 2) {
      return AxisAlignedBB.getBoundingBox(i + 0.0F, j + 0F, k + 0.00F, i + 1F, j + 1F, k + 0.15F);
    } else if (dir == 3) {
      return AxisAlignedBB.getBoundingBox(i + 0.85F, j + 0F, k + 0.0F, i + 1F, j + 1F, k + 1F);
    }

    return AxisAlignedBB.getBoundingBox(i, j, k, i + 1, j + 1, k + 1);
  }
Esempio n. 21
0
  /**
   * calculateFlowCost(World world, int x, int y, int z, int accumulatedCost, int
   * previousDirectionOfFlow) - Used to determine the path of least resistance, this method returns
   * the lowest possible flow cost for the direction of flow indicated. Each necessary horizontal
   * flow adds to the flow cost.
   */
  private int calculateFlowCost(World par1World, int par2, int par3, int par4, int par5, int par6) {
    int var7 = 1000;

    for (int var8 = 0; var8 < 4; ++var8) {
      if ((var8 != 0 || par6 != 1)
          && (var8 != 1 || par6 != 0)
          && (var8 != 2 || par6 != 3)
          && (var8 != 3 || par6 != 2)) {
        int var9 = par2;
        int var11 = par4;

        if (var8 == 0) {
          var9 = par2 - 1;
        }

        if (var8 == 1) {
          ++var9;
        }

        if (var8 == 2) {
          var11 = par4 - 1;
        }

        if (var8 == 3) {
          ++var11;
        }

        if (!this.blockBlocksFlow(par1World, var9, par3, var11)
            && ((par1World.getBlockMaterial(var9, par3, var11) != this.blockMaterial /*||
                		par1World.getBlockId(var9, par3, var11) == this.blockID) || par1World.getBlockMetadata(var9, par3, var11) != 0*/))) {
          if (!this.blockBlocksFlow(par1World, var9, par3 - 1, var11)) {
            return par5;
          }

          if (par5 < 4) {
            int var12 = this.calculateFlowCost(par1World, var9, par3, var11, par5 + 1, var8);

            if (var12 < var7) {
              var7 = var12;
            }
          }
        }
      }
    }

    return var7;
  }
Esempio n. 22
0
  /** Returns true if block at coords blocks fluids */
  private boolean blockBlocksFlow(World par1World, int par2, int par3, int par4) {
    int var5 = par1World.getBlockId(par2, par3, par4);

    if (var5 != Block.doorWood.blockID
        && var5 != Block.doorSteel.blockID
        && var5 != Block.signPost.blockID
        && var5 != Block.ladder.blockID
        && var5 != Block.reed.blockID) {
      if (var5 == 0) {
        return false;
      } else {
        Material var6 = Block.blocksList[var5].blockMaterial;
        return var6 == Material.portal ? true : var6.blocksMovement();
      }
    } else {
      return true;
    }
  }
 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 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);
       }
     }
   }
 }
  @Override
  public AxisAlignedBB getSelectedBoundingBoxFromPool(
      World par1World, int par2, int par3, int par4) {
    int i = par1World.getBlockMetadata(par2, par3, par4);
    float f = 0.375F;

    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    if (i == 0) {
      setBlockBounds(0.0F, 1.0F - f, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 1) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, f, 1.0F);
    }

    if (i == 2) {
      setBlockBounds(0.0F, 0.0F, 1.0F - f, 1.0F, 1.0F, 1.0F);
    }

    if (i == 3) {
      setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, f);
    }

    if (i == 4) {
      setBlockBounds(1.0F - f, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }

    if (i == 5) {
      setBlockBounds(0.0F, 0.0F, 0.0F, f, 1.0F, 1.0F);
    }
    AxisAlignedBB box =
        AxisAlignedBB.getAABBPool()
            .getAABB(
                par2 + this.minX,
                par3 + this.minY,
                par4 + this.minZ,
                par2 + this.maxX,
                par3 + this.maxY,
                par4 + this.maxZ);
    setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.375F);
    return box;
  }
Esempio n. 26
0
  public void SurroundWithLeaves(World world, int i, int j, int k) {
    for (int y = 0; y <= 1; y++) {
      for (int x = 1; x >= -1; x--) {
        for (int z = 1; z >= -1; z--) {
          if (world.getBlockId(i + x, j + y, k + z) == 0
              && (world.getBlockId(i + x, j + y + 1, k + z) == 0
                  || world.getBlockId(i + x, j + y + 2, k + z) == 0)) {
            int meta = world.getBlockMetadata(i, j, k);
            int id =
                meta < 8 ? TFCBlocks.fruitTreeLeaves.blockID : TFCBlocks.fruitTreeLeaves2.blockID;

            if (world.getBlockId(i, j, k) != TFCBlocks.fruitTreeWood.blockID) id = 0;

            world.setBlockAndMetadata(i + x, j + y, k + z, id, world.getBlockMetadata(i, j, k));
          }
        }
      }
    }
  }
  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);
    }
  }
 @Override
 public boolean canPlaceBlockOnSide(World world, int x, int y, int z, int side) {
   if ((side == 0) && (world.getBlock(x, y + 1, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 1) && (world.getBlock(x, y - 1, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 2) && (world.getBlock(x, y, z + 1) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 3) && (world.getBlock(x, y, z - 1) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 4) && (world.getBlock(x + 1, y, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else if ((side == 5) && (world.getBlock(x - 1, y, z) != NailedBlocks.portalCrystal)) {
     return false;
   } else {
     return this.canPlaceBlockAt(world, x, y, z);
   }
 }
  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);
    }
  }
 public static void fire(World world, int i, int j, int k) {
   ChunkCoordinates coord = getBase(i, j, k, world.getBlockMetadata(i, j, k));
   onpulse(world, coord.posX, coord.posY, coord.posZ);
   pathto(world, i, j, k);
 }