コード例 #1
0
ファイル: BlockFlowing.java プロジェクト: chums122/Spigot
 private Set<EnumDirection> f(World world, BlockPosition blockposition) {
   int i = 1000;
   EnumSet enumset = EnumSet.noneOf(EnumDirection.class);
   Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
   while (iterator.hasNext()) {
     EnumDirection enumdirection = (EnumDirection) iterator.next();
     BlockPosition blockposition1 = blockposition.shift(enumdirection);
     IBlockData iblockdata = world.getType(blockposition1);
     if ((!g(world, blockposition1, iblockdata))
         && ((iblockdata.getBlock().getMaterial() != this.material)
             || (((Integer) iblockdata.get(LEVEL)).intValue() > 0))) {
       int j;
       int j;
       if (g(world, blockposition1.down(), world.getType(blockposition1.down()))) {
         j = a(world, blockposition1, 1, enumdirection.opposite());
       } else {
         j = 0;
       }
       if (j < i) {
         enumset.clear();
       }
       if (j <= i) {
         enumset.add(enumdirection);
         i = j;
       }
     }
   }
   return enumset;
 }
コード例 #2
0
ファイル: BlockLever.java プロジェクト: chums122/Spigot
 public IBlockData getPlacedState(
     World world,
     BlockPosition blockposition,
     EnumDirection enumdirection,
     float f,
     float f1,
     float f2,
     int i,
     EntityLiving entityliving) {
   IBlockData iblockdata = getBlockData().set(POWERED, Boolean.valueOf(false));
   if (a(world, blockposition, enumdirection.opposite())) {
     return iblockdata.set(
         FACING, EnumLeverPosition.a(enumdirection, entityliving.getDirection()));
   }
   Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
   EnumDirection enumdirection1;
   do {
     if (!iterator.hasNext()) {
       if (World.a(world, blockposition.down())) {
         return iblockdata.set(
             FACING, EnumLeverPosition.a(EnumDirection.UP, entityliving.getDirection()));
       }
       return iblockdata;
     }
     enumdirection1 = (EnumDirection) iterator.next();
   } while ((enumdirection1 == enumdirection)
       || (!a(world, blockposition, enumdirection1.opposite())));
   return iblockdata.set(FACING, EnumLeverPosition.a(enumdirection1, entityliving.getDirection()));
 }
コード例 #3
0
  public boolean generate(World world, Random random, BlockPosition blockposition) {
    while (world.isEmpty(blockposition) && blockposition.getY() > 2) {
      blockposition = blockposition.down();
    }

    if (world.getType(blockposition).getBlock() != Blocks.SNOW) {
      return false;
    } else {
      int i = random.nextInt(this.b - 2) + 2;
      byte b0 = 1;

      for (int j = blockposition.getX() - i; j <= blockposition.getX() + i; ++j) {
        for (int k = blockposition.getZ() - i; k <= blockposition.getZ() + i; ++k) {
          int l = j - blockposition.getX();
          int i1 = k - blockposition.getZ();

          if (l * l + i1 * i1 <= i * i) {
            for (int j1 = blockposition.getY() - b0; j1 <= blockposition.getY() + b0; ++j1) {
              BlockPosition blockposition1 = new BlockPosition(j, j1, k);
              Block block = world.getType(blockposition1).getBlock();

              if (block == Blocks.DIRT || block == Blocks.SNOW || block == Blocks.ICE) {
                world.setTypeAndData(blockposition1, this.a.getBlockData(), 2);
              }
            }
          }
        }
      }

      return true;
    }
  }
コード例 #4
0
ファイル: BlockFlowing.java プロジェクト: chums122/Spigot
 private int a(World world, BlockPosition blockposition, int i, EnumDirection enumdirection) {
   int j = 1000;
   Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
   while (iterator.hasNext()) {
     EnumDirection enumdirection1 = (EnumDirection) iterator.next();
     if (enumdirection1 != enumdirection) {
       BlockPosition blockposition1 = blockposition.shift(enumdirection1);
       IBlockData iblockdata = world.getType(blockposition1);
       if ((!g(world, blockposition1, iblockdata))
           && ((iblockdata.getBlock().getMaterial() != this.material)
               || (((Integer) iblockdata.get(LEVEL)).intValue() > 0))) {
         if (!g(world, blockposition1.down(), iblockdata)) {
           return i;
         }
         if (i < 4) {
           int k = a(world, blockposition1, i + 1, enumdirection1.opposite());
           if (k < j) {
             j = k;
           }
         }
       }
     }
   }
   return j;
 }
