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));
     }
   }
 }
Пример #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;
  }
Пример #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);
 }
Пример #4
0
 @Override
 public void onNeighborBlockChange(
     World world, BlockPos pos, IBlockState state, Block neighborBlock) {
   if (world.isAirBlock(pos.up())) {
     this.dropBlockAsItem(world, pos, state, 0);
     world.setBlockToAir(pos);
   }
 }
Пример #5
0
 @Override
 public void onNeighborBlockChange(
     World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) {
   if (worldIn.isBlockPowered(pos)) {
     this.onBlockDestroyedByPlayer(
         worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
     worldIn.setBlockToAir(pos);
   }
 }
Пример #6
0
  @Override
  public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) {
    super.onBlockAdded(worldIn, pos, state);

    if (worldIn.isBlockPowered(pos)) {
      this.onBlockDestroyedByPlayer(
          worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)));
      worldIn.setBlockToAir(pos);
    }
  }
Пример #7
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);
      }
    }
  }
Пример #10
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;
  }
Пример #11
0
 public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
   if (!worldIn.isRemote) {
     if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
       // float power = 2F + (((5000) / 10369F) * 18F);
       // ProcessHandler.addProcess(new NuclearExplosion(worldIn, pos.getX(), pos.getY(),
       // pos.getZ(), power));
       EntityNukePrimed entitytntprimed =
           new EntityNukePrimed(
               worldIn, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
       worldIn.spawnEntityInWorld(entitytntprimed);
       worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
     }
   }
 }
Пример #12
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));
 }
Пример #13
0
  @Override
  public boolean onBlockActivated(
      World worldIn,
      BlockPos pos,
      IBlockState state,
      EntityPlayer playerIn,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (playerIn.getCurrentEquippedItem() != null) {
      Item item = playerIn.getCurrentEquippedItem().getItem();

      if (item == Items.flint_and_steel || item == Items.fire_charge) {
        this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn);
        worldIn.setBlockToAir(pos);

        if (item == Items.flint_and_steel) {
          playerIn.getCurrentEquippedItem().damageItem(1, playerIn);
        } else if (!playerIn.capabilities.isCreativeMode) {
          --playerIn.getCurrentEquippedItem().stackSize;
        }

        return true;
      }
    }

    return super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ);
  }
Пример #14
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());
    //        }
  }
Пример #15
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);
   }
 }
Пример #16
0
  @Override
  public void onEntityCollidedWithBlock(
      World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
    if (!worldIn.isRemote && entityIn instanceof EntityArrow) {
      EntityArrow entityarrow = (EntityArrow) entityIn;

      if (entityarrow.isBurning()) {
        this.explode(
            worldIn,
            pos,
            worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)),
            entityarrow.shootingEntity instanceof EntityLivingBase
                ? (EntityLivingBase) entityarrow.shootingEntity
                : null);
        worldIn.setBlockToAir(pos);
      }
    }
  }
Пример #17
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));
   }
 }
Пример #18
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));
   }
 }
Пример #19
0
  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++;
    }
  }
Пример #20
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);
    }
  }
Пример #21
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);
    //		    }
    //		}
  }
Пример #22
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));
     }
   }
 }
Пример #23
0
  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();
  }
Пример #24
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);
   }
 }
Пример #25
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);
   }
 }
Пример #26
0
 @Override
 public void onBlockDestroyedByExplosion(World worldIn, BlockPos pos, Explosion explosionIn) {
   if (!worldIn.isRemote) {
     EntityNukePrimed entitytntprimed =
         new EntityNukePrimed(
             worldIn,
             pos.getX() + 0.5F,
             pos.getY() + 0.5F,
             pos.getZ() + 0.5F,
             explosionIn.getExplosivePlacedBy());
     entitytntprimed.fuse =
         worldIn.rand.nextInt(entitytntprimed.fuse / 4) + entitytntprimed.fuse / 8;
     worldIn.spawnEntityInWorld(entitytntprimed);
   }
 }
Пример #27
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);
  }
Пример #28
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;
  }
Пример #29
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);
     }
   }
 }
Пример #30
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;
    }
  }