Add isOnGroundOrResetCond to BlockProperties.

This commit is contained in:
asofold 2013-01-30 02:00:48 +01:00
parent 87e350aa81
commit d2cdf377eb

View File

@ -651,7 +651,7 @@ public class BlockProperties {
final int y = location.getBlockY(); final int y = location.getBlockY();
final int z = location.getBlockZ(); final int z = location.getBlockZ();
final World world = location.getWorld(); final World world = location.getWorld();
final boolean onGround = isOnGround(player, location) || world.getBlockTypeIdAt(x, y, z) == Material.WATER_LILY.getId(); final boolean onGround = isOnGround(player, location, 0.3) || world.getBlockTypeIdAt(x, y, z) == Material.WATER_LILY.getId();
final boolean inWater = isInWater(world.getBlockTypeIdAt(x, y + 1, z)); final boolean inWater = isInWater(world.getBlockTypeIdAt(x, y + 1, z));
final int haste = (int) Math.round(PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.FAST_DIGGING)); final int haste = (int) Math.round(PotionUtil.getPotionEffectAmplifier(player, PotionEffectType.FAST_DIGGING));
// TODO: haste: int / double !? // TODO: haste: int / double !?
@ -887,31 +887,40 @@ public class BlockProperties {
} }
/** /**
* Heavy but ... * Simple checking method, heavy. No isIllegal check.
* @param world * @param player
* @param x * @param location
* @param y * @param yOnGround
* @param z
* @return * @return
*/ */
public static boolean isOnGround(Player player, Location location) { public static boolean isOnGround(final Player player, final Location location, final double yOnGround) {
// return blockId != 0 && net.minecraft.server.Block.byId[blockId].//.c();// d();
// Bit fat workaround, maybe put the object through from check listener ? // Bit fat workaround, maybe put the object through from check listener ?
blockCache.setAccess(location.getWorld()); blockCache.setAccess(location.getWorld());
pLoc.setBlockCache(blockCache); pLoc.setBlockCache(blockCache);
pLoc.set(location, player, 0.3); pLoc.set(location, player, yOnGround);
// if (pLoc.isIllegal()) {
// blockCache.cleanup();
// pLoc.cleanup();
// CheckUtils.onIllegalMove(player);
// return false;
// }
final boolean onGround = pLoc.isOnGround(); final boolean onGround = pLoc.isOnGround();
blockCache.cleanup(); blockCache.cleanup();
pLoc.cleanup(); pLoc.cleanup();
return onGround; return onGround;
} }
/**
* Simple checking method, heavy. No isIllegal check.
* @param player
* @param location
* @param yOnGround
* @return
*/
public static boolean isOnGroundOrResetCond(final Player player, final Location location, final double yOnGround){
blockCache.setAccess(location.getWorld());
pLoc.setBlockCache(blockCache);
pLoc.set(location, player, yOnGround);
final boolean res = pLoc.isOnGround() || pLoc.isResetCond();
blockCache.cleanup();
pLoc.cleanup();
return res;
}
public static final long getBLockFlags(final int id){ public static final long getBLockFlags(final int id){
return blockFlags[id]; return blockFlags[id];
} }