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


Java Location.getBlockX方法代码示例

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


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

示例1: run

import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void run() {
    Location location = player.getLocation();

    // Check if the player moved or is AFK.
    double x = location.getBlockX();
    double y = location.getBlockY();
    double z = location.getBlockZ();
    if (this.lastX == x && this.lastY == y && this.lastZ == z) {
        return;
    }

    this.lastX = x;
    this.lastY = y;
    this.lastZ = z;
    this.listener.handlePositionChanged(player, player.getWorld(), (int) x, (int) y, (int) z);
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:WallBorderListener.java

示例2: drawCircle

import org.bukkit.Location; //导入方法依赖的package包/类
public List<Location> drawCircle(Location loc, Integer radius, Integer height, Boolean hollow, Boolean sphere,
		int plus_y) {
	List<Location> circleblocks = new ArrayList<Location>();
	Integer r = radius;
	Integer h = height;
	int cx = loc.getBlockX();
	int cy = loc.getBlockY();
	int cz = loc.getBlockZ();
	for (int x = cx - r.intValue(); x <= cx + r.intValue(); x++) {
		for (int z = cz - r.intValue(); z <= cz + r.intValue(); z++) {
			for (int y = sphere.booleanValue() ? cy - r.intValue() : cy; y < (sphere.booleanValue()
					? cy + r.intValue() : cy + h.intValue()); y++) {
				double dist = (cx - x) * (cx - x) + (cz - z) * (cz - z)
						+ (sphere.booleanValue() ? (cy - y) * (cy - y) : 0);
				if ((dist < r.intValue() * r.intValue())
						&& ((!hollow.booleanValue()) || (dist >= (r.intValue() - 1) * (r.intValue() - 1)))) {
					Location l = new Location(loc.getWorld(), x, y + plus_y, z);
					circleblocks.add(l);
				}
			}
		}
	}
	return circleblocks;
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:25,代码来源:Utils.java

示例3: 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

示例4: 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

示例5: teleportSpotDown

import org.bukkit.Location; //导入方法依赖的package包/类
public Location teleportSpotDown(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

示例6: 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

示例7: surrendPlayer

import org.bukkit.Location; //导入方法依赖的package包/类
public static void surrendPlayer(Player player){
       YamlConfiguration PlayerData = PVPAsWantedManager.onLoadData(player.getName());
       int value = PlayerData.getInt("jail.times");
	int times = PlayerData.getInt("wanted.points")*Integer.valueOf(Config.getConfig("timeTick.jailPlayerTimes").replace("min", "").replace("m", ""));
	if(value > 0){
		player.sendMessage(Message.getMsg("player.isAlreadyInJailMessage"));
		return;
	}
	if(times <1){
		player.sendMessage(Message.getMsg("player.notSurrendMessage"));
		return;
	}
	Location location = player.getLocation();
       int playerX = location.getBlockX();
       int playerY = location.getBlockY();
       int playerZ = location.getBlockZ();
       String playerWorld = location.getWorld().getName();
       PlayerData.set("attribute.X", playerX);
       PlayerData.set("attribute.Y", playerY);
       PlayerData.set("attribute.Z", playerZ);
       PlayerData.set("attribute.World", playerWorld);
       PlayerData.set("wanted.points", Integer.valueOf(0));
       PlayerData.set("jail.times", times);
       PVPAsWantedManager.onDeleteList(player.getName(), "WantedList");
       PVPAsWantedManager.onCreateList(player.getName(), "JailedList");
       PVPAsWantedManager.onSaveData(player.getName(), PlayerData);
	JailManager.playerJoinJail(player,location);
	player.sendMessage(Message.getMsg("player.surrendMessage",String.valueOf(times)));
}
 
开发者ID:Saukiya,项目名称:PVPAsWantedManager,代码行数:30,代码来源:JailManager.java

示例8: applyTextureToSkull

import org.bukkit.Location; //导入方法依赖的package包/类
public static void applyTextureToSkull(Skull skull, Object profile) throws Exception {
    Location location = skull.getLocation();
    int x = location.getBlockX();
    int y = location.getBlockY();
    int z = location.getBlockZ();
    Object world = Minecraft.getHandle(location.getWorld());
    Object tileEntity = WorldServerMethodResolver.resolve("getTileEntity").invoke(world, x, y, z);
    TileEntitySkullFieldResolver.resolveByFirstType(GameProfile).set(tileEntity, profile);
    WorldMethodResolver.resolve(new ResolverQuery("notify", int.class, int.class, int.class)).invoke(world, x, y, z);
}
 
开发者ID:VoxelGamesLib,项目名称:VoxelGamesLibv2,代码行数:11,代码来源:HeadTextureChanger.java

示例9: spawnFallingBlock

import org.bukkit.Location; //导入方法依赖的package包/类
public FallingBlock spawnFallingBlock(Location location, org.bukkit.Material material, byte data) throws IllegalArgumentException {
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(material, "Material cannot be null");
    Validate.isTrue(material.isBlock(), "Material must be a block");

    double x = location.getBlockX() + 0.5;
    double y = location.getBlockY() + 0.5;
    double z = location.getBlockZ() + 0.5;

    net.minecraft.entity.item.EntityFallingBlock entity = new net.minecraft.entity.item.EntityFallingBlock(world, x, y, z, net.minecraft.block.Block.getBlockById(material.getId()), data);
    entity.field_145812_b = 1; // ticksLived

    world.addEntity(entity, SpawnReason.CUSTOM);
    return (FallingBlock) entity.getBukkitEntity();
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:16,代码来源:CraftWorld.java

示例10: 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();
    // Player didn't move a block.
    if (from.getBlockX() == to.getBlockX() && from.getBlockY() == to.getBlockY() && from.getBlockZ() == to.getBlockZ()) {
        return;
    }

    cancelTeleport(event.getPlayer(), ChatColor.YELLOW + "You moved a block, therefore cancelling your teleport.");
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:12,代码来源:TeleportTimer.java

示例11: getTopLocation

import org.bukkit.Location; //导入方法依赖的package包/类
public static Location getTopLocation(Location location) {
    World world = location.getWorld();
    int height = world.getMaxHeight();
    int x = location.getBlockX();
    int z = location.getBlockZ();
    for (int i = height; i >= 0; i--) {
        Block block = world.getBlockAt(x, i, z);
        if (block.getType().isSolid())
            return new Location(world, x, i + 1, z);
    }

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

示例12: 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

示例13: locationToString

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * Util method to convert a Location to a String. This method can be useful
 * when working with config files.
 * 
 * @param location
 *            The location to convert into string. It can either contain yaw
 *            and pitch or not.
 *            <p>
 * @return The input Location in string format.
 */
public static String locationToString(Location location) {
	String w = location.getWorld().getName();
	double x = location.getBlockX();
	double y = location.getBlockY();
	double z = location.getBlockZ();

	if ((location.getYaw() == 0.0F) && (location.getPitch() == 0.0F))
		return w + "," + x + "," + y + "," + z;

	float yaw = location.getYaw();
	float pitch = location.getPitch();
	return w + "," + x + "," + y + "," + z + "," + yaw + "," + pitch;
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:24,代码来源:StringUtilities.java

示例14: inMineLocation

import org.bukkit.Location; //导入方法依赖的package包/类
public static boolean inMineLocation(Location loc) {
    int x = loc.getBlockX();
    int y = loc.getBlockY();
    int z = loc.getBlockZ();
    return (x >= 1347 && x <= 1383 && y >= 0 && y <= 25 && z <= 362 && z >= 338);
}
 
开发者ID:Warvale,项目名称:Locked,代码行数:7,代码来源:BlockListener.java

示例15: locationToDbString

import org.bukkit.Location; //导入方法依赖的package包/类
public String locationToDbString(Location loc) {
	return loc.getBlockX() + "-" + loc.getBlockY() + "-" + loc.getBlockZ() + "-" + loc.getPitch() + "-"
			+ loc.getYaw() + "-" + loc.getWorld().getName();
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:5,代码来源:Utils.java


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