Ejemplo 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 onBlockRemoval(World world, int i, int j, int k) {
   super.onBlockRemoval(world, i, j, k);
   if (world.multiplayerWorld) {
     return;
   }
   world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
   world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
   updateAndPropagateCurrentStrength(world, i, j, k);
   notifyWireNeighborsOfNeighborChange(world, i - 1, j, k);
   notifyWireNeighborsOfNeighborChange(world, i + 1, j, k);
   notifyWireNeighborsOfNeighborChange(world, i, j, k - 1);
   notifyWireNeighborsOfNeighborChange(world, i, j, k + 1);
   if (world.isBlockOpaqueCube(i - 1, j, k)) {
     notifyWireNeighborsOfNeighborChange(world, i - 1, j + 1, k);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i - 1, j - 1, k);
   }
   if (world.isBlockOpaqueCube(i + 1, j, k)) {
     notifyWireNeighborsOfNeighborChange(world, i + 1, j + 1, k);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i + 1, j - 1, k);
   }
   if (world.isBlockOpaqueCube(i, j, k - 1)) {
     notifyWireNeighborsOfNeighborChange(world, i, j + 1, k - 1);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i, j - 1, k - 1);
   }
   if (world.isBlockOpaqueCube(i, j, k + 1)) {
     notifyWireNeighborsOfNeighborChange(world, i, j + 1, k + 1);
   } else {
     notifyWireNeighborsOfNeighborChange(world, i, j - 1, k + 1);
   }
 }
Ejemplo 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);
 }
Ejemplo n.º 4
0
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (!world.isBlockOpaqueCube(i, j - 1, k) && !func_263_h(world, i, j, k)) {
     world.setBlockWithNotify(i, j, k, 0);
     return;
   } else {
     return;
   }
 }
Ejemplo n.º 5
0
 private void func_319_i(World world, int i, int j, int k) {
   Random random = world.rand;
   double d = 0.0625D;
   for (int l = 0; l < 6; l++) {
     double d1 = (float) i + random.nextFloat();
     double d2 = (float) j + random.nextFloat();
     double d3 = (float) k + random.nextFloat();
     if (l == 0 && !world.isBlockOpaqueCube(i, j + 1, k)) {
       d2 = (double) (j + 1) + d;
     }
     if (l == 1 && !world.isBlockOpaqueCube(i, j - 1, k)) {
       d2 = (double) (j + 0) - d;
     }
     if (l == 2 && !world.isBlockOpaqueCube(i, j, k + 1)) {
       d3 = (double) (k + 1) + d;
     }
     if (l == 3 && !world.isBlockOpaqueCube(i, j, k - 1)) {
       d3 = (double) (k + 0) - d;
     }
     if (l == 4 && !world.isBlockOpaqueCube(i + 1, j, k)) {
       d1 = (double) (i + 1) + d;
     }
     if (l == 5 && !world.isBlockOpaqueCube(i - 1, j, k)) {
       d1 = (double) (i + 0) - d;
     }
     if (d1 < (double) i
         || d1 > (double) (i + 1)
         || d2 < 0.0D
         || d2 > (double) (j + 1)
         || d3 < (double) k
         || d3 > (double) (k + 1)) {
       world.spawnParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D);
     }
   }
 }
Ejemplo n.º 6
0
 public void onBlockAdded(World world, int i, int j, int k) {
   if (world.getBlockId(i, j - 1, k) == Block.obsidian.blockID
       && Block.portal.tryToCreatePortal(world, i, j, k)) {
     return;
   }
   if (!world.isBlockOpaqueCube(i, j - 1, k) && !func_263_h(world, i, j, k)) {
     world.setBlockWithNotify(i, j, k, 0);
     return;
   } else {
     world.func_22136_c(i, j, k, blockID, tickRate());
     return;
   }
 }
Ejemplo n.º 7
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);
       }
     }
   }
 }
Ejemplo n.º 8
0
 public void updateTick(World world, int i, int j, int k, Random random) {
   boolean flag = world.getBlockId(i, j - 1, k) == Block.bloodStone.blockID;
   int l = world.getBlockMetadata(i, j, k);
   if (l < 15) {
     world.setBlockMetadataWithNotify(i, j, k, l + 1);
     world.func_22136_c(i, j, k, blockID, tickRate());
   }
   if (!flag && !func_263_h(world, i, j, k)) {
     if (!world.isBlockOpaqueCube(i, j - 1, k) || l > 3) {
       world.setBlockWithNotify(i, j, k, 0);
     }
     return;
   }
   if (!flag && !canBlockCatchFire(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
     world.setBlockWithNotify(i, j, k, 0);
     return;
   }
   if (l % 2 == 0 && l > 2) {
     tryToCatchBlockOnFire(world, i + 1, j, k, 300, random);
     tryToCatchBlockOnFire(world, i - 1, j, k, 300, random);
     tryToCatchBlockOnFire(world, i, j - 1, k, 250, random);
     tryToCatchBlockOnFire(world, i, j + 1, k, 250, random);
     tryToCatchBlockOnFire(world, i, j, k - 1, 300, random);
     tryToCatchBlockOnFire(world, i, j, k + 1, 300, random);
     for (int i1 = i - 1; i1 <= i + 1; i1++) {
       for (int j1 = k - 1; j1 <= k + 1; j1++) {
         for (int k1 = j - 1; k1 <= j + 4; k1++) {
           if (i1 == i && k1 == j && j1 == k) {
             continue;
           }
           int l1 = 100;
           if (k1 > j + 1) {
             l1 += (k1 - (j + 1)) * 100;
           }
           int i2 = getChanceOfNeighborsEncouragingFire(world, i1, k1, j1);
           if (i2 > 0 && random.nextInt(l1) <= i2) {
             world.setBlockWithNotify(i1, k1, j1, blockID);
           }
         }
       }
     }
   }
 }
Ejemplo n.º 9
0
  public void randomDisplayTick(World world, int i, int j, int k, Random random) {
    if (random.nextInt(24) == 0) {
      world.playSoundEffect(
          (float) i + 0.5F,
          (float) j + 0.5F,
          (float) k + 0.5F,
          "fire.fire",
          1.0F + random.nextFloat(),
          random.nextFloat() * 0.7F + 0.3F);
    }
    if (world.isBlockOpaqueCube(i, j - 1, k) || Block.fire.canBlockCatchFire(world, i, j - 1, k)) {
      for (int l = 0; l < 3; l++) {
        float f = (float) i + random.nextFloat();
        float f6 = (float) j + random.nextFloat() * 0.5F + 0.5F;
        float f12 = (float) k + random.nextFloat();
        world.spawnParticle("largesmoke", f, f6, f12, 0.0D, 0.0D, 0.0D);
      }

    } else {
      if (Block.fire.canBlockCatchFire(world, i - 1, j, k)) {
        for (int i1 = 0; i1 < 2; i1++) {
          float f1 = (float) i + random.nextFloat() * 0.1F;
          float f7 = (float) j + random.nextFloat();
          float f13 = (float) k + random.nextFloat();
          world.spawnParticle("largesmoke", f1, f7, f13, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i + 1, j, k)) {
        for (int j1 = 0; j1 < 2; j1++) {
          float f2 = (float) (i + 1) - random.nextFloat() * 0.1F;
          float f8 = (float) j + random.nextFloat();
          float f14 = (float) k + random.nextFloat();
          world.spawnParticle("largesmoke", f2, f8, f14, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i, j, k - 1)) {
        for (int k1 = 0; k1 < 2; k1++) {
          float f3 = (float) i + random.nextFloat();
          float f9 = (float) j + random.nextFloat();
          float f15 = (float) k + random.nextFloat() * 0.1F;
          world.spawnParticle("largesmoke", f3, f9, f15, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i, j, k + 1)) {
        for (int l1 = 0; l1 < 2; l1++) {
          float f4 = (float) i + random.nextFloat();
          float f10 = (float) j + random.nextFloat();
          float f16 = (float) (k + 1) - random.nextFloat() * 0.1F;
          world.spawnParticle("largesmoke", f4, f10, f16, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i, j + 1, k)) {
        for (int i2 = 0; i2 < 2; i2++) {
          float f5 = (float) i + random.nextFloat();
          float f11 = (float) (j + 1) - random.nextFloat() * 0.1F;
          float f17 = (float) k + random.nextFloat();
          world.spawnParticle("largesmoke", f5, f11, f17, 0.0D, 0.0D, 0.0D);
        }
      }
    }
  }
Ejemplo n.º 10
0
 public boolean canPlaceBlockAt(World world, int i, int j, int k) {
   return world.isBlockOpaqueCube(i, j - 1, k) || func_263_h(world, i, j, k);
 }
Ejemplo n.º 11
0
  /** A randomly called display update to be able to add particles or other items for display */
  public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    int var6;

    if (this.blockMaterial == Material.water) {
      if (par5Random.nextInt(10) == 0) {
        var6 = par1World.getBlockMetadata(par2, par3, par4);

        if (var6 <= 0 || var6 >= 8) {
          par1World.spawnParticle(
              "suspended",
              (double) ((float) par2 + par5Random.nextFloat()),
              (double) ((float) par3 + par5Random.nextFloat()),
              (double) ((float) par4 + par5Random.nextFloat()),
              0.0D,
              0.0D,
              0.0D);
        }
      }

      for (var6 = 0; var6 < 0; ++var6) {
        int var7 = par5Random.nextInt(4);
        int var8 = par2;
        int var9 = par4;

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

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

        if (var7 == 2) {
          var9 = par4 - 1;
        }

        if (var7 == 3) {
          ++var9;
        }

        if (par1World.getBlockMaterial(var8, par3, var9) == Material.air
            && (par1World.getBlockMaterial(var8, par3 - 1, var9).blocksMovement()
                || par1World.getBlockMaterial(var8, par3 - 1, var9).isLiquid())) {
          float var10 = 0.0625F;
          double var11 = (double) ((float) par2 + par5Random.nextFloat());
          double var13 = (double) ((float) par3 + par5Random.nextFloat());
          double var15 = (double) ((float) par4 + par5Random.nextFloat());

          if (var7 == 0) {
            var11 = (double) ((float) par2 - var10);
          }

          if (var7 == 1) {
            var11 = (double) ((float) (par2 + 1) + var10);
          }

          if (var7 == 2) {
            var15 = (double) ((float) par4 - var10);
          }

          if (var7 == 3) {
            var15 = (double) ((float) (par4 + 1) + var10);
          }

          double var17 = 0.0D;
          double var19 = 0.0D;

          if (var7 == 0) {
            var17 = (double) (-var10);
          }

          if (var7 == 1) {
            var17 = (double) var10;
          }

          if (var7 == 2) {
            var19 = (double) (-var10);
          }

          if (var7 == 3) {
            var19 = (double) var10;
          }

          par1World.spawnParticle("splash", var11, var13, var15, var17, 0.0D, var19);
        }
      }
    }

    if (this.blockMaterial == Material.water && par5Random.nextInt(64) == 0) {
      var6 = par1World.getBlockMetadata(par2, par3, par4);

      if (var6 > 0 && var6 < 8) {
        par1World.playSound(
            (double) ((float) par2 + 0.5F),
            (double) ((float) par3 + 0.5F),
            (double) ((float) par4 + 0.5F),
            "liquid.water",
            par5Random.nextFloat() * 0.25F + 0.75F,
            par5Random.nextFloat() * 1.0F + 0.5F);
      }
    }

    double var21;
    double var23;
    double var22;

    if (this.blockMaterial == Material.lava
        && par1World.getBlockMaterial(par2, par3 + 1, par4) == Material.air
        && !par1World.isBlockOpaqueCube(par2, par3 + 1, par4)) {
      if (par5Random.nextInt(100) == 0) {
        var21 = (double) ((float) par2 + par5Random.nextFloat());
        var22 = (double) par3 + this.maxY;
        var23 = (double) ((float) par4 + par5Random.nextFloat());
        par1World.spawnParticle("lava", var21, var22, var23, 0.0D, 0.0D, 0.0D);
        par1World.playSound(
            var21,
            var22,
            var23,
            "liquid.lavapop",
            0.2F + par5Random.nextFloat() * 0.2F,
            0.9F + par5Random.nextFloat() * 0.15F);
      }

      if (par5Random.nextInt(200) == 0) {
        par1World.playSound(
            (double) par2,
            (double) par3,
            (double) par4,
            "liquid.lava",
            0.2F + par5Random.nextFloat() * 0.2F,
            0.9F + par5Random.nextFloat() * 0.15F);
      }
    }

    if (par5Random.nextInt(10) == 0
        && par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
        && !par1World.getBlockMaterial(par2, par3 - 2, par4).blocksMovement()) {
      var21 = (double) ((float) par2 + par5Random.nextFloat());
      var22 = (double) par3 - 1.05D;
      var23 = (double) ((float) par4 + par5Random.nextFloat());

      if (this.blockMaterial == Material.water) {
        par1World.spawnParticle("dripWater", var21, var22, var23, 0.0D, 0.0D, 0.0D);
      } else {
        par1World.spawnParticle("dripLava", var21, var22, var23, 0.0D, 0.0D, 0.0D);
      }
    }
  }
Ejemplo n.º 12
0
 public void updateTickOld(World world, int i, int j, int k, Random random) {
   boolean flag = world.getBlockId(i, j - 1, k) == Block.netherrack.blockID;
   if (!flag
       && world.isRaining()
       && (world.canLightningStrikeAt(i, j, k)
           || world.canLightningStrikeAt(i - 1, j, k)
           || world.canLightningStrikeAt(i + 1, j, k)
           || world.canLightningStrikeAt(i, j, k - 1)
           || world.canLightningStrikeAt(i, j, k + 1))) {
     world.setBlockToAir(i, j, k);
     return;
   }
   int l = world.getBlockMetadata(i, j, k);
   if (l < 15) {
     world.setBlockMetadataWithNotify(i, j, k, l + 1, 3);
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate(world));
   }
   if (!flag && !canNeighborBurn(world, i, j, k)) {
     if (!world.isBlockOpaqueCube(i, j - 1, k) || l > 3) {
       world.setBlockToAir(i, j, k);
     }
     return;
   }
   if (!flag && !canBlockCatchFire(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
     world.setBlockToAir(i, j, k);
     return;
   }
   if (l % 2 == 0 && l > 2) {
     tryToCatchBlockOnFire_old(world, i + 1, j, k, 300, random);
     tryToCatchBlockOnFire_old(world, i - 1, j, k, 300, random);
     tryToCatchBlockOnFire_old(world, i, j - 1, k, 250, random);
     tryToCatchBlockOnFire_old(world, i, j + 1, k, 250, random);
     tryToCatchBlockOnFire_old(world, i, j, k - 1, 300, random);
     tryToCatchBlockOnFire_old(world, i, j, k + 1, 300, random);
     for (int i1 = i - 1; i1 <= i + 1; i1++) {
       for (int j1 = k - 1; j1 <= k + 1; j1++) {
         for (int k1 = j - 1; k1 <= j + 4; k1++) {
           if (i1 == i && k1 == j && j1 == k) {
             continue;
           }
           int l1 = 100;
           if (k1 > j + 1) {
             l1 += (k1 - (j + 1)) * 100;
           }
           int i2 = getChanceOfNeighborsEncouragingFire(world, i1, k1, j1);
           if (i2 > 0
               && random.nextInt(l1) <= i2
               && (!world.isRaining() || !world.canLightningStrikeAt(i1, k1, j1))
               && !world.canLightningStrikeAt(i1 - 1, k1, k)
               && !world.canLightningStrikeAt(i1 + 1, k1, j1)
               && !world.canLightningStrikeAt(i1, k1, j1 - 1)
               && !world.canLightningStrikeAt(i1, k1, j1 + 1)) {
             world.setBlock(i1, k1, j1, blockID);
           }
         }
       }
     }
   }
   if (l == 15 && !infiniteBurn) {
     tryToCatchBlockOnFire_old(world, i + 1, j, k, 1, random);
     tryToCatchBlockOnFire_old(world, i - 1, j, k, 1, random);
     tryToCatchBlockOnFire_old(world, i, j - 1, k, 1, random);
     tryToCatchBlockOnFire_old(world, i, j + 1, k, 1, random);
     tryToCatchBlockOnFire_old(world, i, j, k - 1, 1, random);
     tryToCatchBlockOnFire_old(world, i, j, k + 1, 1, random);
   }
 }
  private void func_21030_a(World world, int i, int j, int k, int l, int i1, int j1) {
    int k1 = world.getBlockMetadata(i, j, k);
    int l1 = 0;
    wiresProvidePower = false;
    boolean flag = world.isBlockIndirectlyGettingPowered(i, j, k);
    wiresProvidePower = true;
    if (flag) {
      l1 = 15;
    } else {
      for (int i2 = 0; i2 < 4; i2++) {
        int k2 = i;
        int i3 = k;
        if (i2 == 0) {
          k2--;
        }
        if (i2 == 1) {
          k2++;
        }
        if (i2 == 2) {
          i3--;
        }
        if (i2 == 3) {
          i3++;
        }
        if (k2 != l || j != i1 || i3 != j1) {
          l1 = getMaxCurrentStrength(world, k2, j, i3, l1);
        }
        if (world.isBlockOpaqueCube(k2, j, i3) && !world.isBlockOpaqueCube(i, j + 1, k)) {
          if (k2 != l || j + 1 != i1 || i3 != j1) {
            l1 = getMaxCurrentStrength(world, k2, j + 1, i3, l1);
          }
          continue;
        }
        if (!world.isBlockOpaqueCube(k2, j, i3) && (k2 != l || j - 1 != i1 || i3 != j1)) {
          l1 = getMaxCurrentStrength(world, k2, j - 1, i3, l1);
        }
      }

      if (l1 > 0) {
        l1--;
      } else {
        l1 = 0;
      }
    }
    if (k1 != l1) {
      world.field_1043_h = true;
      world.setBlockMetadataWithNotify(i, j, k, l1);
      world.markBlocksDirty(i, j, k, i, j, k);
      world.field_1043_h = false;
      for (int j2 = 0; j2 < 4; j2++) {
        int l2 = i;
        int j3 = k;
        int k3 = j - 1;
        if (j2 == 0) {
          l2--;
        }
        if (j2 == 1) {
          l2++;
        }
        if (j2 == 2) {
          j3--;
        }
        if (j2 == 3) {
          j3++;
        }
        if (world.isBlockOpaqueCube(l2, j, j3)) {
          k3 += 2;
        }
        int l3 = 0;
        l3 = getMaxCurrentStrength(world, l2, j, j3, -1);
        l1 = world.getBlockMetadata(i, j, k);
        if (l1 > 0) {
          l1--;
        }
        if (l3 >= 0 && l3 != l1) {
          func_21030_a(world, l2, j, j3, i, j, k);
        }
        l3 = getMaxCurrentStrength(world, l2, k3, j3, -1);
        l1 = world.getBlockMetadata(i, j, k);
        if (l1 > 0) {
          l1--;
        }
        if (l3 >= 0 && l3 != l1) {
          func_21030_a(world, l2, k3, j3, i, j, k);
        }
      }

      if (k1 == 0 || l1 == 0) {
        field_21031_b.add(new ChunkPosition(i, j, k));
        field_21031_b.add(new ChunkPosition(i - 1, j, k));
        field_21031_b.add(new ChunkPosition(i + 1, j, k));
        field_21031_b.add(new ChunkPosition(i, j - 1, k));
        field_21031_b.add(new ChunkPosition(i, j + 1, k));
        field_21031_b.add(new ChunkPosition(i, j, k - 1));
        field_21031_b.add(new ChunkPosition(i, j, k + 1));
      }
    }
  }