コード例 #5
0
  private void a(boolean var1) {
    class_aqk var2 = new class_aqk(var1);

    BlockPosition var3;
    for (var3 = this.d.r(class_aqk.a).down();
        this.d.getType(var3).getBlock() == Blocks.BEDROCK && var3.getY() > this.d.G();
        var3 = var3.down()) {;
    }

    var2.generate(this.d, new Random(), var3);
  }
コード例 #6
0
  public boolean generate(World world, Random random, BlockPosition blockposition) {
    for (int i = 0; i < 64; ++i) {
      BlockPosition blockposition1 =
          blockposition.a(
              random.nextInt(8) - random.nextInt(8),
              random.nextInt(4) - random.nextInt(4),
              random.nextInt(8) - random.nextInt(8));

      if (world.isEmpty(blockposition1)
          && world.getType(blockposition1.down()).getBlock() == Blocks.NETHERRACK) {
        world.setTypeAndData(blockposition1, Blocks.FIRE.getBlockData(), 2);
      }
    }

    return true;
  }
コード例 #7
0
  public boolean generate(World var1, Random var2, BlockPosition var3) {
    if (this.a == null) {
      this.a = var2.nextBoolean() ? Blocks.BROWN_MUSHROOM_BLOCK : Blocks.RED_MUSHROOM_BLOCK;
    }

    int var4 = var2.nextInt(3) + 4;
    boolean var5 = true;
    if (var3.getY() >= 1 && var3.getY() + var4 + 1 < 256) {
      int var9;
      int var10;
      for (int var6 = var3.getY(); var6 <= var3.getY() + 1 + var4; ++var6) {
        byte var7 = 3;
        if (var6 <= var3.getY() + 3) {
          var7 = 0;
        }

        BlockPosition.MutableBlockPosition var8 = new BlockPosition.MutableBlockPosition();

        for (var9 = var3.getX() - var7; var9 <= var3.getX() + var7 && var5; ++var9) {
          for (var10 = var3.getZ() - var7; var10 <= var3.getZ() + var7 && var5; ++var10) {
            if (var6 >= 0 && var6 < 256) {
              Block var11 = var1.getType(var8.setPosition(var9, var6, var10)).getBlock();
              if (var11.getMaterial() != Material.AIR && var11.getMaterial() != Material.LEAVES) {
                var5 = false;
              }
            } else {
              var5 = false;
            }
          }
        }
      }

      if (!var5) {
        return false;
      } else {
        Block var19 = var1.getType(var3.down()).getBlock();
        if (var19 != Blocks.DIRT && var19 != Blocks.GRASS && var19 != Blocks.MYCELIM) {
          return false;
        } else {
          int var20 = var3.getY() + var4;
          if (this.a == Blocks.RED_MUSHROOM_BLOCK) {
            var20 = var3.getY() + var4 - 3;
          }

          int var21;
          for (var21 = var20; var21 <= var3.getY() + var4; ++var21) {
            var9 = 1;
            if (var21 < var3.getY() + var4) {
              ++var9;
            }

            if (this.a == Blocks.BROWN_MUSHROOM_BLOCK) {
              var9 = 3;
            }

            var10 = var3.getX() - var9;
            int var23 = var3.getX() + var9;
            int var12 = var3.getZ() - var9;
            int var13 = var3.getZ() + var9;

            for (int var14 = var10; var14 <= var23; ++var14) {
              for (int var15 = var12; var15 <= var13; ++var15) {
                int var16 = 5;
                if (var14 == var10) {
                  --var16;
                } else if (var14 == var23) {
                  ++var16;
                }

                if (var15 == var12) {
                  var16 -= 3;
                } else if (var15 == var13) {
                  var16 += 3;
                }

                BlockHugeMushroom.class_a_in_class_aiw var17 =
                    BlockHugeMushroom.class_a_in_class_aiw.a(var16);
                if (this.a == Blocks.BROWN_MUSHROOM_BLOCK || var21 < var3.getY() + var4) {
                  if ((var14 == var10 || var14 == var23) && (var15 == var12 || var15 == var13)) {
                    continue;
                  }

                  if (var14 == var3.getX() - (var9 - 1) && var15 == var12) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.a;
                  }

                  if (var14 == var10 && var15 == var3.getZ() - (var9 - 1)) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.a;
                  }

                  if (var14 == var3.getX() + (var9 - 1) && var15 == var12) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.c;
                  }

                  if (var14 == var23 && var15 == var3.getZ() - (var9 - 1)) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.c;
                  }

                  if (var14 == var3.getX() - (var9 - 1) && var15 == var13) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.g;
                  }

                  if (var14 == var10 && var15 == var3.getZ() + (var9 - 1)) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.g;
                  }

                  if (var14 == var3.getX() + (var9 - 1) && var15 == var13) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.i;
                  }

                  if (var14 == var23 && var15 == var3.getZ() + (var9 - 1)) {
                    var17 = BlockHugeMushroom.class_a_in_class_aiw.i;
                  }
                }

                if (var17 == BlockHugeMushroom.class_a_in_class_aiw.e
                    && var21 < var3.getY() + var4) {
                  var17 = BlockHugeMushroom.class_a_in_class_aiw.k;
                }

                if (var3.getY() >= var3.getY() + var4 - 1
                    || var17 != BlockHugeMushroom.class_a_in_class_aiw.k) {
                  BlockPosition var18 = new BlockPosition(var14, var21, var15);
                  if (!var1.getType(var18).getBlock().isFullBlock()) {
                    this.setTypeAndData(
                        var1, var18, this.a.getBlockData().set(BlockHugeMushroom.a, var17));
                  }
                }
              }
            }
          }

          for (var21 = 0; var21 < var4; ++var21) {
            Block var22 = var1.getType(var3.up(var21)).getBlock();
            if (!var22.isFullBlock()) {
              this.setTypeAndData(
                  var1,
                  var3.up(var21),
                  this.a
                      .getBlockData()
                      .set(BlockHugeMushroom.a, BlockHugeMushroom.class_a_in_class_aiw.j));
            }
          }

          return true;
        }
      }
    } else {
      return false;
    }
  }
