本文整理汇总了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;
}
示例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;
}
}
示例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()));
}
示例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);
}
}
}
示例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()));
}
}
}
示例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;
}
示例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);
}
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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();
}
示例12: canStand
import org.bukkit.block.Block; //导入方法依赖的package包/类
public static boolean canStand(Block block) {
return !(block.isLiquid() || block.getType() == Material.AIR);
}
示例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();
}