本文整理匯總了Java中cn.nukkit.Player.getZ方法的典型用法代碼示例。如果您正苦於以下問題:Java Player.getZ方法的具體用法?Java Player.getZ怎麽用?Java Player.getZ使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cn.nukkit.Player
的用法示例。
在下文中一共展示了Player.getZ方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addBossBar
import cn.nukkit.Player; //導入方法依賴的package包/類
/**
* @param players ServerPlayers
* @param title Text
* @return EntityId
*/
public static long addBossBar(Map<UUID, Player> players, String title) {
if (players.isEmpty()) return 1L;
long eid = Entity.entityCount++;
AddEntityPacket pk = new AddEntityPacket();
pk.entityRuntimeId = pk.entityUniqueId = eid;
pk.type = 52;
pk.yaw = 0;
pk.pitch = 0;
EntityMetadata metadata = new EntityMetadata()
.putLong(Entity.DATA_LEAD_HOLDER_EID, -1)
.putLong(Entity.DATA_FLAGS, 0 ^ 1 << Entity.DATA_FLAG_SILENT ^ 1 << Entity.DATA_FLAG_INVISIBLE ^ 1 << Entity.DATA_FLAG_NO_AI)
.putFloat(Entity.DATA_SCALE, 0)
.putString(Entity.DATA_NAMETAG, title)
.putString(Entity.DATA_TYPE_STRING, title)
.putFloat(Entity.DATA_BOUNDING_BOX_WIDTH, 0)
.putFloat(Entity.DATA_BOUNDING_BOX_HEIGHT, 0);
pk.speedX = 0;
pk.speedY = 0;
pk.speedZ = 0;
pk.metadata = metadata;
AddEntityPacket pkp;
Player player;
for (Map.Entry<UUID, Player> entry : players.entrySet()) {
player = entry.getValue();
pkp = (AddEntityPacket) pk.clone();
pkp.x = (float) player.getX();
pkp.y = (float) player.getY() - 28;
pkp.z = (float) player.getZ();
player.dataPacket(pkp);
pkp.clean();
pkp = null;
}
BossEventPacket bpk = new BossEventPacket(); // This updates the bar
bpk.eid = eid;
bpk.type = 0;
Server.broadcastPacket(players.values(), bpk);
return eid;
}
示例2: sendBossBarToPlayer
import cn.nukkit.Player; //導入方法依賴的package包/類
/**
* @param player Who Player
* @param eid EntityId
* @param title Text
*/
public static void sendBossBarToPlayer(Player player, long eid, String title) {
AddEntityPacket packet = new AddEntityPacket();
packet.entityRuntimeId = packet.entityUniqueId = eid;
packet.type = 52;
packet.yaw = 0;
packet.pitch = 0;
EntityMetadata metadata = new EntityMetadata()
.putLong(Entity.DATA_LEAD_HOLDER_EID, -1)
.putLong(Entity.DATA_FLAGS, 0 ^ 1 << Entity.DATA_FLAG_SILENT ^ 1 << Entity.DATA_FLAG_INVISIBLE ^ 1 << Entity.DATA_FLAG_NO_AI)
.putFloat(Entity.DATA_SCALE, 0)
.putString(Entity.DATA_NAMETAG, title)
.putString(Entity.DATA_TYPE_STRING, title)
.putFloat(Entity.DATA_BOUNDING_BOX_WIDTH, 0)
.putFloat(Entity.DATA_BOUNDING_BOX_HEIGHT, 0);
packet.metadata = metadata;
packet.x = (float) player.getX();
packet.y = (float) player.getY();
packet.z = (float) player.getZ();
packet.speedX = 0;
packet.speedY = 0;
packet.speedZ = 0;
player.dataPacket(packet);
BossEventPacket bpk = new BossEventPacket();
bpk.eid = eid;
bpk.type = 0;
player.dataPacket(bpk);
}