コード例 #8
0
ファイル: Entity.java プロジェクト: randyzingle/javaalg
  public void move(double d0, double d1, double d2) {
    if (this.T) {
      this.a(this.getBoundingBox().c(d0, d1, d2));
      this.recalcPosition();
    } else {
      this.world.methodProfiler.a("move");
      double d3 = this.locX;
      double d4 = this.locY;
      double d5 = this.locZ;

      if (this.H) {
        this.H = false;
        d0 *= 0.25D;
        d1 *= 0.05000000074505806D;
        d2 *= 0.25D;
        this.motX = 0.0D;
        this.motY = 0.0D;
        this.motZ = 0.0D;
      }

      double d6 = d0;
      double d7 = d1;
      double d8 = d2;
      boolean flag = this.onGround && this.isSneaking() && this instanceof EntityHuman;

      if (flag) {
        double d9;

        for (d9 = 0.05D;
            d0 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, 0.0D)).isEmpty();
            d6 = d0) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }
        }

        for (;
            d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(0.0D, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }

        for (;
            d0 != 0.0D
                && d2 != 0.0D
                && this.world.getCubes(this, this.getBoundingBox().c(d0, -1.0D, d2)).isEmpty();
            d8 = d2) {
          if (d0 < d9 && d0 >= -d9) {
            d0 = 0.0D;
          } else if (d0 > 0.0D) {
            d0 -= d9;
          } else {
            d0 += d9;
          }

          d6 = d0;
          if (d2 < d9 && d2 >= -d9) {
            d2 = 0.0D;
          } else if (d2 > 0.0D) {
            d2 -= d9;
          } else {
            d2 += d9;
          }
        }
      }

      List list = this.world.getCubes(this, this.getBoundingBox().a(d0, d1, d2));
      AxisAlignedBB axisalignedbb = this.getBoundingBox();

      AxisAlignedBB axisalignedbb1;

      for (Iterator iterator = list.iterator();
          iterator.hasNext();
          d1 = axisalignedbb1.b(this.getBoundingBox(), d1)) {
        axisalignedbb1 = (AxisAlignedBB) iterator.next();
      }

      this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
      boolean flag1 = this.onGround || d7 != d1 && d7 < 0.0D;

      AxisAlignedBB axisalignedbb2;
      Iterator iterator1;

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d0 = axisalignedbb2.a(this.getBoundingBox(), d0)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(d0, 0.0D, 0.0D));

      for (iterator1 = list.iterator();
          iterator1.hasNext();
          d2 = axisalignedbb2.c(this.getBoundingBox(), d2)) {
        axisalignedbb2 = (AxisAlignedBB) iterator1.next();
      }

      this.a(this.getBoundingBox().c(0.0D, 0.0D, d2));
      if (this.S > 0.0F && flag1 && (d6 != d0 || d8 != d2)) {
        double d10 = d0;
        double d11 = d1;
        double d12 = d2;
        AxisAlignedBB axisalignedbb3 = this.getBoundingBox();

        this.a(axisalignedbb);
        d1 = (double) this.S;
        List list1 = this.world.getCubes(this, this.getBoundingBox().a(d6, d1, d8));
        AxisAlignedBB axisalignedbb4 = this.getBoundingBox();
        AxisAlignedBB axisalignedbb5 = axisalignedbb4.a(d6, 0.0D, d8);
        double d13 = d1;

        AxisAlignedBB axisalignedbb6;

        for (Iterator iterator2 = list1.iterator();
            iterator2.hasNext();
            d13 = axisalignedbb6.b(axisalignedbb5, d13)) {
          axisalignedbb6 = (AxisAlignedBB) iterator2.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, d13, 0.0D);
        double d14 = d6;

        AxisAlignedBB axisalignedbb7;

        for (Iterator iterator3 = list1.iterator();
            iterator3.hasNext();
            d14 = axisalignedbb7.a(axisalignedbb4, d14)) {
          axisalignedbb7 = (AxisAlignedBB) iterator3.next();
        }

        axisalignedbb4 = axisalignedbb4.c(d14, 0.0D, 0.0D);
        double d15 = d8;

        AxisAlignedBB axisalignedbb8;

        for (Iterator iterator4 = list1.iterator();
            iterator4.hasNext();
            d15 = axisalignedbb8.c(axisalignedbb4, d15)) {
          axisalignedbb8 = (AxisAlignedBB) iterator4.next();
        }

        axisalignedbb4 = axisalignedbb4.c(0.0D, 0.0D, d15);
        AxisAlignedBB axisalignedbb9 = this.getBoundingBox();
        double d16 = d1;

        AxisAlignedBB axisalignedbb10;

        for (Iterator iterator5 = list1.iterator();
            iterator5.hasNext();
            d16 = axisalignedbb10.b(axisalignedbb9, d16)) {
          axisalignedbb10 = (AxisAlignedBB) iterator5.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, d16, 0.0D);
        double d17 = d6;

        AxisAlignedBB axisalignedbb11;

        for (Iterator iterator6 = list1.iterator();
            iterator6.hasNext();
            d17 = axisalignedbb11.a(axisalignedbb9, d17)) {
          axisalignedbb11 = (AxisAlignedBB) iterator6.next();
        }

        axisalignedbb9 = axisalignedbb9.c(d17, 0.0D, 0.0D);
        double d18 = d8;

        AxisAlignedBB axisalignedbb12;

        for (Iterator iterator7 = list1.iterator();
            iterator7.hasNext();
            d18 = axisalignedbb12.c(axisalignedbb9, d18)) {
          axisalignedbb12 = (AxisAlignedBB) iterator7.next();
        }

        axisalignedbb9 = axisalignedbb9.c(0.0D, 0.0D, d18);
        double d19 = d14 * d14 + d15 * d15;
        double d20 = d17 * d17 + d18 * d18;

        if (d19 > d20) {
          d0 = d14;
          d2 = d15;
          this.a(axisalignedbb4);
        } else {
          d0 = d17;
          d2 = d18;
          this.a(axisalignedbb9);
        }

        d1 = (double) (-this.S);

        AxisAlignedBB axisalignedbb13;

        for (Iterator iterator8 = list1.iterator();
            iterator8.hasNext();
            d1 = axisalignedbb13.b(this.getBoundingBox(), d1)) {
          axisalignedbb13 = (AxisAlignedBB) iterator8.next();
        }

        this.a(this.getBoundingBox().c(0.0D, d1, 0.0D));
        if (d10 * d10 + d12 * d12 >= d0 * d0 + d2 * d2) {
          d0 = d10;
          d1 = d11;
          d2 = d12;
          this.a(axisalignedbb3);
        }
      }

      this.world.methodProfiler.b();
      this.world.methodProfiler.a("rest");
      this.recalcPosition();
      this.positionChanged = d6 != d0 || d8 != d2;
      this.E = d7 != d1;
      this.onGround = this.E && d7 < 0.0D;
      this.F = this.positionChanged || this.E;
      int i = MathHelper.floor(this.locX);
      int j = MathHelper.floor(this.locY - 0.20000000298023224D);
      int k = MathHelper.floor(this.locZ);
      BlockPosition blockposition = new BlockPosition(i, j, k);
      Block block = this.world.getType(blockposition).getBlock();

      if (block.getMaterial() == Material.AIR) {
        Block block1 = this.world.getType(blockposition.down()).getBlock();

        if (block1 instanceof BlockFence
            || block1 instanceof BlockCobbleWall
            || block1 instanceof BlockFenceGate) {
          block = block1;
          blockposition = blockposition.down();
        }
      }

      this.a(d1, this.onGround, block, blockposition);
      if (d6 != d0) {
        this.motX = 0.0D;
      }

      if (d8 != d2) {
        this.motZ = 0.0D;
      }

      if (d7 != d1) {
        block.a(this.world, this);
      }

      if (this.r_() && !flag && this.vehicle == null) {
        double d21 = this.locX - d3;
        double d22 = this.locY - d4;
        double d23 = this.locZ - d5;

        if (block != Blocks.LADDER) {
          d22 = 0.0D;
        }

        if (block != null && this.onGround) {
          block.a(this.world, blockposition, this);
        }

        this.M = (float) ((double) this.M + (double) MathHelper.sqrt(d21 * d21 + d23 * d23) * 0.6D);
        this.N =
            (float)
                ((double) this.N
                    + (double) MathHelper.sqrt(d21 * d21 + d22 * d22 + d23 * d23) * 0.6D);
        if (this.N > (float) this.h && block.getMaterial() != Material.AIR) {
          this.h = (int) this.N + 1;
          if (this.V()) {
            float f =
                MathHelper.sqrt(
                        this.motX * this.motX * 0.20000000298023224D
                            + this.motY * this.motY
                            + this.motZ * this.motZ * 0.20000000298023224D)
                    * 0.35F;

            if (f > 1.0F) {
              f = 1.0F;
            }

            this.makeSound(
                this.P(), f, 1.0F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
          }

          this.a(blockposition, block);
        }
      }

      try {
        this.checkBlockCollisions();
      } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.a(throwable, "Checking entity block collision");
        CrashReportSystemDetails crashreportsystemdetails =
            crashreport.a("Entity being checked for collision");

        this.appendEntityCrashDetails(crashreportsystemdetails);
        throw new ReportedException(crashreport);
      }

      boolean flag2 = this.U();

      if (this.world.e(this.getBoundingBox().shrink(0.001D, 0.001D, 0.001D))) {
        this.burn(1);
        if (!flag2) {
          ++this.fireTicks;
          if (this.fireTicks == 0) {
            this.setOnFire(8);
          }
        }
      } else if (this.fireTicks <= 0) {
        this.fireTicks = -this.maxFireTicks;
      }

      if (flag2 && this.fireTicks > 0) {
        this.makeSound(
            "random.fizz", 0.7F, 1.6F + (this.random.nextFloat() - this.random.nextFloat()) * 0.4F);
        this.fireTicks = -this.maxFireTicks;
      }

      this.world.methodProfiler.b();
    }
  }
コード例 #9
0
ファイル: BlockNetherWart.java プロジェクト: chums122/Spigot
 public boolean f(World world, BlockPosition blockposition, IBlockData iblockdata) {
   return c(world.getType(blockposition.down()).getBlock());
 }
コード例 #10
0
 public boolean canPlace(World world, BlockPosition blockposition) {
   return world.getType(blockposition).getBlock().material.isReplaceable()
       && World.a((IBlockAccess) world, blockposition.down());
 }
コード例 #11
0
ファイル: BlockFlowing.java プロジェクト: chums122/Spigot
  public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
    org.bukkit.World bworld = world.getWorld();
    Server server = world.getServer();
    org.bukkit.block.Block source =
        bworld == null
            ? null
            : bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());

    int i = ((Integer) iblockdata.get(LEVEL)).intValue();
    byte b0 = 1;
    if ((this.material == Material.LAVA) && (!world.worldProvider.n())) {
      b0 = 2;
    }
    int j = a(world);
    if (i > 0) {
      int l = -100;

      this.a = 0;
      EnumDirection enumdirection;
      for (Iterator iterator = EnumDirection.EnumDirectionLimit.HORIZONTAL.iterator();
          iterator.hasNext();
          l = a(world, blockposition.shift(enumdirection), l)) {
        enumdirection = (EnumDirection) iterator.next();
      }
      int i1 = l + b0;
      if ((i1 >= 8) || (l < 0)) {
        i1 = -1;
      }
      if (e(world, blockposition.up()) >= 0) {
        int k = e(world, blockposition.up());
        if (k >= 8) {
          i1 = k;
        } else {
          i1 = k + 8;
        }
      }
      if ((this.a >= 2) && (this.material == Material.WATER)) {
        IBlockData iblockdata1 = world.getType(blockposition.down());
        if (iblockdata1.getBlock().getMaterial().isBuildable()) {
          i1 = 0;
        } else if ((iblockdata1.getBlock().getMaterial() == this.material)
            && (((Integer) iblockdata1.get(LEVEL)).intValue() == 0)) {
          i1 = 0;
        }
      }
      if ((this.material == Material.LAVA)
          && (i < 8)
          && (i1 < 8)
          && (i1 > i)
          && (random.nextInt(4) != 0)) {
        j *= 4;
      }
      if (i1 == i) {
        f(world, blockposition, iblockdata);
      } else {
        i = i1;
        if (i1 < 0) {
          world.setAir(blockposition);
        } else {
          iblockdata = iblockdata.set(LEVEL, Integer.valueOf(i1));
          world.setTypeAndData(blockposition, iblockdata, 2);
          world.a(blockposition, this, j);
          world.applyPhysics(blockposition, this);
        }
      }
    } else {
      f(world, blockposition, iblockdata);
    }
    IBlockData iblockdata2 = world.getType(blockposition.down());
    if (h(world, blockposition.down(), iblockdata2)) {
      BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
      if (server != null) {
        server.getPluginManager().callEvent(event);
      }
      if (!event.isCancelled()) {
        if ((this.material == Material.LAVA)
            && (world.getType(blockposition.down()).getBlock().getMaterial() == Material.WATER)) {
          world.setTypeUpdate(blockposition.down(), Blocks.STONE.getBlockData());
          fizz(world, blockposition.down());
          return;
        }
        if (i >= 8) {
          flow(world, blockposition.down(), iblockdata2, i);
        } else {
          flow(world, blockposition.down(), iblockdata2, i + 8);
        }
      }
    } else if ((i >= 0) && ((i == 0) || (g(world, blockposition.down(), iblockdata2)))) {
      Set set = f(world, blockposition);

      int k = i + b0;
      if (i >= 8) {
        k = 1;
      }
      if (k >= 8) {
        return;
      }
      Iterator iterator1 = set.iterator();
      while (iterator1.hasNext()) {
        EnumDirection enumdirection1 = (EnumDirection) iterator1.next();

        BlockFromToEvent event =
            new BlockFromToEvent(source, CraftBlock.notchToBlockFace(enumdirection1));
        if (server != null) {
          server.getPluginManager().callEvent(event);
        }
        if (!event.isCancelled()) {
          flow(
              world,
              blockposition.shift(enumdirection1),
              world.getType(blockposition.shift(enumdirection1)),
              k);
        }
      }
    }
  }
