Advertisement
Corosus

Untitled

Feb 10th, 2013
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.29 KB | None | 0 0
  1. public DimensionChunkCache(World world/*, int par2, int par3, int par4, int par5, int par6, int par7*/)
  2.     {
  3.        
  4.         int minX = 0;
  5.         int minZ = 0;
  6.         int maxX = 0;
  7.         int maxZ = 0;
  8.        
  9.         byte playerRadius = 8;
  10.        
  11.         for (int i = 0; i < world.playerEntities.size(); ++i)
  12.         {
  13.             EntityPlayer var5 = (EntityPlayer)world.playerEntities.get(i);
  14.            
  15.             if ((int)var5.posX < minX) minX = (int)var5.posX;
  16.             if ((int)var5.posZ < minZ) minZ = (int)var5.posZ;
  17.             if ((int)var5.posX > maxX) maxX = (int)var5.posX;
  18.             if ((int)var5.posZ > maxZ) maxZ = (int)var5.posZ;
  19.         }
  20.        
  21.         minX -= (playerRadius * 16);
  22.         minZ -= (playerRadius * 16);
  23.         maxX += (playerRadius * 16);
  24.         maxZ += (playerRadius * 16);
  25.        
  26.         this.worldObj = world;
  27.         this.chunkX = minX >> 4;
  28.         this.chunkZ = minZ >> 4;
  29.         int var8 = maxX >> 4;
  30.         int var9 = maxZ >> 4;
  31.         this.chunkArray = new Chunk[var8 - this.chunkX + 1][var9 - this.chunkZ + 1];
  32.         this.hasExtendedLevels = true;
  33.        
  34.         int chunkCount = 0;
  35.        
  36.         for (int i = 0; i < world.playerEntities.size(); ++i)
  37.         {
  38.            
  39.             EntityPlayer var5 = (EntityPlayer)world.playerEntities.get(i);
  40.            
  41.             int pChunkX = MathHelper.floor_double(var5.posX / 16.0D);
  42.             int pChunkZ = MathHelper.floor_double(var5.posZ / 16.0D);
  43.            
  44.             for (int xx = -playerRadius; xx <= playerRadius; ++xx)
  45.             {
  46.                 for (int zz = -playerRadius; zz <= playerRadius; ++zz)
  47.                 {
  48.                     if (this.chunkArray[pChunkX + xx - this.chunkX][pChunkZ + zz - this.chunkZ] == null) {
  49.                         Chunk var12 = world.getChunkFromChunkCoords(pChunkX + xx, pChunkZ + zz);
  50.  
  51.                         if (var12 != null)
  52.                         {
  53.                             //System.out.println("adding to array!");
  54.                             chunkCount++;
  55.                             this.chunkArray[pChunkX + xx - this.chunkX][pChunkZ + zz - this.chunkZ] = var12;
  56.                         }
  57.                     }                  
  58.                 }
  59.             }
  60.         }
  61.        
  62.         //System.out.println("Total Cached Chunks: " + chunkCount);
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement