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


Java PlayerManager.getPlayerInstance方法代码示例

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


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

示例1: resyncChunksFull

import net.minecraft.server.management.PlayerManager; //导入方法依赖的package包/类
public void resyncChunksFull() {
    if (w.isRemote) return;
    Chunk chunk = getChunk();
    final WorldServer world = (WorldServer) chunk.getWorld();
    final PlayerManager pm = world.getPlayerManager();
    PlayerManager.PlayerInstance watcher = pm.getPlayerInstance(chunk.xPosition, chunk.zPosition, false);
    if (watcher == null) return;
    ArrayList<EntityPlayerMP> players = new ArrayList<EntityPlayerMP>();
    players.addAll(watcher.playersWatchingChunk);
    for (EntityPlayerMP player : players) {
        watcher.removePlayer(player);
        watcher.addPlayer(player);
    }


    Packet packet = new S21PacketChunkData(chunk, true, -1);
    FzNetDispatch.addPacketFrom(packet, chunk);
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:19,代码来源:Coord.java

示例2: addPacketFrom

import net.minecraft.server.management.PlayerManager; //导入方法依赖的package包/类
public static void addPacketFrom(Packet packet, Chunk chunk) {
    if (chunk.getWorld().isRemote) return;
    final WorldServer world = (WorldServer) chunk.getWorld();
    final PlayerManager pm = world.getPlayerManager();
    PlayerManager.PlayerInstance watcher = pm.getPlayerInstance(chunk.xPosition, chunk.zPosition, false);
    if (watcher == null) return;
    watcher.sendToAllPlayersWatchingChunk(packet);

    // The above requires an AT that is impossible to get working?
    
    /*if (chunk.worldObj.isRemote) return;
    final WorldServer world = (WorldServer) chunk.worldObj;
    final PlayerManager pm = world.getPlayerManager();
    final int near = 10;
    final int far = 16;
    final int sufficientlyClose = (near*16)*(near*16);
    final int superlativelyFar = (far*16)*(far*16);
    final int chunkBlockX = chunk.xPosition*16 + 8;
    final int chunkBlockZ = chunk.zPosition*16 + 8;
    for (EntityPlayerMP player : world.playerEntities) {
        double dx = player.posX - chunkBlockX;
        double dz = player.posZ - chunkBlockZ;
        double dist = dx*dx + dz*dz;
        if (dist > superlativelyFar) continue;
        if (dist < sufficientlyClose || pm.isPlayerWatchingChunk(player, chunk.xPosition, chunk.zPosition)) {
            player.playerNetServerHandler.sendPacket(packet);
        }
    }*/
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:30,代码来源:FzNetDispatch.java


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