コード例 #12
0
ファイル: Explosion.java プロジェクト: dentmaged/Spigot-1.8
  public void a(boolean flag) {
    this.world.makeSound(
        this.posX,
        this.posY,
        this.posZ,
        "random.explode",
        4.0F,
        (1.0F + (this.world.random.nextFloat() - this.world.random.nextFloat()) * 0.2F) * 0.7F);
    if (this.size >= 2.0F && this.b) {
      this.world.addParticle(
          EnumParticle.EXPLOSION_HUGE,
          this.posX,
          this.posY,
          this.posZ,
          1.0D,
          0.0D,
          0.0D,
          new int[0]);
    } else {
      this.world.addParticle(
          EnumParticle.EXPLOSION_LARGE,
          this.posX,
          this.posY,
          this.posZ,
          1.0D,
          0.0D,
          0.0D,
          new int[0]);
    }

    Iterator iterator;
    BlockPosition blockposition;

    if (this.b) {
      // CraftBukkit start
      org.bukkit.World bworld = this.world.getWorld();
      org.bukkit.entity.Entity explode = this.source == null ? null : this.source.getBukkitEntity();
      Location location = new Location(bworld, this.posX, this.posY, this.posZ);

      List<org.bukkit.block.Block> blockList = Lists.newArrayList();
      for (int i1 = this.blocks.size() - 1; i1 >= 0; i1--) {
        BlockPosition cpos = (BlockPosition) this.blocks.get(i1);
        org.bukkit.block.Block bblock = bworld.getBlockAt(cpos.getX(), cpos.getY(), cpos.getZ());
        if (bblock.getType() != org.bukkit.Material.AIR) {
          blockList.add(bblock);
        }
      }

      boolean cancelled;
      List<org.bukkit.block.Block> bukkitBlocks;
      float yield;

      if (explode != null) {
        EntityExplodeEvent event = new EntityExplodeEvent(explode, location, blockList, 0.3F);
        this.world.getServer().getPluginManager().callEvent(event);
        cancelled = event.isCancelled();
        bukkitBlocks = event.blockList();
        yield = event.getYield();
      } else {
        BlockExplodeEvent event = new BlockExplodeEvent(location.getBlock(), blockList, 0.3F);
        this.world.getServer().getPluginManager().callEvent(event);
        cancelled = event.isCancelled();
        bukkitBlocks = event.blockList();
        yield = event.getYield();
      }

      this.blocks.clear();

      for (org.bukkit.block.Block bblock : bukkitBlocks) {
        BlockPosition coords = new BlockPosition(bblock.getX(), bblock.getY(), bblock.getZ());
        blocks.add(coords);
      }

      if (cancelled) {
        this.wasCanceled = true;
        return;
      }
      // CraftBukkit end
      iterator = this.blocks.iterator();

      while (iterator.hasNext()) {
        blockposition = (BlockPosition) iterator.next();
        Block block = this.world.getType(blockposition).getBlock();

        world.spigotConfig.antiXrayInstance.updateNearbyBlocks(world, blockposition); // Spigot
        if (flag) {
          double d0 = (double) ((float) blockposition.getX() + this.world.random.nextFloat());
          double d1 = (double) ((float) blockposition.getY() + this.world.random.nextFloat());
          double d2 = (double) ((float) blockposition.getZ() + this.world.random.nextFloat());
          double d3 = d0 - this.posX;
          double d4 = d1 - this.posY;
          double d5 = d2 - this.posZ;
          double d6 = (double) MathHelper.sqrt(d3 * d3 + d4 * d4 + d5 * d5);

          d3 /= d6;
          d4 /= d6;
          d5 /= d6;
          double d7 = 0.5D / (d6 / (double) this.size + 0.1D);

          d7 *= (double) (this.world.random.nextFloat() * this.world.random.nextFloat() + 0.3F);
          d3 *= d7;
          d4 *= d7;
          d5 *= d7;
          this.world.addParticle(
              EnumParticle.EXPLOSION_NORMAL,
              (d0 + this.posX * 1.0D) / 2.0D,
              (d1 + this.posY * 1.0D) / 2.0D,
              (d2 + this.posZ * 1.0D) / 2.0D,
              d3,
              d4,
              d5,
              new int[0]);
          this.world.addParticle(EnumParticle.SMOKE_NORMAL, d0, d1, d2, d3, d4, d5, new int[0]);
        }

        if (block.getMaterial() != Material.AIR) {
          if (block.a(this)) {
            // CraftBukkit - add yield
            block.dropNaturally(
                this.world, blockposition, this.world.getType(blockposition), yield, 0);
          }

          this.world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 3);
          block.wasExploded(this.world, blockposition, this);
        }
      }
    }

    if (this.a) {
      iterator = this.blocks.iterator();

      while (iterator.hasNext()) {
        blockposition = (BlockPosition) iterator.next();
        if (this.world.getType(blockposition).getBlock().getMaterial() == Material.AIR
            && this.world.getType(blockposition.down()).getBlock().o()
            && this.c.nextInt(3) == 0) {
          // CraftBukkit start - Ignition by explosion
          if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(
                  this.world,
                  blockposition.getX(),
                  blockposition.getY(),
                  blockposition.getZ(),
                  this)
              .isCancelled()) {
            this.world.setTypeUpdate(blockposition, Blocks.FIRE.getBlockData());
          }
          // CraftBukkit end
        }
      }
    }
  }