Java 类net.minecraft.network.packet.Packet56MapChunks 实例源码

项目:RuneCraftery    文件:NetClientHandler.java   
public void func_72453_a(Packet56MapChunks p_72453_1_) {
   for(int var2 = 0; var2 < p_72453_1_.func_73581_d(); ++var2) {
      int var3 = p_72453_1_.func_73582_a(var2);
      int var4 = p_72453_1_.func_73580_b(var2);
      this.field_72564_i.func_73025_a(var3, var4, true);
      this.field_72564_i.func_73031_a(var3 << 4, 0, var4 << 4, (var3 << 4) + 15, 256, (var4 << 4) + 15);
      Chunk var5 = this.field_72564_i.func_72964_e(var3, var4);
      if(var5 == null) {
         this.field_72564_i.func_73025_a(var3, var4, true);
         var5 = this.field_72564_i.func_72964_e(var3, var4);
      }

      if(var5 != null) {
         var5.func_76607_a(p_72453_1_.func_73583_c(var2), p_72453_1_.field_73590_a[var2], p_72453_1_.field_73588_b[var2], true);
         this.field_72564_i.func_72909_d(var3 << 4, 0, var4 << 4, (var3 << 4) + 15, 256, (var4 << 4) + 15);
         if(!(this.field_72564_i.field_73011_w instanceof WorldProviderSurface)) {
            var5.func_76613_n();
         }
      }
   }

}
项目:forge_world_downloader    文件:WDLNetClientHandler.java   
@Override
public void handleMapChunks(Packet56MapChunks par1Packet56MapChunks)
{
    if (wc == null)
    {
        wc = (WorldClient)Reflexion.stealField(NetClientHandler.class, WorldClient.class).get(nch);
    }

    //nch.handleMapChunks(par1Packet56MapChunks);
    for (int i = 0; i < par1Packet56MapChunks.getNumberOfChunkInPacket(); ++i)
    {
        int j = par1Packet56MapChunks.getChunkPosX(i);
        int k = par1Packet56MapChunks.getChunkPosZ(i);
        doPreChunk(j, k, true);
        wc.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
        Chunk chunk = wc.getChunkFromChunkCoords(j, k);

        if (chunk == null)
        {
            doPreChunk(j, k, true);
            chunk = wc.getChunkFromChunkCoords(j, k);
        }

        if (chunk != null)
        {
            chunk.fillChunk(par1Packet56MapChunks.getChunkCompressedData(i), par1Packet56MapChunks.field_73590_a[i], par1Packet56MapChunks.field_73588_b[i], true);
            wc.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);

            if (!(wc.provider instanceof WorldProviderSurface))
            {
                    chunk.resetRelightChecks();
            }
        }
    }
}
项目:RuneCraftery    文件:NetClientHandler.java   
public void handleMapChunks(Packet56MapChunks par1Packet56MapChunks)
{
    for (int i = 0; i < par1Packet56MapChunks.getNumberOfChunkInPacket(); ++i)
    {
        int j = par1Packet56MapChunks.getChunkPosX(i);
        int k = par1Packet56MapChunks.getChunkPosZ(i);
        this.worldClient.doPreChunk(j, k, true);
        this.worldClient.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
        Chunk chunk = this.worldClient.getChunkFromChunkCoords(j, k);

        if (chunk == null)
        {
            this.worldClient.doPreChunk(j, k, true);
            chunk = this.worldClient.getChunkFromChunkCoords(j, k);
        }

        if (chunk != null)
        {
            chunk.fillChunk(par1Packet56MapChunks.getChunkCompressedData(i), par1Packet56MapChunks.field_73590_a[i], par1Packet56MapChunks.field_73588_b[i], true);
            this.worldClient.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);

            if (!(this.worldClient.provider instanceof WorldProviderSurface))
            {
                chunk.resetRelightChecks();
            }
        }
    }
}
项目:BetterNutritionMod    文件:NetClientHandler.java   
public void handleMapChunks(Packet56MapChunks par1Packet56MapChunks)
{
    for (int i = 0; i < par1Packet56MapChunks.getNumberOfChunkInPacket(); ++i)
    {
        int j = par1Packet56MapChunks.getChunkPosX(i);
        int k = par1Packet56MapChunks.getChunkPosZ(i);
        this.worldClient.doPreChunk(j, k, true);
        this.worldClient.invalidateBlockReceiveRegion(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);
        Chunk chunk = this.worldClient.getChunkFromChunkCoords(j, k);

        if (chunk == null)
        {
            this.worldClient.doPreChunk(j, k, true);
            chunk = this.worldClient.getChunkFromChunkCoords(j, k);
        }

        if (chunk != null)
        {
            chunk.fillChunk(par1Packet56MapChunks.getChunkCompressedData(i), par1Packet56MapChunks.field_73590_a[i], par1Packet56MapChunks.field_73588_b[i], true);
            this.worldClient.markBlockRangeForRenderUpdate(j << 4, 0, k << 4, (j << 4) + 15, 256, (k << 4) + 15);

            if (!(this.worldClient.provider instanceof WorldProviderSurface))
            {
                chunk.resetRelightChecks();
            }
        }
    }
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
public void func_70071_h_() {
   this.field_71134_c.func_73075_a();
   --this.field_71145_cl;
   this.field_71070_bA.func_75142_b();
   if(!this.field_70170_p.field_72995_K && !this.field_71070_bA.func_75145_c(this)) {
      this.func_71053_j();
      this.field_71070_bA = this.field_71069_bz;
   }

   while(!this.field_71130_g.isEmpty()) {
      int var1 = Math.min(this.field_71130_g.size(), 127);
      int[] var2 = new int[var1];
      Iterator var3 = this.field_71130_g.iterator();
      int var4 = 0;

      while(var3.hasNext() && var4 < var1) {
         var2[var4++] = ((Integer)var3.next()).intValue();
         var3.remove();
      }

      this.field_71135_a.func_72567_b(new Packet29DestroyEntity(var2));
   }

   if(!this.field_71129_f.isEmpty()) {
      ArrayList var6 = new ArrayList();
      Iterator var7 = this.field_71129_f.iterator();
      ArrayList var8 = new ArrayList();

      while(var7.hasNext() && var6.size() < 5) {
         ChunkCoordIntPair var9 = (ChunkCoordIntPair)var7.next();
         var7.remove();
         if(var9 != null && this.field_70170_p.func_72899_e(var9.field_77276_a << 4, 0, var9.field_77275_b << 4)) {
            var6.add(this.field_70170_p.func_72964_e(var9.field_77276_a, var9.field_77275_b));
            var8.addAll(((WorldServer)this.field_70170_p).func_73049_a(var9.field_77276_a * 16, 0, var9.field_77275_b * 16, var9.field_77276_a * 16 + 16, 256, var9.field_77275_b * 16 + 16));
         }
      }

      if(!var6.isEmpty()) {
         this.field_71135_a.func_72567_b(new Packet56MapChunks(var6));
         Iterator var11 = var8.iterator();

         while(var11.hasNext()) {
            TileEntity var5 = (TileEntity)var11.next();
            this.func_71119_a(var5);
         }

         var11 = var6.iterator();

         while(var11.hasNext()) {
            Chunk var10 = (Chunk)var11.next();
            this.func_71121_q().func_73039_n().func_85172_a(this, var10);
         }
      }
   }

   if(this.field_143005_bX > 0L && this.field_71133_b.func_143007_ar() > 0 && MinecraftServer.func_130071_aq() - this.field_143005_bX > (long)(this.field_71133_b.func_143007_ar() * 1000 * 60)) {
      this.field_71135_a.func_72565_c("You have been idle for too long!");
   }

}
项目:RuneCraftery    文件:NetHandler.java   
public void func_72453_a(Packet56MapChunks p_72453_1_) {
   this.func_72509_a(p_72453_1_);
}
项目:RuneCraftery    文件:EntityPlayerMP.java   
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.theItemInWorldManager.updateBlockRemoving();
    --this.initialInvulnerability;
    this.openContainer.detectAndSendChanges();

    if (!this.worldObj.isRemote && !ForgeHooks.canInteractWith(this, this.openContainer))
    {
        this.closeScreen();
        this.openContainer = this.inventoryContainer;
    }

    while (!this.destroyedItemsNetCache.isEmpty())
    {
        int i = Math.min(this.destroyedItemsNetCache.size(), 127);
        int[] aint = new int[i];
        Iterator iterator = this.destroyedItemsNetCache.iterator();
        int j = 0;

        while (iterator.hasNext() && j < i)
        {
            aint[j++] = ((Integer)iterator.next()).intValue();
            iterator.remove();
        }

        this.playerNetServerHandler.sendPacketToPlayer(new Packet29DestroyEntity(aint));
    }

    if (!this.loadedChunks.isEmpty())
    {
        ArrayList arraylist = new ArrayList();
        Iterator iterator1 = this.loadedChunks.iterator();
        ArrayList arraylist1 = new ArrayList();

        while (iterator1.hasNext() && arraylist.size() < 5)
        {
            ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next();
            iterator1.remove();

            if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
            {
                arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos));
                //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
                //ToDo: Find a way to efficiently clean abandoned chunks.
                //arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 16, 256, chunkcoordintpair.chunkZPos * 16 + 16));
                arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15));
            }
        }

        if (!arraylist.isEmpty())
        {
            this.playerNetServerHandler.sendPacketToPlayer(new Packet56MapChunks(arraylist));
            Iterator iterator2 = arraylist1.iterator();

            while (iterator2.hasNext())
            {
                TileEntity tileentity = (TileEntity)iterator2.next();
                this.sendTileEntityToPlayer(tileentity);
            }

            iterator2 = arraylist.iterator();

            while (iterator2.hasNext())
            {
                Chunk chunk = (Chunk)iterator2.next();
                this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk);
                MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), this));
            }
        }
    }

    if (this.field_143005_bX > 0L && this.mcServer.func_143007_ar() > 0 && MinecraftServer.getSystemTimeMillis() - this.field_143005_bX > (long)(this.mcServer.func_143007_ar() * 1000 * 60))
    {
        this.playerNetServerHandler.kickPlayerFromServer("You have been idle for too long!");
    }
}
项目:BetterNutritionMod    文件:EntityPlayerMP.java   
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate()
{
    this.theItemInWorldManager.updateBlockRemoving();
    --this.initialInvulnerability;
    this.openContainer.detectAndSendChanges();

    if (!this.worldObj.isRemote && !ForgeHooks.canInteractWith(this, this.openContainer))
    {
        this.closeScreen();
        this.openContainer = this.inventoryContainer;
    }

    while (!this.destroyedItemsNetCache.isEmpty())
    {
        int i = Math.min(this.destroyedItemsNetCache.size(), 127);
        int[] aint = new int[i];
        Iterator iterator = this.destroyedItemsNetCache.iterator();
        int j = 0;

        while (iterator.hasNext() && j < i)
        {
            aint[j++] = ((Integer)iterator.next()).intValue();
            iterator.remove();
        }

        this.playerNetServerHandler.sendPacketToPlayer(new Packet29DestroyEntity(aint));
    }

    if (!this.loadedChunks.isEmpty())
    {
        ArrayList arraylist = new ArrayList();
        Iterator iterator1 = this.loadedChunks.iterator();
        ArrayList arraylist1 = new ArrayList();

        while (iterator1.hasNext() && arraylist.size() < 5)
        {
            ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next();
            iterator1.remove();

            if (chunkcoordintpair != null && this.worldObj.blockExists(chunkcoordintpair.chunkXPos << 4, 0, chunkcoordintpair.chunkZPos << 4))
            {
                arraylist.add(this.worldObj.getChunkFromChunkCoords(chunkcoordintpair.chunkXPos, chunkcoordintpair.chunkZPos));
                //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
                //ToDo: Find a way to efficiently clean abandoned chunks.
                //arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 16, 256, chunkcoordintpair.chunkZPos * 16 + 16));
                arraylist1.addAll(((WorldServer)this.worldObj).getAllTileEntityInBox(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15));
            }
        }

        if (!arraylist.isEmpty())
        {
            this.playerNetServerHandler.sendPacketToPlayer(new Packet56MapChunks(arraylist));
            Iterator iterator2 = arraylist1.iterator();

            while (iterator2.hasNext())
            {
                TileEntity tileentity = (TileEntity)iterator2.next();
                this.sendTileEntityToPlayer(tileentity);
            }

            iterator2 = arraylist.iterator();

            while (iterator2.hasNext())
            {
                Chunk chunk = (Chunk)iterator2.next();
                this.getServerForPlayer().getEntityTracker().func_85172_a(this, chunk);
                MinecraftForge.EVENT_BUS.post(new ChunkWatchEvent.Watch(chunk.getChunkCoordIntPair(), this));
            }
        }
    }

    if (this.field_143005_bX > 0L && this.mcServer.func_143007_ar() > 0 && MinecraftServer.getSystemTimeMillis() - this.field_143005_bX > (long)(this.mcServer.func_143007_ar() * 1000 * 60))
    {
        this.playerNetServerHandler.kickPlayerFromServer("You have been idle for too long!");
    }
}