本文整理汇总了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);
}
示例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);
}
}*/
}