当前位置: 首页>>代码示例>>Java>>正文


Java Location.getBlockZ方法代码示例

本文整理汇总了Java中org.bukkit.Location.getBlockZ方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getBlockZ方法的具体用法?Java Location.getBlockZ怎么用?Java Location.getBlockZ使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.Location的用法示例。


在下文中一共展示了Location.getBlockZ方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPlayerMove

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }
    if (!isWithinBorder(to) && isWithinBorder(from)) {
        final Player player = event.getPlayer();
        player.sendMessage(ChatColor.RED + "You cannot go past the border.");
        event.setTo(from);
        final Entity vehicle = player.getVehicle();
        if (vehicle != null) {
            vehicle.eject();
            vehicle.teleport(from);
            vehicle.setPassenger((Entity)player);
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:20,代码来源:BorderListener.java

示例2: adjustToPos

import org.bukkit.Location; //导入方法依赖的package包/类
private void adjustToPos(final Location to, final WorldBorder worldBorder) {
    final double knockback = worldBorder.getKnockbackDistance();

    final int toBlockX = to.getBlockX();
    if (toBlockX < worldBorder.getMinX()) {
        to.setX(worldBorder.getMinX() + knockback);
    } else if (toBlockX > worldBorder.getMaxX()) {
        to.setX(worldBorder.getMaxX() - knockback);
    }
    final int toBlockZ = to.getBlockZ();
    if (toBlockZ < worldBorder.getMinZ()) {
        to.setZ(worldBorder.getMinZ() + knockback);
    } else if (toBlockZ > worldBorder.getMaxZ()) {
        to.setZ(worldBorder.getMaxZ() - knockback);
    }
}
 
开发者ID:Mystiflow,项目名称:WorldBorder,代码行数:17,代码来源:WorldBorderListener.java

示例3: onPlayerMove

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public final void onPlayerMove(final PlayerMoveEvent event) {
    final Location from = event.getFrom();
    final Location to = event.getTo();
    // If the player didn't move a complete block, ignore.
    if (from.getBlockX() == to.getBlockX()
            && from.getBlockY() == to.getBlockY()
            && from.getBlockZ() == to.getBlockZ()) {
        return;
    }

    final double origX = to.getX();
    final double origZ = to.getZ();
    this.adjustToPos(to, wbHandler.getBorder(to.getWorld()));
    if (Double.compare(origX, to.getX()) != 0
            || Double.compare(origZ, to.getZ()) != 0) {
        event.getPlayer().sendMessage(DENY_ENTRY);
    }
}
 
开发者ID:Mystiflow,项目名称:WorldBorder,代码行数:20,代码来源:WorldBorderListener.java

示例4: calculateUpLocation

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Calculates the upLocation
 *
 * @param corner1 corner1
 * @param corner2 corner2
 */
private void calculateUpLocation(Location corner1, Location corner2) {
    final int x;
    if (corner1.getBlockX() > corner2.getBlockX()) {
        x = corner1.getBlockX();
    } else {
        x = corner2.getBlockX();
    }
    final int y;
    if (corner1.getBlockY() > corner2.getBlockY()) {
        y = corner1.getBlockY();
    } else {
        y = corner2.getBlockY();
    }
    final int z;
    if (corner1.getBlockZ() > corner2.getBlockZ()) {
        z = corner1.getBlockZ();
    } else {
        z = corner2.getBlockZ();
    }
    this.upCorner = new SLocation(new Location(corner1.getWorld(), x, y, z));
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:28,代码来源:SelectedArea.java

示例5: calculateDownLocation

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Calculates the downLocation
 *
 * @param corner1 corner1
 * @param corner2 corner2
 */
private void calculateDownLocation(Location corner1, Location corner2) {
    final int x;
    if (corner1.getBlockX() < corner2.getBlockX()) {
        x = corner1.getBlockX();
    } else {
        x = corner2.getBlockX();
    }
    final int y;
    if (corner1.getBlockY() < corner2.getBlockY()) {
        y = corner1.getBlockY();
    } else {
        y = corner2.getBlockY();
    }
    final int z;
    if (corner1.getBlockZ() < corner2.getBlockZ()) {
        z = corner1.getBlockZ();
    } else {
        z = corner2.getBlockZ();
    }
    this.downCorner = new SLocation(new Location(corner1.getWorld(), x, y, z));
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:28,代码来源:SelectedArea.java

示例6: onChunkChange

import org.bukkit.Location; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler
    public void onChunkChange(PlayerMoveEvent event) {
        Location to = event.getTo();
        Location from = event.getFrom();
        if (to.getBlockX() == from.getBlockX() && to.getBlockZ() == from.getBlockZ()) {
            return;
        }
        Chunk toChunk = to.getChunk();
        Chunk fromChunk = from.getChunk();
        if (toChunk.getX() == fromChunk.getX() && toChunk.getZ() == fromChunk.getZ()) {
            return;
        }
        
		PlayerModule.getInstance().getPlayer(event.getPlayer()).handleViewDistance(); 
		}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:17,代码来源:ChunkChangeEvent.java

示例7: destroyAllDuctsOnIsland

import org.bukkit.Location; //导入方法依赖的package包/类
private void destroyAllDuctsOnIsland(Location islandLoc) {
	int dist = 200;
	final Location min = islandLoc.clone().add(-dist, 0, -dist);
	min.setY(0);
	final Location max = islandLoc.clone().add(dist, 0, dist);
	max.setY(max.getWorld().getMaxHeight());

	com.wasteofplastic.acidisland.ASkyBlockAPI skyblockApi = com.wasteofplastic.acidisland.ASkyBlockAPI.getInstance();

	Location tempLoc = new Location(min.getWorld(), 0, 0, 0);
	for (int x = min.getBlockX(); x < max.getBlockX(); x++) {
		for (int y = min.getBlockY(); y < max.getBlockY(); y++) {
			for (int z = min.getBlockZ(); z < max.getBlockZ(); z++) {
				tempLoc.setX(x);
				tempLoc.setY(y);
				tempLoc.setZ(z);
				if (PipeAPI.isDuct(tempLoc, null) && !skyblockApi.islandAtLocation(tempLoc)) {
					PipeAPI.destroyDuct(tempLoc);
				}
			}
		}
	}
}
 
开发者ID:RoboTricker,项目名称:Transport-Pipes,代码行数:24,代码来源:SkyblockAPIUtils.java

示例8: onIsland

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Checks if a location is within this island's protected area
 *
 * @param target
 * @return true if it is, false if not
 */
public boolean onIsland(Location target) {
    if (center != null && center.getWorld() != null) {
        if (target.getBlockX() >= minProtectedX && target.getBlockX() < (minProtectedX + protectionRange * 2)
                && target.getBlockZ() >= minProtectedZ && target.getBlockZ() < (minProtectedZ + protectionRange * 2)) {
            return true;
        }
    }

    return false;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:17,代码来源:Island.java

示例9: nextGridLocation

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Finds the next free island spot based off the last known island Uses
 * island_distance setting from the config file Builds up in a grid fashion
 *
 * @param lastIsland
 * @return Location of next free island
 */
private Location nextGridLocation(final Location lastIsland) {
    int x = lastIsland.getBlockX();
    int z = lastIsland.getBlockZ();
    Location nextPos = lastIsland;
    if (x < z) {
        if (-1 * x < z) {
            nextPos.setX(nextPos.getX() + Settings.islandDistance*2);
            return nextPos;
        }
        nextPos.setZ(nextPos.getZ() + Settings.islandDistance*2);
        return nextPos;
    }
    if (x > z) {
        if (-1 * x >= z) {
            nextPos.setX(nextPos.getX() - Settings.islandDistance*2);
            return nextPos;
        }
        nextPos.setZ(nextPos.getZ() - Settings.islandDistance*2);
        return nextPos;
    }
    if (x <= 0) {
        nextPos.setZ(nextPos.getZ() + Settings.islandDistance*2);
        return nextPos;
    }
    nextPos.setZ(nextPos.getZ() - Settings.islandDistance*2);
    return nextPos;
}
 
开发者ID:tastybento,项目名称:bskyblock,代码行数:35,代码来源:NewIsland.java

示例10: teleportSpotUp

import org.bukkit.Location; //导入方法依赖的package包/类
public Location teleportSpotUp(Location loc, int min, int max) {
    int k = min;
    while (k < max) {
    	Material m = new Location(loc.getWorld(), loc.getBlockX(), k - 1, loc.getBlockZ()).getBlock().getType();
        Material m1 = new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ()).getBlock().getType();
        Material m2 = new Location(loc.getWorld(), loc.getBlockX(), (k + 1), loc.getBlockZ()).getBlock().getType();
        if (m1.equals(Material.AIR) && m2.equals(Material.AIR) && m.isSolid() && !m.equals(Material.SIGN_POST) && !m.equals(Material.WALL_SIGN)) {
            return new Location(loc.getWorld(), loc.getBlockX(), k, loc.getBlockZ());
        }
        ++k;
    }
    return new Location(loc.getWorld(), loc.getBlockX(), loc.getWorld().getHighestBlockYAt(loc.getBlockX(), loc.getBlockZ()), loc.getBlockZ());
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:ElevatorListener.java

示例11: addSignJoinGame

import org.bukkit.Location; //导入方法依赖的package包/类
public boolean addSignJoinGame(Location loc, String mapName) {
	if (SkyWarsReloaded.getMC().mapRegistered(mapName)) {
		String world = loc.getWorld().getName().toString();
		int x = loc.getBlockX();
		int y = loc.getBlockY();
		int z = loc.getBlockZ();
		GameSign gs = new GameSign(x, y, z, world, mapName);
		gameNumber = -1;
		File signJoinFile = new File(SkyWarsReloaded.get().getDataFolder(), "signJoinGames.yml");
		if (!signJoinFile.exists()) {
			SkyWarsReloaded.get().saveResource("signJoinGames.yml", false);
		}
		if (signJoinFile.exists()) {
			FileConfiguration storage = YamlConfiguration.loadConfiguration(signJoinFile);
			for (int i = 1; i < 1000; i++) {
				if (storage.getString("games." + i + ".map") == null) {
					gameNumber = i;
					break;
				}
			}
			storage.set("games." + gameNumber + ".x", x);
			storage.set("games." + gameNumber + ".y", y);
			storage.set("games." + gameNumber + ".z", z);
			storage.set("games." + gameNumber + ".world", world);
			storage.set("games." + gameNumber + ".map", mapName);
			try {
				storage.save(signJoinFile);
			} catch (IOException e) {
				e.printStackTrace();
			}
			signJoinGames.put(gameNumber, gs);
			createGame(gameNumber, gs);
			return true;
		} else {
			return false;
		}
		}
	return false;
}
 
开发者ID:smessie,项目名称:SkyWarsReloaded,代码行数:40,代码来源:GameController.java

示例12: getNearestSafePosition

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Finds the nearest safe {@link Location} from a given position.
 *
 * @param player
 *            the {@link Player} to find for
 * @param origin
 *            the {@link Location} to begin searching at
 * @param searchRadius
 *            the radius to search for
 * @return the nearest safe {@link Location} from origin
 */
public static Location getNearestSafePosition(Player player, Location origin, int searchRadius) {
    FactionManager factionManager = HCF.getPlugin().getFactionManager();
    Faction playerFaction = factionManager.getPlayerFaction(player.getUniqueId());

    int minX = origin.getBlockX() - searchRadius;
    int maxX = origin.getBlockX() + searchRadius;
    int minZ = origin.getBlockZ() - searchRadius;
    int maxZ = origin.getBlockZ() + searchRadius;

    for (int x = minX; x < maxX; x++) {
        for (int z = minZ; z < maxZ; z++) {
            Location atPos = origin.clone().add(x, 0, z);
            Faction factionAtPos = factionManager.getFactionAt(atPos);
            if (Objects.equal(factionAtPos, playerFaction) || !(factionAtPos instanceof PlayerFaction)) {
                return BukkitUtils.getHighestLocation(atPos, atPos);
            }

            Location atNeg = origin.clone().add(x, 0, z);
            Faction factionAtNeg = factionManager.getFactionAt(atNeg);
            if (Objects.equal(factionAtNeg, playerFaction) || !(factionAtNeg instanceof PlayerFaction)) {
                return BukkitUtils.getHighestLocation(atNeg, atNeg);
            }
        }
    }

    return null;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:39,代码来源:LandMap.java

示例13: onPlayerMove

import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
    Location from = event.getFrom();
    Location to = event.getTo();
    if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }

    Player player = event.getPlayer();
    if (getRemaining(player) > 0L) {
        player.sendMessage(ChatColor.RED + "You moved a block, " + getDisplayName() + ChatColor.RED + " timer cancelled.");
        clearCooldown(player);
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:15,代码来源:LogoutTimer.java

示例14: getEmptyLocation

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location getEmptyLocation(Location location, Predicate<Block> filter) {
    World world = location.getWorld();
    int maxHeight = world.getMaxHeight();
    int x = location.getBlockX();
    int z = location.getBlockZ();
    for (int i = location.getBlockY(); i < maxHeight; i++) {
        Block block = world.getBlockAt(x, i, z);
        if (block.getType() == Material.AIR
                && filter.test(block))
            return new Location(world, x, i, z);
    }

    return location;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:15,代码来源:Locations.java

示例15: format

import org.bukkit.Location; //导入方法依赖的package包/类
public static String format(Location loc, boolean world) {
    return (world ? (loc.getWorld().getName() + ":") : "") + loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:4,代码来源:LocUtil.java


注:本文中的org.bukkit.Location.getBlockZ方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。