예제 #1
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  @Override
  public void onBlockAdded(final World par1World, final int par2, final int par3, final 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());
    }
  }
예제 #2
0
 @Override
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (world.getBlockMetadata(i, j, k) < 2) {
     if (random.nextInt(5) == 2) {
       world.setBlockWithNotify(i, j, k, 0);
     } else {
       world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
     }
   }
 }
예제 #3
0
  /** Ticks the block if it's been scheduled */
  @Override
  public void updateTick(
      final World par1World,
      final int par2,
      final int par3,
      final int par4,
      final Random par5Random) {
    int var6 = this.getFlowDecay(par1World, par2, par3, par4);
    byte var7 = 1;

    if ((this.blockMaterial == Material.lava) && !par1World.provider.isHellWorld) {
      var7 = 2;
    }

    boolean var8 = true;
    int var10;

    if (var6 > 0) {
      final byte var9 = -100;
      this.numAdjacentSources = 0;
      int var12 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var9);
      var12 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var12);
      var12 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var12);
      var10 = var12 + var7;

      if ((var10 >= 8) || (var12 < 0)) {
        var10 = -1;
      }

      if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) {
        final int var11 = this.getFlowDecay(par1World, par2, par3 + 1, par4);

        if (var11 >= 8) {
          var10 = var11;
        } else {
          var10 = var11 + 8;
        }
      }

      if ((this.numAdjacentSources >= 2) && (this.blockMaterial == Material.water)) {
        if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) {
          var10 = 0;
        } else if ((par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial)
            && (par1World.getBlockMetadata(par2, par3, par4) == 0)) {
          var10 = 0;
        }
      }

      if ((this.blockMaterial == Material.lava)
          && (var6 < 8)
          && (var10 < 8)
          && (var10 > var6)
          && (par5Random.nextInt(4) != 0)) {
        var10 = var6;
        var8 = false;
      }

      if (var10 == var6) {
        if (var8) {
          this.updateFlow(par1World, par2, par3, par4);
        }
      } else {
        var6 = var10;

        if (var10 < 0) {
          par1World.setBlockWithNotify(par2, par3, par4, 0);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
          par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
        }
      }
    } else {
      this.updateFlow(par1World, par2, par3, par4);
    }

    if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) {
      if ((this.blockMaterial == Material.lava)
          && (par1World.getBlockMaterial(par2, par3 - 1, par4) == Material.water)) {
        par1World.setBlockWithNotify(par2, par3 - 1, par4, Block.stone.blockID);
        this.triggerLavaMixEffects(par1World, par2, par3 - 1, par4);
        return;
      }

      if (var6 >= 8) {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6);
      } else {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6 + 8);
      }
    } else if ((var6 >= 0)
        && ((var6 == 0) || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) {
      final boolean[] var13 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var10 = var6 + var7;

      if (var6 >= 8) {
        var10 = 1;
      }

      if (var10 >= 8) {
        return;
      }

      if (var13[0]) {
        this.flowIntoBlock(par1World, par2 - 1, par3, par4, var10);
      }

      if (var13[1]) {
        this.flowIntoBlock(par1World, par2 + 1, par3, par4, var10);
      }

      if (var13[2]) {
        this.flowIntoBlock(par1World, par2, par3, par4 - 1, var10);
      }

      if (var13[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var10);
      }
    }
  }
예제 #4
0
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
 }
예제 #5
0
 public void onBlockAdded(World world, int i, int j, int k) {
   world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
 }
예제 #6
0
 @Override
 public void onBlockAdded(World world, int i, int j, int k) {
   if (world.getBlockMetadata(i, j, k) < 2) {
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
   }
 }
