當前位置: 首頁>>代碼示例>>Java>>正文


Java Block.isLiquid方法代碼示例

本文整理匯總了Java中org.bukkit.block.Block.isLiquid方法的典型用法代碼示例。如果您正苦於以下問題:Java Block.isLiquid方法的具體用法?Java Block.isLiquid怎麽用?Java Block.isLiquid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.block.Block的用法示例。


在下文中一共展示了Block.isLiquid方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: placeBlock

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * "simulate" a block place when you click on the side of a duct
 */
public static boolean placeBlock(Player p, Block b, Block placedAgainst, int id, byte data, EquipmentSlot es) {
	if (!DuctUtils.canBuild(p, b, placedAgainst, es)) {
		return false;
	}
	// check if there is already a duct at this position

	Map<BlockLoc, Duct> ductMap = TransportPipes.instance.getDuctMap(b.getWorld());
	if (ductMap != null) {
		if (ductMap.containsKey(BlockLoc.convertBlockLoc(b.getLocation()))) {
			return false;
		}
	}

	if (!(b.getType() == Material.AIR || b.isLiquid())) {
		return false;
	}
	b.setTypeIdAndData(id, data, true);

	if (TransportPipes.instance.containerBlockUtils.isIdContainerBlock(id)) {
		TransportPipes.instance.containerBlockUtils.updateDuctNeighborBlockSync(b, true);
	}

	return true;
}
 
開發者ID:RoboTricker,項目名稱:Transport-Pipes,代碼行數:28,代碼來源:HitboxUtils.java

示例2: isSafeSpot

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Checks if a given location is safe. A safe location is a location with two breathable blocks
 * (aka transparent block or water) over something solid (or water).
 *
 * @param location The checked location.
 *
 * @return {@code true} if the location is safe.
 */
public static boolean isSafeSpot(Location location)
{
    Block blockCenter = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY(), location.getBlockZ());
    Block blockAbove = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() + 1, location.getBlockZ());
    Block blockBelow = location.getWorld().getBlockAt(location.getBlockX(), location.getBlockY() - 1, location.getBlockZ());

    // two breathable blocks: ok
    if ((blockCenter.getType().isTransparent() || (blockCenter.isLiquid() && !blockCenter.getType().equals(Material.LAVA) && !blockCenter.getType().equals(Material.STATIONARY_LAVA)))
            && (blockAbove.getType().isTransparent() || (blockAbove.isLiquid() && !blockAbove.getType().equals(Material.LAVA) && !blockCenter.getType().equals(Material.STATIONARY_LAVA))))
    {
        // The block below is solid, or liquid (but not lava)
        return blockBelow.getType().isSolid() || blockBelow.getType().equals(Material.WATER) || blockBelow.getType().equals(Material.STATIONARY_WATER);
    }
    else
    {
        return false;
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:27,代碼來源:SafePortalsUtils.java

示例3: getLocationNearPlayer

import org.bukkit.block.Block; //導入方法依賴的package包/類
public static Location getLocationNearPlayer(Player player, int radius) {
    Block playerBlock = player.getLocation().getBlock();
    List<Location> availableLocations = new ArrayList<>();

    World world = player.getWorld();
    for (int x = playerBlock.getX() - radius; x < playerBlock.getX() + radius; x++) {
        for (int y = playerBlock.getY() - radius; y < playerBlock.getY() + radius; y++) {
            for (int z = playerBlock.getZ() - radius; z < playerBlock.getZ() + radius; z++) {
                Location loc = getBlockCenter(new Location(world, x, y, z));
                if (loc.getBlock().isEmpty()) {
                    Block underBlock = loc.clone().subtract(0, 1, 0).getBlock();
                    if (!underBlock.isEmpty() && !underBlock.isLiquid()) {
                        loc.setYaw((float) (-180 + Math.random() * 360));
                        availableLocations.add(loc);
                    }
                }
            }
        }
    }

    if (availableLocations.size() == 0) {
        return getBlockCenter(playerBlock.getLocation().clone());
    }

    return availableLocations.get(new Random().nextInt(availableLocations.size()));
}
 
開發者ID:EndlessCodeGroup,項目名稱:RPGInventory,代碼行數:27,代碼來源:LocationUtils.java

示例4: onStickyPistonRetract

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onStickyPistonRetract(BlockPistonRetractEvent event) {
    if (!event.isSticky())
        return; // If not a sticky piston, retraction should be fine.

    // If potentially retracted block is just AIR/WATER/LAVA, no worries
    Location retractLocation = event.getRetractLocation();
    Block retractBlock = retractLocation.getBlock();
    if (!retractBlock.isEmpty() && !retractBlock.isLiquid()) {
        Block block = event.getBlock();
        Faction targetFaction = plugin.getFactionManager().getFactionAt(retractLocation);
        if (targetFaction instanceof Raidable && !((Raidable) targetFaction).isRaidable() && targetFaction != plugin.getFactionManager().getFactionAt(block)) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:17,代碼來源:ProtectionListener.java

示例5: onDispenserDispense

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventWrapper
public void onDispenserDispense(final BlockDispenseEvent event) {
    if(Materials.isBucket(event.getItem())) {
        // Yes, the location the dispenser is facing is stored in "velocity" for some ungodly reason
        Block targetBlock = event.getVelocity().toLocation(event.getBlock().getWorld()).getBlock();
        Material contents = Materials.materialInBucket(event.getItem());

        if(Materials.isLiquid(contents) || (contents == Material.AIR && targetBlock.isLiquid())) {
            callEvent(event, targetBlock.getState(), BlockStateUtils.cloneWithMaterial(targetBlock, contents), blockResolver.getOwner(event.getBlock()));
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:13,代碼來源:BlockTransformListener.java

示例6: isHoveringOverWater

import org.bukkit.block.Block; //導入方法依賴的package包/類
public static boolean isHoveringOverWater(Location player, int blocks) {
    for (int i = player.getBlockY(); i > player.getBlockY() - blocks; i--) {
        Block newloc = (new Location(player.getWorld(), player.getBlockX(), i, player.getBlockZ())).getBlock();
        if (newloc.getType() != Material.AIR) {
            return newloc.isLiquid();
        }
    }

    return false;
}
 
開發者ID:Notoh,項目名稱:DynamicAC,代碼行數:11,代碼來源:Utilities.java

示例7: onStickyPistonExtend

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onStickyPistonExtend(final BlockPistonExtendEvent event) {
    final Block block = event.getBlock();
    final Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1);
    if (targetBlock.isEmpty() || targetBlock.isLiquid()) {
        final Faction targetFaction = this.plugin.getFactionManager().getFactionAt(targetBlock.getLocation());
        if (targetFaction instanceof Raidable && !((Raidable)targetFaction).isRaidable() && !targetFaction.equals(this.plugin.getFactionManager().getFactionAt(block))) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:12,代碼來源:CoreListener.java

示例8: onStickyPistonExtend

import org.bukkit.block.Block; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onStickyPistonExtend(BlockPistonExtendEvent event) {
    Block block = event.getBlock();

    // Targets end-of-the-line empty (AIR) block which is being pushed into, including if piston itself would extend into air.
    Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1);
    if (targetBlock.isEmpty() || targetBlock.isLiquid()) { // If potentially pushing into AIR/WATER/LAVA in another territory, check it out.
        Faction targetFaction = plugin.getFactionManager().getFactionAt(targetBlock.getLocation());
        if (targetFaction instanceof Raidable && !((Raidable) targetFaction).isRaidable() && targetFaction != plugin.getFactionManager().getFactionAt(block)) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:funkemunky,項目名稱:HCFCore,代碼行數:14,代碼來源:ProtectionListener.java

示例9: isSafeLocation

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Checks if this location is safe for a player to teleport to. Used by
 * warps and boat exits Unsafe is any liquid or air and also if there's no
 * space
 *
 * @param l
 *            - Location to be checked
 * @return true if safe, otherwise false
 */
public static boolean isSafeLocation(final Location l) {
    if (l == null) {
        return false;
    }
    // TODO: improve the safe location finding.
    //Bukkit.getLogger().info("DEBUG: " + l.toString());
    final Block ground = l.getBlock().getRelative(BlockFace.DOWN);
    final Block space1 = l.getBlock();
    final Block space2 = l.getBlock().getRelative(BlockFace.UP);
    //Bukkit.getLogger().info("DEBUG: ground = " + ground.getType());
    //Bukkit.getLogger().info("DEBUG: space 1 = " + space1.getType());
    //Bukkit.getLogger().info("DEBUG: space 2 = " + space2.getType());
    // Portals are not "safe"
    if (space1.getType() == Material.PORTAL || ground.getType() == Material.PORTAL || space2.getType() == Material.PORTAL
            || space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
        return false;
    }
    // If ground is AIR, then this is either not good, or they are on slab,
    // stair, etc.
    if (ground.getType() == Material.AIR) {
        // Bukkit.getLogger().info("DEBUG: air");
        return false;
    }
    // In BSkyBlock, liquid may be unsafe
    if (ground.isLiquid() || space1.isLiquid() || space2.isLiquid()) {
        // Check if acid has no damage
        if (Settings.acidDamage > 0D) {
            // Bukkit.getLogger().info("DEBUG: acid");
            return false;
        } else if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
                || space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
                || space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
            // Lava check only
            // Bukkit.getLogger().info("DEBUG: lava");
            return false;
        }
    }
    MaterialData md = ground.getState().getData();
    if (md instanceof SimpleAttachableMaterialData) {
        //Bukkit.getLogger().info("DEBUG: trapdoor/button/tripwire hook etc.");
        if (md instanceof TrapDoor) {
            TrapDoor trapDoor = (TrapDoor)md;
            if (trapDoor.isOpen()) {
                //Bukkit.getLogger().info("DEBUG: trapdoor open");
                return false;
            }
        } else {
            return false;
        }
        //Bukkit.getLogger().info("DEBUG: trapdoor closed");
    }
    if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().equals(Material.FENCE)
            || ground.getType().equals(Material.NETHER_FENCE) || ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
        // Bukkit.getLogger().info("DEBUG: cactus");
        return false;
    }
    // Check that the space is not solid
    // The isSolid function is not fully accurate (yet) so we have to
    // check
    // a few other items
    // isSolid thinks that PLATEs and SIGNS are solid, but they are not
    if (space1.getType().isSolid() && !space1.getType().equals(Material.SIGN_POST) && !space1.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    if (space2.getType().isSolid()&& !space2.getType().equals(Material.SIGN_POST) && !space2.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    // Safe
    //Bukkit.getLogger().info("DEBUG: safe!");
    return true;
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:81,代碼來源:IslandsManager.java

示例10: isSafeLocation

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Checks if this location is safe for a player to teleport to. Used by
 * warps and boat exits Unsafe is any liquid or air and also if there's no
 * space
 * 
 * @param l
 *            - Location to be checked
 * @return true if safe, otherwise false
 */
public static boolean isSafeLocation(final Location l) {
    if (l == null) {
        return false;
    }
    // TODO: improve the safe location finding.
    //Bukkit.getLogger().info("DEBUG: " + l.toString());
    final Block ground = l.getBlock().getRelative(BlockFace.DOWN);
    final Block space1 = l.getBlock();
    final Block space2 = l.getBlock().getRelative(BlockFace.UP);
    //Bukkit.getLogger().info("DEBUG: ground = " + ground.getType());
    //Bukkit.getLogger().info("DEBUG: space 1 = " + space1.getType());
    //Bukkit.getLogger().info("DEBUG: space 2 = " + space2.getType());
    // Portals are not "safe"
    if (space1.getType() == Material.PORTAL || ground.getType() == Material.PORTAL || space2.getType() == Material.PORTAL
            || space1.getType() == Material.ENDER_PORTAL || ground.getType() == Material.ENDER_PORTAL || space2.getType() == Material.ENDER_PORTAL) {
        return false;
    }
    // If ground is AIR, then this is either not good, or they are on slab,
    // stair, etc.
    if (ground.getType() == Material.AIR) {
        // Bukkit.getLogger().info("DEBUG: air");
        return false;
    }
    // In ASkyBlock, liquid may be unsafe
    if (ground.isLiquid() || space1.isLiquid() || space2.isLiquid()) {
        // Check if acid has no damage
        if (Settings.acidDamage > 0D) {
            // Bukkit.getLogger().info("DEBUG: acid");
            return false;
        } else if (ground.getType().equals(Material.STATIONARY_LAVA) || ground.getType().equals(Material.LAVA)
                || space1.getType().equals(Material.STATIONARY_LAVA) || space1.getType().equals(Material.LAVA)
                || space2.getType().equals(Material.STATIONARY_LAVA) || space2.getType().equals(Material.LAVA)) {
            // Lava check only
            // Bukkit.getLogger().info("DEBUG: lava");
            return false;
        }
    }
    MaterialData md = ground.getState().getData();
    if (md instanceof SimpleAttachableMaterialData) {
        //Bukkit.getLogger().info("DEBUG: trapdoor/button/tripwire hook etc.");
        if (md instanceof TrapDoor) {
            TrapDoor trapDoor = (TrapDoor)md;
            if (trapDoor.isOpen()) {
                //Bukkit.getLogger().info("DEBUG: trapdoor open");
                return false;
            }
        } else {
            return false;
        }
        //Bukkit.getLogger().info("DEBUG: trapdoor closed");
    }
    if (ground.getType().equals(Material.CACTUS) || ground.getType().equals(Material.BOAT) || ground.getType().equals(Material.FENCE)
            || ground.getType().equals(Material.NETHER_FENCE) || ground.getType().equals(Material.SIGN_POST) || ground.getType().equals(Material.WALL_SIGN)) {
        // Bukkit.getLogger().info("DEBUG: cactus");
        return false;
    }
    // Check that the space is not solid
    // The isSolid function is not fully accurate (yet) so we have to
    // check
    // a few other items
    // isSolid thinks that PLATEs and SIGNS are solid, but they are not
    if (space1.getType().isSolid() && !space1.getType().equals(Material.SIGN_POST) && !space1.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    if (space2.getType().isSolid()&& !space2.getType().equals(Material.SIGN_POST) && !space2.getType().equals(Material.WALL_SIGN)) {
        return false;
    }
    // Safe
    //Bukkit.getLogger().info("DEBUG: safe!");
    return true;
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:81,代碼來源:Util.java

示例11: isSafe

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Is the given location 'safe'?
 * @param loc
 * @return safe
 */
private static boolean isSafe(Location loc) {
    Block bk = loc.getBlock();
    Block below = bk.getRelative(BlockFace.DOWN);
    return !isSolid(bk) && !isSolid(bk.getRelative(BlockFace.UP)) && below.getType() != Material.AIR  && !below.isLiquid();
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:11,代碼來源:Utils.java

示例12: canStand

import org.bukkit.block.Block; //導入方法依賴的package包/類
public static boolean canStand(Block block) {
    return !(block.isLiquid() || block.getType() == Material.AIR);
}
 
開發者ID:Notoh,項目名稱:DynamicAC,代碼行數:4,代碼來源:Utilities.java

示例13: isSolid

import org.bukkit.block.Block; //導入方法依賴的package包/類
/**
 * Is this block solid? (Meaning players cannot walk through it)
 * @param bk
 * @return solid
 */
public static boolean isSolid(Block bk) {
    return isSolid(bk.getType()) && !bk.isLiquid();
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:9,代碼來源:Utils.java


注:本文中的org.bukkit.block.Block.isLiquid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。