Advertisement
Guest User

Untitled

a guest
May 5th, 2012
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.24 KB | None | 0 0
  1.     int id;
  2.     net.minecraft.server.Chunk mcChunk;
  3.     int j1;
  4.     ChunkSection[] sections = null;
  5.     ChunkSection chunksection;
  6. //  Location loc;
  7.     List<ChunkCoordIntPair> chunkCoordIntPairQueue;
  8.     ChunkCoordIntPair ccip;
  9.     int y1 = at.waterHeight >> 4;
  10.     int y2 = at.waterHeight & 15;
  11.     boolean tr;
  12.     boolean changed;
  13.     for(Chunk c: world.getLoadedChunks())
  14.     {
  15.       mcChunk = ((CraftChunk)c).getHandle();
  16.       try
  17.       {
  18.         sections = (ChunkSection[])f.get(mcChunk);
  19.       }
  20.       catch(Exception e)
  21.       {
  22.         // TODO Auto-generated catch block
  23.         e.printStackTrace();
  24.       }
  25.       chunksection = sections[y1];
  26.       if(chunksection == null)
  27.         chunksection = sections[y1] = new ChunkSection(at.waterHeight >> 4 << 4);
  28.      
  29.       changed = false;
  30.       long ts = System.currentTimeMillis();
  31.       for(int x = 0; x < 16; x++)
  32.       {
  33.         for(int z = 0; z < 16; z++)
  34.         {
  35.           j1 = z << 4 | x;
  36.          
  37.           if(at.waterHeight > mcChunk.b[j1] - 1)
  38.             mcChunk.b[j1] = -999;
  39.           id = chunksection.a(x, y2, z);
  40.           tr = false;
  41.           for(int trid: at.toReplace)
  42.           {
  43.             if(id == trid)
  44.             {
  45.               tr = true;
  46.               break;
  47.             }
  48.           }
  49.           if(up)
  50.           {
  51.             if(id == at.air || tr)
  52.             {
  53.               chunksection.a(x, y2, z, at.water2);
  54.               changed = true;
  55.             }
  56.           }
  57.           else if(id == at.water1 || id == at.water2 || tr)
  58.           {
  59.             chunksection.a(x, y2, z, at.air);
  60.             changed = true;
  61.           }
  62.           else if(id == at.grass)
  63.           {
  64.             chunksection.a(x, y2, z, at.dirt);
  65.             changed = true;
  66.           }
  67.         }
  68.       }
  69.      
  70.       if(changed)
  71.       {
  72.           long ts2 = System.currentTimeMillis();
  73.         mcChunk.initLighting();
  74.         long ts3 = System.currentTimeMillis();
  75.         ccip = new ChunkCoordIntPair(mcChunk.x, mcChunk.z);
  76.         for(Player p: world.getPlayers())
  77.         {
  78. /*        loc = p.getLocation();
  79.           int px = loc.getBlockX() - (mcChunk.x * 16);
  80.           int pz = loc.getBlockZ() - (mcChunk.z * 16);
  81.           if((px * px) + (pz * pz) < threshold)
  82.           {*/
  83.             chunkCoordIntPairQueue = (List<ChunkCoordIntPair>)((CraftPlayer)p).getHandle().chunkCoordIntPairQueue;
  84.             if(!chunkCoordIntPairQueue.contains(ccip))
  85.               chunkCoordIntPairQueue.add(ccip);
  86. //        }
  87.         }
  88.         System.out.print("Replacing blocks: "+(ts2 - ts)+"ms - relighting chunk: "+(ts3-ts2)+"ms - Adding package to queues: "+(System.currentTimeMillis()-ts3)+"ms");
  89. //      loc = null;
  90.       }
  91.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement