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


Java Player.getZ方法代码示例

本文整理汇总了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;
}
 
开发者ID:WetABQ,项目名称:BossBarAPI-Nukkit,代码行数:44,代码来源:BossBarAPI.java

示例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);
}
 
开发者ID:WetABQ,项目名称:BossBarAPI-Nukkit,代码行数:33,代码来源:BossBarAPI.java


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