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


Java ServerPlayerPositionRotationPacket类代码示例

本文整理汇总了Java中org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket的典型用法代码示例。如果您正苦于以下问题:Java ServerPlayerPositionRotationPacket类的具体用法?Java ServerPlayerPositionRotationPacket怎么用?Java ServerPlayerPositionRotationPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ServerPlayerPositionRotationPacket类属于org.spacehq.mc.protocol.packet.ingame.server.entity.player包,在下文中一共展示了ServerPlayerPositionRotationPacket类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateLocation

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
/**
 * Update a location with the movement data in the specified packet.
 * @param loc The location
 * @param packet The packet
 * @return The new location
 */
public static Location updateLocation(Location loc, ServerPlayerPositionRotationPacket packet) {
    if (loc == null) {
        loc = Location.NULL;
    }
    double x = loc.getX();
    double y = loc.getY();
    double z = loc.getZ();
    float yaw = loc.getYaw();
    float pitch = loc.getPitch();

    List<PositionElement> relative = packet.getRelativeElements();
    x = (relative.contains(PositionElement.X) ? x : 0) + packet.getX();
    y = (relative.contains(PositionElement.Y) ? y : 0) + packet.getY();
    z = (relative.contains(PositionElement.Z) ? z : 0) + packet.getZ();
    yaw = (relative.contains(PositionElement.YAW) ? yaw : 0) + packet.getYaw();
    pitch = (relative.contains(PositionElement.PITCH) ? pitch : 0) + packet.getPitch();

    return new Location(x, y, z, yaw, pitch);
}
 
开发者ID:ReplayMod,项目名称:ReplayStudio,代码行数:26,代码来源:PacketUtils.java

示例2: setWorld

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
@Override
public void setWorld(World world) {
	super.setWorld(world);

	synchronized (this) {
		if (world == null) {
			return;
		}

		WorldDimension newDim = world.getDimension();
		if (newDim == this.clientDimension) {
			newDim = newDim.next();

			session.send(new ServerRespawnPacket(newDim.toInt(), Difficulty.PEACEFUL, GameMode.CREATIVE,
					WorldType.DEFAULT));
		}

		for (Iterator<Column> i = this.loadedColumns.iterator(); i.hasNext();) {
			i.next();
			i.remove();
		}

		for (Iterator<ServerEntity> i = this.loadedEntities.iterator(); i.hasNext();) {
			i.next();
			i.remove();
		}

		session.send(new ServerRespawnPacket(this.world.getDimension().toInt(), Difficulty.PEACEFUL,
				GameMode.CREATIVE, WorldType.DEFAULT));

		session.send(new ServerPlayerPositionRotationPacket(this.x, this.y, this.z, (float) this.yaw,
				(float) this.pitch, 0));
	}
}
 
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:35,代码来源:ServerPlayer.java

示例3: onLogin

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
public void onLogin(Session session) {
	ServerPlayer newPlayer = new ServerPlayer(session);
	MainMain.players.put(session, newPlayer);
	newPlayer.setWorld(MainMain.defaultWorld);
	session.send(new ServerJoinGamePacket((int) newPlayer.getUEID(), false, GameMode.CREATIVE,
			newPlayer.getWorld().getDimension().toInt(), Difficulty.PEACEFUL, 10, WorldType.DEFAULT, false));

	List<PlayerListEntry> playerList = new ArrayList<PlayerListEntry>();

	MainMain.players.forEach((otherPlayer) -> {
		playerList.add(new PlayerListEntry(otherPlayer.getProfile(), GameMode.CREATIVE, 1,
				new TextMessage(otherPlayer.getName())));
	});

	PlayerListEntry[] playerListPck = new PlayerListEntry[playerList.size()];
	playerList.toArray(playerListPck);

	session.send(new ServerPlayerListEntryPacket(PlayerListEntryAction.ADD_PLAYER, playerListPck));
	MainMain.players.forEach((otherPlayer) -> {
		if (otherPlayer == newPlayer)
			return;
		PlayerListEntry[] newPlayerListing = new PlayerListEntry[1];

		newPlayerListing[0] = new PlayerListEntry(newPlayer.getProfile(), GameMode.CREATIVE, 1,
				new TextMessage(newPlayer.getName()));

		otherPlayer.sendPacket(new ServerPlayerListEntryPacket(PlayerListEntryAction.ADD_PLAYER, newPlayerListing));
	});
	session.send(new ServerPlayerPositionRotationPacket(0, 120, 0, 0, 0, 0));
	MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
	if (protocol.getSubProtocol() == SubProtocol.GAME) {
		GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
		logger.info(profile.getName() + " has joined the game");
		MainMain.server.getSessions()
				.forEach((sessions) -> sessions
						.send(new ServerChatPacket(new TextMessage(profile.getName() + " has joined the game")
								.setStyle(new MessageStyle().setColor(ChatColor.YELLOW)))));
	}
}
 
开发者ID:MineGuard-dev,项目名称:TestServer_Java,代码行数:40,代码来源:LoginHandler.java

示例4: onLogin

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
public void onLogin(Session session) {
	NetherPlayer newPlayer = new NetherPlayer(session);

	NetherServer.players.put(session, newPlayer);

	// spawn the player in the world
	newPlayer.setWorld(NetherServer.defaultWorld);

	// send the join game packet
	session.send(new ServerJoinGamePacket((int) newPlayer.getUEID(),
			false, // Hardcore
			GameMode.CREATIVE, // Player gamemode
			newPlayer.getWorld().getDimension().toInt(), // Dimension (-1, 0, 1)
			Difficulty.PEACEFUL, // Difficulty
			10, // Max players
			WorldType.DEFAULT, 
			false // Less debug info
	));
       
       // Send the logging in player the player list
       
       List<PlayerListEntry> playerList = new ArrayList<PlayerListEntry>();
       
       NetherServer.players.forEach((otherPlayer) -> {
           playerList.add(new PlayerListEntry(
                           otherPlayer.getProfile(),
                           GameMode.CREATIVE,        //TODO: game mode
                           1,                        //TODO: ping
                           new TextMessage(otherPlayer.getName())
           ));
       });
       
       PlayerListEntry[] playerListPck = new PlayerListEntry[playerList.size()];
       playerList.toArray(playerListPck);
       
       session.send(new ServerPlayerListEntryPacket(
           PlayerListEntryAction.ADD_PLAYER,
           playerListPck
       ));
       
       // Send the other players the new player listing.
       
       NetherServer.players.forEach((otherPlayer) -> {
           if(otherPlayer == newPlayer) return;
           
           PlayerListEntry[] newPlayerListing = new PlayerListEntry[1];
           
           newPlayerListing[0] = new PlayerListEntry(newPlayer.getProfile(), GameMode.CREATIVE, 1, new TextMessage(newPlayer.getName()));
           
           otherPlayer.sendPacket(new ServerPlayerListEntryPacket(PlayerListEntryAction.ADD_PLAYER, newPlayerListing));
       });

	// send the player position packet to get the player to spawn
	session.send(new ServerPlayerPositionRotationPacket(0, 81.62, 0, 0, 0, 0));

	// send a message to the console and to all players that a new person
	// has joined the game
	MinecraftProtocol protocol = (MinecraftProtocol) session.getPacketProtocol();
	if (protocol.getSubProtocol() == SubProtocol.GAME) {
		GameProfile profile = session.getFlag(MinecraftConstants.PROFILE_KEY);
		logger.info(profile.getName() + " has joined the game");
		NetherServer.server.getSessions()
				.forEach((sessions) -> sessions
						.send(new ServerChatPacket(new TextMessage(profile.getName() + " has joined the game")
								.setStyle(new MessageStyle().setColor(ChatColor.YELLOW)))));
	}
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:68,代码来源:LoginHandler.java

示例5: setWorld

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
@Override
public void setWorld(World world) {
	super.setWorld(world);
       
       synchronized(this){
           //TODO: what to tell the client when the world is null.
           if(world == null){
               return;
           }
           
           WorldDimension newDim = world.getDimension();
           
           // Make sure we don't send the same dimension twice in a row.
           if(newDim == this.clientDimension){
               newDim = newDim.next();
               
               session.send(new ServerRespawnPacket(newDim.toInt(), Difficulty.PEACEFUL, GameMode.CREATIVE, WorldType.DEFAULT));
           }
           
           // Columns and Entities are automatically unloaded by the client.
           
           for(Iterator<Column> i = this.loadedColumns.iterator(); i.hasNext(); ){
               i.next();
               i.remove();
           }
           
           for(Iterator<NetherEntity> i = this.loadedEntities.iterator(); i.hasNext(); ){
               i.next();
               i.remove();
           }
           
           session.send(new ServerRespawnPacket(this.world.getDimension().toInt(),
                                                Difficulty.PEACEFUL,
                                                GameMode.CREATIVE,
                                                WorldType.DEFAULT));
           
           session.send(new ServerPlayerPositionRotationPacket(this.x,
                                                               this.y,
                                                               this.z,
                                                               (float) this.yaw,
                                                               (float) this.pitch,
                                                               0)); //TODO: teleport id.
       }
}
 
开发者ID:netherrack,项目名称:netherrack,代码行数:45,代码来源:NetherPlayer.java

示例6: handle

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
@Override
public void handle(ServerPlayerPositionRotationPacket packet) {
    boolean xRelative = false, yRelative = false, zRelative = false, pitchRelative = false, yawRelative = false;
    for(PositionElement pe : packet.getRelativeElements()) {
        if(pe == PositionElement.X) {
            xRelative = true;
        } else if(pe == PositionElement.Y) {
            yRelative = true;
        } else if(pe == PositionElement.Z) {
            zRelative = true;
        } else if(pe == PositionElement.PITCH) {
            pitchRelative = true;
        } else if(pe == PositionElement.YAW) {
            yawRelative = true;
        }
    }

    float x = game.getPlayer().getPosition().getX();
    float y = game.getPlayer().getPosition().getY();
    float z = game.getPlayer().getPosition().getZ();

    if(xRelative) {
        x += packet.getX();
    } else {
        x = (float)packet.getX();
    }

    if(yRelative) {
        y += packet.getY();
    } else {
        y = (float) packet.getY() - 2;
    }

    if(zRelative) {
        z += packet.getZ();
    } else {
        z = (float) packet.getZ();
    }

    float pitch = game.getPlayer().getRotation().getPitch();
    float yaw = game.getPlayer().getRotation().getYaw();

    if(pitchRelative) {
        pitch += packet.getPitch();
    } else {
        pitch = packet.getPitch();
    }

    if(yawRelative) {
        yaw += packet.getYaw();
    } else {
        yaw = packet.getYaw();
    }

    game.getPlayer().getPosition().set(x, y, z);
    game.getPlayer().getRotation().setRot(-pitch, 180 - yaw);

    game.getGameRenderer().calculateFrustum();
    Gdx.graphics.requestRendering();

    game.getMinecraftConn().getClient().getSession()
            .send(new ClientTeleportConfirmPacket(packet.getTeleportId()));
}
 
开发者ID:mstojcevich,项目名称:Radix,代码行数:64,代码来源:PlayerPositionHandler.java

示例7: loginPlayer

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
public synchronized Player loginPlayer(Session session) {
    GameProfile profile = session.getFlag(ProtocolConstants.PROFILE_KEY);
    World world = server.getWorldManager().getWorld("world");
    Location location = world.getSpawnLocation();
    CyanPlayer player = new CyanPlayer(server, profile, location);
    player.setPlayerNetwork(new CyanPlayerNetwork(server, session, player));
    // world.getPlayerService().readPlayer(player);
    player.loadData();

    // player.load();
    ServerJoinGamePacket packet = new ServerJoinGamePacket(player.getEntityID(), world.isHardcore(), player.getGameMode(), world.getDimension().getId(), world.getDifficulty(), server.getMaxPlayers(), WorldType.DEFAULT, false);
    session.send(packet);
    players.add(player);

    // Send spawn packet
    ServerPlayerPositionRotationPacket ppacket = new ServerPlayerPositionRotationPacket(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ(), player.getLocation().getYaw(), player.getLocation().getPitch());
    session.send(ppacket);

    Position position = new Position(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ());
    ServerSpawnPositionPacket spawnPacket = new ServerSpawnPositionPacket(position);
    session.send(spawnPacket);

    // set time
    player.setTime(0);// TODO

    // Send health
    ServerUpdateHealthPacket healthPacket = new ServerUpdateHealthPacket(20, 20, 1);
    session.send(healthPacket);

    // Send Difficulty
    ServerDifficultyPacket diffPacket = new ServerDifficultyPacket(Difficulty.NORMAL);
    session.send(diffPacket);
    world.getPlayerService().savePlayer(player);

    // Send packets for all players
    for (Packet packets : player.getSpawnPackets()) {
        server.getNetworkServer().sendPacketForAll(packets);
    }

    player.chat("Hello! This test message for CyanWool!");
    player.setMoveable(true);

    // Test sounds
    player.damage(5);
    return player;
}
 
开发者ID:BeYkeRYkt,项目名称:CyanWool,代码行数:47,代码来源:PlayerManager.java

示例8: toServerPlayerPositionRotationPacket

import org.spacehq.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; //导入依赖的package包/类
/**
 * Creates a new ServerPlayerPositionRotationPacket from the specified location.
 * @param loc The location
 * @return The packet
 */
public static ServerPlayerPositionRotationPacket toServerPlayerPositionRotationPacket(Location loc) {
    return new ServerPlayerPositionRotationPacket(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
}
 
开发者ID:ReplayMod,项目名称:ReplayStudio,代码行数:9,代码来源:PacketUtils.java


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