예제 #1
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;
    }
  }
예제 #2
0
  public void d(World world, BlockPosition blockposition) {
    if (!world.worldProvider.o()) {
      IBlockData iblockdata = world.getType(blockposition);
      int i = world.b(EnumSkyBlock.SKY, blockposition) - world.ab();
      float f = world.d(1.0F);
      float f1 = f < 3.1415927F ? 0.0F : 6.2831855F;

      f += (f1 - f) * 0.2F;
      i = Math.round((float) i * MathHelper.cos(f));
      i = MathHelper.clamp(i, 0, 15);
      if (this.b) {
        i = 15 - i;
      }

      if (((Integer) iblockdata.get(BlockDaylightDetector.POWER)).intValue() != i) {
        i =
            org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(
                    world,
                    blockposition.getX(),
                    blockposition.getY(),
                    blockposition.getZ(),
                    ((Integer) iblockdata.get(POWER)),
                    i)
                .getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
        world.setTypeAndData(
            blockposition, iblockdata.set(BlockDaylightDetector.POWER, Integer.valueOf(i)), 3);
      }
    }
  }
예제 #3
0
  public boolean interact(
      World world,
      BlockPosition blockposition,
      IBlockData iblockdata,
      EntityHuman entityhuman,
      EnumHand enumhand,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    ItemStack itemstack = entityhuman.b(enumhand);

    if (!itemstack.isEmpty()
        && (itemstack.getItem() == Items.FLINT_AND_STEEL
            || itemstack.getItem() == Items.FIRE_CHARGE)) {
      this.a(
          world,
          blockposition,
          iblockdata.set(BlockTNT.EXPLODE, Boolean.valueOf(true)),
          (EntityLiving) entityhuman);
      world.setTypeAndData(blockposition, Blocks.AIR.getBlockData(), 11);
      if (itemstack.getItem() == Items.FLINT_AND_STEEL) {
        itemstack.damage(1, entityhuman);
      } else if (!entityhuman.abilities.canInstantlyBuild) {
        itemstack.subtract(1);
      }

      return true;
    } else {
      return super.interact(
          world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2);
    }
  }
예제 #4
0
  public void a(
      World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
    if (entityhuman.abilities.canInstantlyBuild) {
      iblockdata = iblockdata.set(BlockSkull.NODROP, Boolean.valueOf(true));
      world.setTypeAndData(blockposition, iblockdata, 4);
    }

    super.a(world, blockposition, iblockdata, entityhuman);
  }
예제 #5
0
 private void flow(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
   if ((world.isLoaded(blockposition)) && (h(world, blockposition, iblockdata))) {
     if (iblockdata.getBlock() != Blocks.AIR) {
       if (this.material == Material.LAVA) {
         fizz(world, blockposition);
       } else {
         iblockdata.getBlock().b(world, blockposition, iblockdata, 0);
       }
     }
     world.setTypeAndData(blockposition, getBlockData().set(LEVEL, Integer.valueOf(i)), 3);
   }
 }
예제 #6
0
  public boolean interact(
      World world,
      BlockPosition blockposition,
      IBlockData iblockdata,
      EntityHuman entityhuman,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    if (entityhuman.cm()) {
      if (world.isStatic) {
        return true;
      } else {
        if (this.b) {
          world.setTypeAndData(
              blockposition,
              Blocks.DAYLIGHT_DETECTOR
                  .getBlockData()
                  .set(BlockDaylightDetector.POWER, iblockdata.get(BlockDaylightDetector.POWER)),
              4);
          Blocks.DAYLIGHT_DETECTOR.d(world, blockposition);
        } else {
          world.setTypeAndData(
              blockposition,
              Blocks.DAYLIGHT_DETECTOR_INVERTED
                  .getBlockData()
                  .set(BlockDaylightDetector.POWER, iblockdata.get(BlockDaylightDetector.POWER)),
              4);
          Blocks.DAYLIGHT_DETECTOR_INVERTED.d(world, blockposition);
        }

        return true;
      }
    } else {
      return super.interact(
          world, blockposition, iblockdata, entityhuman, enumdirection, f, f1, f2);
    }
  }
예제 #7
0
  public boolean a(World world, Random random, StructureBoundingBox structureboundingbox) {
    Block block = this.b(Blocks.GRAVEL, 0);

    for (int i = this.f.a; i <= this.f.d; ++i) {
      for (int j = this.f.c; j <= this.f.f; ++j) {
        if (structureboundingbox.b(i, 64, j)) {
          int k = world.i(i, j) - 1;

          world.setTypeAndData(i, k, j, block, 0, 2);
        }
      }
    }

    return true;
  }
예제 #8
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;
  }
예제 #9
0
  public boolean interactWith(
      ItemStack itemstack,
      EntityHuman entityhuman,
      World world,
      BlockPosition blockposition,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    IBlockData iblockdata = world.getType(blockposition);
    Block block = iblockdata.getBlock();

    if (!block.a(world, blockposition)) {
      blockposition = blockposition.shift(enumdirection);
    }

    if (itemstack.count == 0) {
      return false;
    } else if (!entityhuman.a(blockposition, enumdirection, itemstack)) {
      return false;
    } else if (world.a(this.a, blockposition, false, enumdirection, (Entity) null, itemstack)) {
      int i = this.filterData(itemstack.getData());
      IBlockData iblockdata1 =
          this.a.getPlacedState(world, blockposition, enumdirection, f, f1, f2, i, entityhuman);

      if (world.setTypeAndData(blockposition, iblockdata1, 3)) {
        iblockdata1 = world.getType(blockposition);
        if (iblockdata1.getBlock() == this.a) {
          a(world, entityhuman, blockposition, itemstack);
          this.a.postPlace(world, blockposition, iblockdata1, entityhuman, itemstack);
        }

        world.makeSound(
            (double) ((float) blockposition.getX() + 0.5F),
            (double) ((float) blockposition.getY() + 0.5F),
            (double) ((float) blockposition.getZ() + 0.5F),
            this.a.stepSound.getPlaceSound(),
            (this.a.stepSound.getVolume1() + 1.0F) / 2.0F,
            this.a.stepSound.getVolume2() * 0.8F);
        --itemstack.count;
      }

      return true;
    } else {
      return false;
    }
  }
예제 #10
0
  public boolean generate(World world, Random random, int i, int j, int k) {
    Block block;

    while (((block = world.getType(i, j, k)).getMaterial() == Material.AIR
            || block.getMaterial() == Material.LEAVES)
        && j > 0) {
      --j;
    }

    for (int l = 0; l < 128; ++l) {
      int i1 = i + random.nextInt(8) - random.nextInt(8);
      int j1 = j + random.nextInt(4) - random.nextInt(4);
      int k1 = k + random.nextInt(8) - random.nextInt(8);

      if (world.isEmpty(i1, j1, k1) && this.a.j(world, i1, j1, k1)) {
        world.setTypeAndData(i1, j1, k1, this.a, this.b, 2);
      }
    }

    return true;
  }
예제 #11
0
  public boolean interact(
      World world,
      BlockPosition blockposition,
      IBlockData iblockdata,
      EntityHuman entityhuman,
      EnumDirection enumdirection,
      float f,
      float f1,
      float f2) {
    if (world.isClientSide) {
      return true;
    }
    boolean powered = ((Boolean) iblockdata.get(POWERED)).booleanValue();
    org.bukkit.block.Block block =
        world
            .getWorld()
            .getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    int old = powered ? 15 : 0;
    int current = !powered ? 15 : 0;

    BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
    world.getServer().getPluginManager().callEvent(eventRedstone);
    if ((eventRedstone.getNewCurrent() > 0 ? 1 : 0) != (powered ? 0 : 1)) {
      return true;
    }
    iblockdata = iblockdata.a(POWERED);
    world.setTypeAndData(blockposition, iblockdata, 3);
    world.makeSound(
        blockposition.getX() + 0.5D,
        blockposition.getY() + 0.5D,
        blockposition.getZ() + 0.5D,
        "random.click",
        0.3F,
        ((Boolean) iblockdata.get(POWERED)).booleanValue() ? 0.6F : 0.5F);
    world.applyPhysics(blockposition, this);
    EnumDirection enumdirection1 = ((EnumLeverPosition) iblockdata.get(FACING)).c();

    world.applyPhysics(blockposition.shift(enumdirection1.opposite()), this);
    return true;
  }
예제 #12
0
  // CraftBukkit start - Add method to process block placement
  static boolean processBlockPlace(
      final World world,
      final EntityHuman entityhuman,
      final ItemStack itemstack,
      final int x,
      final int y,
      final int z,
      final Block id,
      final int data,
      final int clickedX,
      final int clickedY,
      final int clickedZ) {
    org.bukkit.block.BlockState blockstate =
        org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(world, x, y, z);

    world.callingPlaceEvent = true;
    // Sign is now 3 not 2.
    int flag = (id == Blocks.SIGN_POST || id == Blocks.WALL_SIGN) ? 3 : 2;
    world.setTypeAndData(x, y, z, id, data, flag);

    org.bukkit.event.block.BlockPlaceEvent event =
        org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(
            world, entityhuman, blockstate, clickedX, clickedY, clickedZ);
    if (event.isCancelled() || !event.canBuild()) {
      blockstate.update(true, false);
      world.callingPlaceEvent = false;
      return false;
    }

    world.callingPlaceEvent = false;

    Block block = world.getType(x, y, z);
    int newData = world.getData(x, y, z);

    if (block != null
        && !(block instanceof BlockContainer)) { // Containers get placed automatically
      block.onPlace(world, x, y, z);
    }

    world.update(x, y, z, block);

    // Cocoa beans placed via ItemDye do not need the rest of the processing
    if (block == Blocks.COCOA && itemstack != null && itemstack.getItem() instanceof ItemDye) {
      return true;
    }

    // Skulls don't get block data applied to them
    if (block != null && block != Blocks.SKULL) {
      block.postPlace(world, x, y, z, entityhuman, itemstack);
      block.postPlace(world, x, y, z, newData);

      world.makeSound(
          (double) ((float) x + 0.5F),
          (double) ((float) y + 0.5F),
          (double) ((float) z + 0.5F),
          block.stepSound.getPlaceSound(),
          (block.stepSound.getVolume1() + 1.0F) / 2.0F,
          block.stepSound.getVolume2() * 0.8F);
    }

    if (itemstack != null) {
      --itemstack.count;
    }

    return true;
  }
예제 #13
0
  public void d(World world, int i, int j, int k, Random random) {
    int l = world.getData(i, j, k) & 7;
    Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
    int i1 = 0;
    int j1 = 0;
    boolean flag = false;

    switch (l) {
      case 0:
      default:
        break;

      case 1:
        label78:
        for (i1 = 0; i1 >= -1; --i1) {
          for (j1 = 0; j1 >= -1; --j1) {
            if (this.a(world, i + i1, j, k + j1, 1)
                && this.a(world, i + i1 + 1, j, k + j1, 1)
                && this.a(world, i + i1, j, k + j1 + 1, 1)
                && this.a(world, i + i1 + 1, j, k + j1 + 1, 1)) {
              object = new WorldGenMegaTree(false, random.nextBoolean());
              flag = true;
              break label78;
            }
          }
        }

        if (!flag) {
          j1 = 0;
          i1 = 0;
          object = new WorldGenTaiga2(true);
        }
        break;

      case 2:
        object = new WorldGenForest(true, false);
        break;

      case 3:
        label93:
        for (i1 = 0; i1 >= -1; --i1) {
          for (j1 = 0; j1 >= -1; --j1) {
            if (this.a(world, i + i1, j, k + j1, 3)
                && this.a(world, i + i1 + 1, j, k + j1, 3)
                && this.a(world, i + i1, j, k + j1 + 1, 3)
                && this.a(world, i + i1 + 1, j, k + j1 + 1, 3)) {
              object = new WorldGenJungleTree(true, 10, 20, 3, 3);
              flag = true;
              break label93;
            }
          }
        }

        if (!flag) {
          j1 = 0;
          i1 = 0;
          object = new WorldGenTrees(true, 4 + random.nextInt(7), 3, 3, false);
        }
        break;

      case 4:
        object = new WorldGenAcaciaTree(true);
        break;

      case 5:
        label108:
        for (i1 = 0; i1 >= -1; --i1) {
          for (j1 = 0; j1 >= -1; --j1) {
            if (this.a(world, i + i1, j, k + j1, 5)
                && this.a(world, i + i1 + 1, j, k + j1, 5)
                && this.a(world, i + i1, j, k + j1 + 1, 5)
                && this.a(world, i + i1 + 1, j, k + j1 + 1, 5)) {
              object = new WorldGenForestTree(true);
              flag = true;
              break label108;
            }
          }
        }

        if (!flag) {
          return;
        }
    }

    Block block = Blocks.AIR;

    if (flag) {
      world.setTypeAndData(i + i1, j, k + j1, block, 0, 4);
      world.setTypeAndData(i + i1 + 1, j, k + j1, block, 0, 4);
      world.setTypeAndData(i + i1, j, k + j1 + 1, block, 0, 4);
      world.setTypeAndData(i + i1 + 1, j, k + j1 + 1, block, 0, 4);
    } else {
      world.setTypeAndData(i, j, k, block, 0, 4);
    }

    if (!((WorldGenerator) object).generate(world, random, i + i1, j, k + j1)) {
      if (flag) {
        world.setTypeAndData(i + i1, j, k + j1, this, l, 4);
        world.setTypeAndData(i + i1 + 1, j, k + j1, this, l, 4);
        world.setTypeAndData(i + i1, j, k + j1 + 1, this, l, 4);
        world.setTypeAndData(i + i1 + 1, j, k + j1 + 1, this, l, 4);
      } else {
        world.setTypeAndData(i, j, k, this, l, 4);
      }
    }
  }
예제 #14
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);
        }
      }
    }
  }
예제 #15
0
 private void f(World world, BlockPosition blockposition, IBlockData iblockdata) {
   world.setTypeAndData(
       blockposition,
       b(this.material).getBlockData().set(LEVEL, (Integer) iblockdata.get(LEVEL)),
       2);
 }