Пример #1
0
 /**
  * Test if something solid/ground-like collides within the given margin above the height of the
  * player.
  *
  * @param marginAboveHeight
  * @return
  */
 public boolean isHeadObstructed(double marginAboveHeight) {
   return BlockProperties.collides(
       blockCache,
       x - width,
       y + eyeHeight,
       z - width,
       x + width,
       y + eyeHeight + marginAboveHeight,
       z + width,
       BlockProperties.F_GROUND | BlockProperties.F_SOLID);
 }
Пример #2
0
 /**
  * Check if solid blocks hit the box.
  *
  * @param xzMargin
  * @param yMargin
  * @return
  */
 public boolean isNextToGround(final double xzMargin, final double yMargin) {
   // TODO: Adjust to check block flags ?
   return BlockProperties.collides(
       blockCache,
       minX - xzMargin,
       minY - yMargin,
       minZ - xzMargin,
       maxX + xzMargin,
       maxY + yMargin,
       maxZ + xzMargin,
       BlockProperties.F_GROUND);
 }
Пример #3
0
 /**
  * Checks if the player is in water.
  *
  * @return true, if the player is in water
  */
 public boolean isInWater() {
   if (inWater == null) {
     if (blockFlags != null && (blockFlags.longValue() & BlockProperties.F_WATER) == 0) {
       inWater = false;
       return false;
     }
     // TODO: ...
     //          final double dX = -0.001D;
     //          final double dY = -0.40000000596046448D - 0.001D;
     //          final double dZ = dX;
     //          inWater = BlockProperties.collides(blockCache, minX - dX, minY - dY, minZ - dZ,
     // maxX + dX, maxY + dY, maxZ + dZ, BlockProperties.F_WATER);
     inWater =
         BlockProperties.collides(
             blockCache, minX, minY, minZ, maxX, maxY, maxZ, BlockProperties.F_WATER);
   }
   return inWater;
 }
Пример #4
0
 /**
  * Checks if the player is in lava.
  *
  * @return true, if the player is in lava
  */
 public boolean isInLava() {
   if (inLava == null) {
     if (blockFlags != null && (blockFlags.longValue() & BlockProperties.F_LAVA) == 0) {
       inLava = false;
       return false;
     }
     // TODO: ...
     //          final double dX = -0.10000000149011612D;
     //          final double dY = -0.40000000596046448D;
     //          final double dZ = dX;
     //          inLava = BlockProperties.collides(blockCache, minX - dX, minY - dY, minZ - dZ,
     // maxX + dX, maxY + dY, maxZ + dZ, BlockProperties.F_LAVA);
     inLava =
         BlockProperties.collides(
             blockCache, minX, minY, minZ, maxX, maxY, maxZ, BlockProperties.F_LAVA);
   }
   return inLava;
 }
Пример #5
0
 /**
  * Checks if the player is in water.
  *
  * @return true, if the player is in water
  */
 public boolean isInWater() {
   if (inWater == null) {
     final double dX = -0.001D;
     final double dY = -0.40000000596046448D - 0.001D;
     final double dZ = -0.001D;
     inWater =
         BlockProperties.collides(
             getBlockAccess(),
             minX - dX,
             minY - dY,
             minZ - dZ,
             maxX + dX,
             maxY + dY,
             maxZ + dZ,
             BlockProperties.F_WATER);
   }
   return inWater;
 }
Пример #6
0
 /**
  * Checks if the player is in lava.
  *
  * @return true, if the player is in lava
  */
 public boolean isInLava() {
   if (inLava == null) {
     final double dX = -0.10000000149011612D;
     final double dY = -0.40000000596046448D;
     final double dZ = dX;
     inLava =
         BlockProperties.collides(
             getBlockAccess(),
             minX - dX,
             minY - dY,
             minZ - dZ,
             maxX + dX,
             maxY + dY,
             maxZ + dZ,
             BlockProperties.F_LAVA);
   }
   return inLava;
 }
Пример #7
0
 /**
  * Checks if the player is above stairs.
  *
  * @return true, if the player above on stairs
  */
 public boolean isAboveStairs() {
   if (aboveStairs == null) {
     // aboveStairs =
     // BlockProperties.isStairs(getTypeIdBelow().intValue());
     // TODO: maybe distinguish upside down stairs and normal stairs !
     final double diff = getWidth() + 0.001;
     aboveStairs =
         BlockProperties.collides(
             getBlockAccess(),
             x - diff,
             y + 0.25,
             z - diff,
             x + diff,
             y - 1.0,
             z + diff,
             BlockProperties.F_STAIRS);
   }
   return aboveStairs;
 }
Пример #8
0
 /**
  * Checks if the player is above stairs.
  *
  * @return true, if the player above on stairs
  */
 public boolean isAboveStairs() {
   if (aboveStairs == null) {
     if (blockFlags != null && (blockFlags.longValue() & BlockProperties.F_STAIRS) == 0) {
       aboveStairs = false;
       return false;
     }
     // TODO: Distinguish based on actual height off .0 ?
     // TODO: diff still needed ?
     final double diff = 0; // 0.001;
     aboveStairs =
         BlockProperties.collides(
             blockCache,
             minX - diff,
             minY - 1.0,
             minZ - diff,
             maxX + diff,
             minY + 0.25,
             maxZ + diff,
             BlockProperties.F_STAIRS);
   }
   return aboveStairs;
 }