示例#1
0
 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()));
 }
示例#2
0
 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;
 }
示例#3
0
 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;
 }
示例#4
0
  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);
        }
      }
    }
  }