Ejemplo n.º 1
0
  public void sendThisChunkToPlayer(EntityPlayerMP par1EntityPlayerMP) {
    if (this.playersInChunk.contains(par1EntityPlayerMP)) {
      par1EntityPlayerMP.playerNetServerHandler.sendPacketToPlayer(
          new Packet51MapChunk(
              PlayerManager.getWorldServer(this.thePlayerManager)
                  .getChunkFromChunkCoords(
                      this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos),
              true,
              0));
      this.playersInChunk.remove(par1EntityPlayerMP);
      par1EntityPlayerMP.loadedChunks.remove(this.chunkLocation);

      MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.UnWatch(chunkLocation, par1EntityPlayerMP));

      if (this.playersInChunk.isEmpty()) {
        long i =
            (long) this.chunkLocation.chunkXPos + 2147483647L
                | (long) this.chunkLocation.chunkZPos + 2147483647L << 32;
        PlayerManager.getChunkWatchers(this.thePlayerManager).remove(i);

        if (this.numberOfTilesToUpdate > 0) {
          PlayerManager.getChunkWatchersWithPlayers(this.thePlayerManager).remove(this);
        }

        this.thePlayerManager
            .getWorldServer()
            .theChunkProviderServer
            .unloadChunksIfNotNearSpawn(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos);
      }
    }
  }