Package net.minecraft.server

Examples of net.minecraft.server.Block


   * @return True if a block got changed, False if not
   */
  public static boolean setBlock(org.bukkit.Chunk chunk, int x, int y, int z, Material type, int data) {
    boolean result = y >= 0 && y <= chunk.getWorld().getMaxHeight();
    WorldServer world = CommonNMS.getNative(chunk.getWorld());
    Block typeBlock = CommonNMS.getBlock(type);
    if (result) {
      result = ChunkRef.setBlock(Conversion.toChunkHandle.convert(chunk), x, y, z, typeBlock, data);
            world.methodProfiler.a("checkLight");
            world.z(x, y, z);
            world.methodProfiler.b();
View Full Code Here


    int x, y, z;
    for (x = xmin; x < xmax; ++x) {
      for (z = zmin; z < zmax; ++z) {
        if (handle.world.isLoaded(x, 64, z)) {
          for (y = ymin - 1; y < ymax; ++y) {
            Block block = handle.world.getType(x, y, z);
            if (block != null) {
              block.a(handle.world, x, y, z, bounds, collisionBuffer, handle);
            }
          }
        }
      }
    }

    // Handle block collisions
    BlockFace hitFace;
    Iterator<AxisAlignedBB> iter = collisionBuffer.iterator();
    AxisAlignedBB blockBounds;
    double dx, dz;
    while (iter.hasNext()) {
      blockBounds = iter.next();
      // Convert to block and block coordinates
      org.bukkit.block.Block block = entity.getWorld().getBlockAt(MathUtil.floor(blockBounds.a), MathUtil.floor(blockBounds.b), MathUtil.floor(blockBounds.c));

      // Find out what direction the block is hit
      if (bounds.e > blockBounds.e) {
        hitFace = BlockFace.UP;
      } else if (bounds.b < blockBounds.b) {
        hitFace = BlockFace.DOWN;
      } else {
        dx = entity.loc.getX() - block.getX() - 0.5;
        dz = entity.loc.getZ() - block.getZ() - 0.5;
        hitFace = FaceUtil.getDirection(dx, dz, false);
      }
      // Block collision event
      if (!controller.onBlockCollision(block, hitFace)) {
        iter.remove();
View Full Code Here

    // Update entity movement sounds
    if (EntityRef.hasMovementSound(handle) && handle.vehicle == null) {
      int bX = entity.loc.x.block();
      int bY = MathUtil.floor(handle.locY - 0.2 - (double) handle.height);
      int bZ = entity.loc.z.block();
      Block block = handle.world.getType(bX, bY, bZ);
      int j1 = handle.world.getType(bX, bY - 1, bZ).b();

      // Magic values! *gasp* Bad, BAD Minecraft! Go sit in a corner!
      if (j1 == 11 || j1 == 32 || j1 == 21) {
        block = handle.world.getType(bX, bY - 1, bZ);
      }
      if (block != Blocks.LADDER) {
        moveDy = 0.0;
      }

      handle.Q += MathUtil.length(moveDx, moveDz) * 0.6;
      handle.O += MathUtil.length(moveDx, moveDy, moveDz) * 0.6;
      if (handle.O > EntityRef.stepCounter.get(entity.getHandle()) && block != Blocks.AIR) {
        EntityRef.stepCounter.set(entity.getHandle(), (int) handle.O + 1);
        if (entity.isInWater(true)) {
          float f = (float) Math.sqrt(entity.vel.y.squared() + 0.2 * entity.vel.xz.lengthSquared()) * 0.35f;
          if (f > 1.0f) {
            f = 1.0f;
          }
          entity.makeRandomSound(EntityRef.getSwimSound.invoke(handle), f, 1.0f);
        }
        entity.makeStepSound(bX, bY, bZ, CommonNMS.getMaterial(block));
        block.b(handle.world, bX, bY, bZ, handle);
      }
    }

    EntityRef.updateBlockCollision(handle);

View Full Code Here

TOP

Related Classes of net.minecraft.server.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.