本文整理了Java中org.bukkit.block.Block.isLiquid()
方法的一些代码示例,展示了Block.isLiquid()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.isLiquid()
方法的具体详情如下:
包路径:org.bukkit.block.Block
类名称:Block
方法名:isLiquid
[英]Checks if this block is liquid.
A block is considered liquid when #getType() returns Material#WATER, Material#STATIONARY_WATER, Material#LAVA or Material#STATIONARY_LAVA.
[中]检查此块是否为液体。
当#getType()返回材质#水、材质#静止#水、材质#熔岩或材质#静止#熔岩时,块被视为液体。
代码示例来源:origin: GlowstoneMC/Glowstone
@Override
public boolean canSpawn(World world, int x, int z) {
Block block = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
return !block.isLiquid() && !block.isEmpty() && !noSpawnFloors.contains(block.getType());
}
代码示例来源:origin: GlowstoneMC/Glowstone
protected void jump() {
if (location.getBlock().isLiquid()) {
// jump out more when you breach the surface of the liquid
if (location.getBlock().getRelative(BlockFace.UP).isEmpty()) {
velocity.setY(velocity.getY() + 0.3);
}
// less jumping in liquid
velocity.setY(velocity.getY() + 0.04);
} else {
// jump normally
velocity.setY(velocity.getY() + 0.42);
}
}
代码示例来源:origin: GlowstoneMC/Glowstone
if (!isOnGround() || location.getBlock().isLiquid()) {
代码示例来源:origin: GlowstoneMC/Glowstone
private boolean canPlace(byte[] lakeMap, World world, int sourceX, int sourceY, int sourceZ) {
for (int x = 0; x < MAX_DIAMETER; x++) {
for (int z = 0; z < MAX_DIAMETER; z++) {
for (int y = 0; y < MAX_HEIGHT; y++) {
if (isLakeBlock(lakeMap, x, y, z)
|| (((x >= (MAX_DIAMETER - 1)) || !isLakeBlock(lakeMap, x + 1, y, z))
&& ((x <= 0) || !isLakeBlock(lakeMap, x - 1, y, z))
&& ((z >= (MAX_DIAMETER - 1)) || !isLakeBlock(lakeMap, x, y,
z + 1))
&& ((z <= 0) || !isLakeBlock(lakeMap, x, y, z - 1))
&& ((z >= (MAX_HEIGHT - 1)) || !isLakeBlock(lakeMap, x, y + 1, z))
&& ((z <= 0) || !isLakeBlock(lakeMap, x, y - 1, z)))) {
continue;
}
Block block = world.getBlockAt(sourceX + x, sourceY + y, sourceZ + z);
if (y >= MAX_HEIGHT / 2 && (block.isLiquid()
|| block.getType() == Material.ICE)) {
return false; // there's already some liquids above
} else if (y < MAX_HEIGHT / 2 && !block.getType().isSolid()
&& block.getType() != type) {
return false;
// bottom must be solid and do not overlap with another liquid type
}
}
}
}
return true;
}
代码示例来源:origin: bergerkiller/BKCommonLib
@Override
public boolean isLiquid() {
return base.isLiquid();
}
代码示例来源:origin: mcMMO-Dev/mcMMO
public boolean exploitPrevention(BoundingBox boundingBox) {
Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100);
if (!targetBlock.isLiquid()) {
return false;
}
long currentTime = System.currentTimeMillis();
boolean hasFished = (currentTime < fishingTimestamp + (FISHING_COOLDOWN_SECONDS * 10));
if(hasFished)
fishingTimestamp = currentTime;
boolean sameTarget = (lastFishingBoundingBox != null && lastFishingBoundingBox.overlaps(boundingBox));
lastFishingBoundingBox = boundingBox;
return hasFished || sameTarget;
}
代码示例来源:origin: ProjectKorra/ProjectKorra
public static void revertAirBlock(final int i, final boolean force) {
if (!TEMP_AIR_LOCATIONS.containsKey(i)) {
return;
}
final Information info = TEMP_AIR_LOCATIONS.get(i);
final Block block = info.getState().getBlock();
if (block.getType() != Material.AIR && !block.isLiquid()) {
if (force || !MOVED_EARTH.containsKey(block)) {
TEMP_AIR_LOCATIONS.remove(i);
} else {
info.setTime(info.getTime() + 10000);
}
return;
} else {
info.getState().update(true);
TEMP_AIR_LOCATIONS.remove(i);
}
}
代码示例来源:origin: ProjectKorra/ProjectKorra
private Block getGround() {
final Block standingblock = this.player.getLocation().getBlock();
for (int i = 0; i <= this.height + 5; i++) {
final Block block = standingblock.getRelative(BlockFace.DOWN, i);
if (GeneralMethods.isSolid(block) || block.isLiquid()) {
return block;
}
}
return null;
}
代码示例来源:origin: ProjectKorra/ProjectKorra
private void getFloor() {
this.floorblock = null;
for (int i = 0; i <= this.maxHeightFromGround; i++) {
final Block block = this.player.getEyeLocation().getBlock().getRelative(BlockFace.DOWN, i);
if (GeneralMethods.isSolid(block) || block.isLiquid()) {
this.floorblock = block;
return;
}
}
}
代码示例来源:origin: ProjectKorra/ProjectKorra
@Override
public void progress() {
if (System.currentTimeMillis() - this.time >= this.interval) {
this.time = System.currentTimeMillis();
final Block block = this.location.getBlock();
this.location = this.location.add(this.direction);
if (!block.isLiquid()) {
this.moveEarth(block, this.direction, this.distance);
}
this.loadAffectedBlocks();
if (this.location.distanceSquared(this.origin) >= this.distance * this.distance) {
this.remove();
return;
}
}
}
代码示例来源:origin: gvlfm78/BukkitOldCombatMechanics
/**
* Check preconditions for critical hit
* @param p Player to perform checks on
* @return Whether hit is critical
*/
public static boolean isCriticalHit(Player p){
return !p.isOnGround() && p.getFallDistance() > 0 &&
!p.getLocation().getBlock().isLiquid() &&
!p.isInsideVehicle() && !p.isSprinting() &&
p.getActivePotionEffects().stream().noneMatch(pe -> pe.getType() == PotionEffectType.BLINDNESS);
}
}
代码示例来源:origin: ProjectKorra/ProjectKorra
public static void setOrigin(final Player player) {
final Location location = GeneralMethods.getTargetedLocation(player, getSelectRange(), getTransparentMaterials());
if (location.getBlock().isLiquid() || GeneralMethods.isSolid(location.getBlock())) {
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBlast", location)) {
return;
}
ORIGINS.put(player, location);
}
代码示例来源:origin: ProjectKorra/ProjectKorra
public WaterReturn(final Player player, final Block block) {
super(player);
if (hasAbility(player, WaterReturn.class)) {
return;
}
this.location = block.getLocation();
this.range = 30;
this.interval = 50;
this.range = this.getNightFactor(this.range);
if (this.bPlayer.canBendIgnoreBindsCooldowns(this)) {
if (isTransparent(player, block) && ((TempBlock.isTempBlock(block) && block.isLiquid()) || !block.isLiquid()) && this.hasEmptyWaterBottle()) {
this.block = new TempBlock(block, Material.WATER, (byte) 0);
}
}
this.start();
}
代码示例来源:origin: ProjectKorra/ProjectKorra
public static void setOrigin(final Player player) {
final Material[] ignore = new Material[getTransparentMaterials().length + doorTypes.length];
for (int i = 0; i < ignore.length; i++) {
if (i < getTransparentMaterials().length) {
ignore[i] = getTransparentMaterials()[i];
} else {
ignore[i] = doorTypes[i - getTransparentMaterials().length];
}
}
final Location location = GeneralMethods.getTargetedLocation(player, getSelectRange(), ignore);
if (location.getBlock().isLiquid() || GeneralMethods.isSolid(location.getBlock())) {
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, "AirSuction", location)) {
return;
} else {
ORIGINS.put(player, location);
}
}
代码示例来源:origin: ProjectKorra/ProjectKorra
@Override
public void progress() {
if (this.player.getEyeLocation().getBlock().isLiquid() || !this.player.isSneaking() || !this.bPlayer.canBend(this)) {
this.bPlayer.addCooldown(this);
this.remove();
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, this.origin)) {
this.remove();
return;
} else if (this.duration != 0) {
if (this.getStartTime() + this.duration <= System.currentTimeMillis()) {
this.bPlayer.addCooldown(this);
this.remove();
return;
}
}
this.rotateTornado();
}
代码示例来源:origin: ProjectKorra/ProjectKorra
public FireBlast(final Location location, final Vector direction, final Player player, final int damage, final List<Block> safeBlocks) {
super(player);
if (location.getBlock().isLiquid()) {
return;
}
this.setFields();
this.safeBlocks = safeBlocks;
this.damage = damage;
this.location = location.clone();
this.origin = location.clone();
this.direction = direction.clone().normalize();
this.range = this.getDayFactor(this.range);
this.damage = this.getDayFactor(damage);
this.start();
}
代码示例来源:origin: ProjectKorra/ProjectKorra
private void initializeLocations() {
Location location = this.origin.clone();
this.locations.add(location);
while (location.distanceSquared(this.origin) < this.range * this.range) {
location = location.clone().add(this.direction);
for (final int i : new int[] { 1, 2, 3, 0, -1 }) {
Location loc;
loc = location.clone().add(0, i, 0);
final Block topblock = loc.getBlock();
final Block botblock = loc.clone().add(0, -1, 0).getBlock();
if (this.isTransparent(topblock) && !topblock.isLiquid() && this.isEarthbendable(botblock) && botblock.getType() != Material.STATIONARY_LAVA) {
location = loc.clone().add(0, -1, 0);
this.locations.add(location);
break;
} else if (i == -1) {
return;
}
}
}
}
代码示例来源:origin: ProjectKorra/ProjectKorra
public FireBlast(final Player player) {
super(player);
if (this.bPlayer.isOnCooldown("FireBlast")) {
return;
} else if (player.getEyeLocation().getBlock().isLiquid() || FireBlastCharged.isCharging(player)) {
return;
}
this.setFields();
this.isFireBurst = false;
this.damage = this.getDayFactor(getConfig().getDouble("Abilities.Fire.FireBlast.Damage"));
this.safeBlocks = new ArrayList<>();
this.range = this.getDayFactor(this.range);
this.location = player.getEyeLocation();
this.origin = player.getEyeLocation();
this.direction = player.getEyeLocation().getDirection().normalize();
this.location = this.location.add(this.direction.clone());
this.start();
this.bPlayer.addCooldown("FireBlast", this.cooldown);
}
代码示例来源:origin: ProSavage/SavageFactions
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPistonExtend(BlockPistonExtendEvent event) {
if (!Conf.pistonProtectionThroughDenyBuild) {
return;
}
Faction pistonFaction = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
// target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air
Block targetBlock = event.getBlock().getRelative(event.getDirection(), event.getLength() + 1);
// if potentially pushing into air/water/lava in another territory, we need to check it out
if ((targetBlock.isEmpty() || targetBlock.isLiquid()) && !canPistonMoveBlock(pistonFaction, targetBlock.getLocation())) {
event.setCancelled(true);
}
/*
* note that I originally was testing the territory of each affected block, but since I found that pistons can only push
* up to 12 blocks and the width of any territory is 16 blocks, it should be safe (and much more lightweight) to test
* only the final target block as done above
*/
}
代码示例来源:origin: ProSavage/SavageFactions
@EventHandler (priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockFromTo(BlockFromToEvent event) {
if (!Conf.handleExploitLiquidFlow) {
return;
}
if (event.getBlock().isLiquid()) {
if (event.getToBlock().isEmpty()) {
Faction from = Board.getInstance().getFactionAt(new FLocation(event.getBlock()));
Faction to = Board.getInstance().getFactionAt(new FLocation(event.getToBlock()));
if (from == to) {
// not concerned with inter-faction events
return;
}
// from faction != to faction
if (to.isNormal()) {
if (from.isNormal() && from.getRelationTo(to).isAlly()) {
return;
}
event.setCancelled(true);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!