Package net.minecraft.network

Examples of net.minecraft.network.NetServerHandler


  public void processPacket(NetHandler netHandler) {
    if (!(netHandler instanceof NetServerHandler)) {
      Log.warning(netHandler + " sent a movement update before properly connecting. It will be ignored.");
      return;
    }
    NetServerHandler nsh = (NetServerHandler) netHandler;
    EntityPlayerMP entityPlayerMP = nsh.playerEntity;
    sendChunks(entityPlayerMP);
    nsh.handleFlying(this);
  }
View Full Code Here


    sendChunks(entityPlayerMP);
    nsh.handleFlying(this);
  }

  private static void sendChunks(EntityPlayerMP entityPlayerMP) {
    NetServerHandler netServerHandler = entityPlayerMP.playerNetServerHandler;
    if (!entityPlayerMP.loadedChunks.isEmpty()) {
      ArrayList<ChunkCoordIntPair> unpopulatedChunks = new ArrayList<ChunkCoordIntPair>();
      ArrayList<Chunk> chunks = new ArrayList<Chunk>(5);
      ArrayList<TileEntity> tileEntities = new ArrayList<TileEntity>();
      synchronized (entityPlayerMP.loadedChunks) {
        ChunkCoordIntPair chunkCoordIntPair;

        while (chunks.size() < 5 && (chunkCoordIntPair = (ChunkCoordIntPair) entityPlayerMP.loadedChunks.remove(0)) != null) {
          int x = chunkCoordIntPair.chunkXPos;
          int z = chunkCoordIntPair.chunkZPos;

          Chunk chunk = entityPlayerMP.worldObj.getChunkIfExists(x, z);
          if (chunk == null) {
            continue;
          }
          synchronized (chunk) {
            if (!chunk.isTerrainPopulated) {
              unpopulatedChunks.add(chunkCoordIntPair);
              continue;
            }
          }
          chunks.add(chunk);
          tileEntities.addAll(chunk.chunkTileEntityMap.values());
        }
      }
      entityPlayerMP.loadedChunks.addAll(unpopulatedChunks);

      if (!chunks.isEmpty()) {
        netServerHandler.sendPacketToPlayer(new Packet56MapChunks(chunks));
        Iterator iterator = tileEntities.iterator();

        while (iterator.hasNext()) {
          Packet descriptionPacket;
          try {
            descriptionPacket = ((TileEntity) iterator.next()).getDescriptionPacket();
          } catch (Throwable t) {
            Log.warning("A TileEntity failed to provide a description packet", t);
            continue;
          }
          if (descriptionPacket != null) {
            netServerHandler.sendPacketToPlayer(descriptionPacket);
          }
        }

        iterator = chunks.iterator();
View Full Code Here

TOP

Related Classes of net.minecraft.network.NetServerHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.