예제 #7
0
 @Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (!mod_NWater.chunkPass(world, i, j, k)) {
     return;
   }
   if (world.getBlockMetadata(i, j, k) < 2) {
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
   }
   if (world.multiplayerWorld) {
     return;
   }
   if (BlockNWater_Ocean.noOcean) {
     return;
   }
   checkForHarden(world, i, j, k);
   int i1 = world.getBlockMetadata(i, j, k);
   boolean flag = false;
   if ((world.getBlockId(i, j - 1, k) == mod_NWater.nwater_ocean.blockID)
       & (world.getBlockMetadata(i, j - 1, k) < 2 || world.getBlockMetadata(i, j - 1, k) > 3)) {
     flag = true;
   }
   if (mod_NWater.canMoveAmt(world, i, j - 1, k, i1)) {
     flag = true;
   }
   if (checkSponge(world, i - 1, j, k)) {
     flag = true;
   }
   if (checkSponge(world, i + 1, j, k)) {
     flag = true;
   }
   if (checkSponge(world, i, j - 1, k)) {
     flag = true;
   }
   if (checkSponge(world, i, j, k - 1)) {
     flag = true;
   }
   if (checkSponge(world, i, j, k + 1)) {
     flag = true;
   }
   if ((!flag) & isWater(world, i, j - 1, k)) {
     int j1 = world.getBlockMetadata(i, j - 1, k);
     if (j1 < 15) {
       if (j1 + (1 + i1) < 16) {
         flag = true;
       } else {
         flag = true;
       }
     }
   }
   if (!flag) {
     int k1 = 1;
     int i2 = 1;
     for (int k2 = -1; k2 <= 1; k2++) {
       for (int i3 = -1; i3 <= 1; i3++) {
         int k3 = k2 * k1;
         int i4 = i3 * i2;
         if (!((!flag) & (k2 != 0 || i3 != 0) & (k2 == 0 || i3 == 0))) {
           continue;
         }
         world.getBlockId(i + k3, j, k + i4);
         world.getBlockMetadata(i + k3, j, k + i4);
         boolean flag1 = mod_NWater.canMoveAmt(world, i + k3, j, k + i4, i1);
         if (!((!flag) & flag1)) {
           continue;
         }
         world.getBlockId(i + k3, j - 1, k + i4);
         world.getBlockMetadata(i + k3, j - 1, k + i4);
         flag1 = mod_NWater.canMoveAmt(world, i + k3, j - 1, k + i4, i1);
         if ((!flag) & flag1) {
           flag = true;
         }
         if (!((!flag) & isWater(world, i + k3, j - 1, k + i4))) {
           continue;
         }
         int k5 = world.getBlockMetadata(i + k3, j - 1, k + i4);
         if (k5 >= 15) {
           continue;
         }
         if (k5 + (1 + i1) < 16) {
           flag = true;
         } else {
           flag = true;
         }
       }
     }
   }
   if ((!flag) & (i1 > 0)) {
     int l1 = 1;
     int j2 = 1;
     for (int l2 = -1; l2 <= 1; l2++) {
       for (int j3 = -1; j3 <= 1; j3++) {
         int l3 = l2 * l1;
         int j4 = j3 * j2;
         if (!((!flag) & (l2 != 0 || j3 != 0) & (l2 == 0 || j3 == 0))) {
           continue;
         }
         world.getBlockId(i + l3, j, k + j4);
         int j5 = world.getBlockMetadata(i + l3, j, k + j4);
         boolean flag2 = mod_NWater.canMoveAmt(world, i + l3, j, k + j4, i1);
         if ((!flag) & flag2) {
           flag = true;
         }
         if (!((!flag) & isWater(world, i + l3, j, k + j4))) {
           continue;
         }
         if (j5 + 1 < i1) {
           flag = true;
         }
         float f = getSurfaceMull();
         if (!((!flag)
             & (Math.pow(mod_NWater.getMetaAvg2(world, i + l3, j, k + j4), f)
                 < mod_NWater.getMetaAvg2(world, i, j, k)))) {
           continue;
         }
         int l5 = i1;
         int j6 = (i1 + j5) / 2;
         if (l5 != j6) {
           flag = true;
         }
       }
     }
   }
   if (flag) {
     world.setBlockAndMetadata(i, j, k, getMoving(), i1);
   }
 }