Advertisement
Guest User

Problem bit of Minecraft Code

a guest
Dec 18th, 2014
350
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.86 KB | None | 0 0
  1. public void sendChunkUpdate()
  2. {
  3.   if (this.numberOfTilesToUpdate != 0)
  4.   {
  5.     int i;
  6.     int j;
  7.     int k;
  8.  
  9.     if (this.numberOfTilesToUpdate == 1)
  10.     {
  11.       i = this.chunkLocation.chunkXPos * 16 + (this.locationOfBlockChange[0] >> 12 & 15);
  12.       j = this.locationOfBlockChange[0] & 255;
  13.       k = this.chunkLocation.chunkZPos * 16 + (this.locationOfBlockChange[0] >> 8 & 15);
  14.       this.sendToAllPlayersWatchingChunk(new S23PacketBlockChange(i, j, k, PlayerManager.this.theWorldServer));
  15.  
  16.       if (PlayerManager.this.theWorldServer.getBlock(i, j, k).hasTileEntity(PlayerManager.this.theWorldServer.getBlockMetadata(i, j, k)))
  17.       {
  18.         this.sendTileToAllPlayersWatchingChunk(PlayerManager.this.theWorldServer.getTileEntity(i, j, k));
  19.       }
  20.     }
  21.     else
  22.     {
  23.       int l;
  24.  
  25.       if (this.numberOfTilesToUpdate == net.minecraftforge.common.ForgeModContainer.clumpingThreshold)
  26.       {
  27.         i = this.chunkLocation.chunkXPos * 16;
  28.         j = this.chunkLocation.chunkZPos * 16;
  29.         this.sendToAllPlayersWatchingChunk(new S21PacketChunkData(PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos), false, this.flagsYAreasToUpdate));
  30.  
  31.         // Forge: Grabs ALL tile entities is costly on a modded server, only send needed ones
  32.         for (k = 0; false && k < 16; ++k)
  33.         {
  34.           if ((this.flagsYAreasToUpdate & 1 << k) != 0)
  35.           {
  36.             l = k << 4;
  37.             List list = PlayerManager.this.theWorldServer.func_147486_a(i, l, j, i + 16, l + 16, j + 16);
  38.  
  39.             for (int i1 = 0; i1 < list.size(); ++i1)
  40.             {
  41.               this.sendTileToAllPlayersWatchingChunk((TileEntity)list.get(i1));
  42.             }
  43.           }
  44.         }
  45.       }
  46.       else
  47.       {
  48.         this.sendToAllPlayersWatchingChunk(new S22PacketMultiBlockChange(this.numberOfTilesToUpdate, this.locationOfBlockChange, PlayerManager.this.theWorldServer.getChunkFromChunkCoords(this.chunkLocation.chunkXPos, this.chunkLocation.chunkZPos)));
  49.       }
  50.                    
  51.       { //Forge: Send only the tile entities that are updated, Adding this brace lets us keep the indent and the patch small
  52.         WorldServer world = PlayerManager.this.theWorldServer;
  53.         for (i = 0; i < this.numberOfTilesToUpdate; ++i)
  54.         {
  55.           j = this.chunkLocation.chunkXPos * 16 + (this.locationOfBlockChange[i] >> 12 & 15);
  56.           k = this.locationOfBlockChange[i] & 255;
  57.           l = this.chunkLocation.chunkZPos * 16 + (this.locationOfBlockChange[i] >> 8 & 15);
  58.  
  59.           if (world.getBlock(j, k, l).hasTileEntity(world.getBlockMetadata(j, k, l)))
  60.           {
  61.             this.sendTileToAllPlayersWatchingChunk(PlayerManager.this.theWorldServer.getTileEntity(j, k, l));
  62.           }
  63.         }
  64.       }
  65.     }
  66.     this.numberOfTilesToUpdate = 0;
  67.     this.flagsYAreasToUpdate = 0;
  68.   }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement