Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int id;
- net.minecraft.server.Chunk mcChunk;
- int j1;
- ChunkSection[] sections = null;
- ChunkSection chunksection;
- // Location loc;
- List<ChunkCoordIntPair> chunkCoordIntPairQueue;
- ChunkCoordIntPair ccip;
- int y1 = at.waterHeight >> 4;
- int y2 = at.waterHeight & 15;
- boolean tr;
- boolean changed;
- for(Chunk c: world.getLoadedChunks())
- {
- mcChunk = ((CraftChunk)c).getHandle();
- try
- {
- sections = (ChunkSection[])f.get(mcChunk);
- }
- catch(Exception e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- chunksection = sections[y1];
- if(chunksection == null)
- chunksection = sections[y1] = new ChunkSection(at.waterHeight >> 4 << 4);
- changed = false;
- long ts = System.currentTimeMillis();
- for(int x = 0; x < 16; x++)
- {
- for(int z = 0; z < 16; z++)
- {
- j1 = z << 4 | x;
- if(at.waterHeight > mcChunk.b[j1] - 1)
- mcChunk.b[j1] = -999;
- id = chunksection.a(x, y2, z);
- tr = false;
- for(int trid: at.toReplace)
- {
- if(id == trid)
- {
- tr = true;
- break;
- }
- }
- if(up)
- {
- if(id == at.air || tr)
- {
- chunksection.a(x, y2, z, at.water2);
- changed = true;
- }
- }
- else if(id == at.water1 || id == at.water2 || tr)
- {
- chunksection.a(x, y2, z, at.air);
- changed = true;
- }
- else if(id == at.grass)
- {
- chunksection.a(x, y2, z, at.dirt);
- changed = true;
- }
- }
- }
- if(changed)
- {
- long ts2 = System.currentTimeMillis();
- mcChunk.initLighting();
- long ts3 = System.currentTimeMillis();
- ccip = new ChunkCoordIntPair(mcChunk.x, mcChunk.z);
- for(Player p: world.getPlayers())
- {
- /* loc = p.getLocation();
- int px = loc.getBlockX() - (mcChunk.x * 16);
- int pz = loc.getBlockZ() - (mcChunk.z * 16);
- if((px * px) + (pz * pz) < threshold)
- {*/
- chunkCoordIntPairQueue = (List<ChunkCoordIntPair>)((CraftPlayer)p).getHandle().chunkCoordIntPairQueue;
- if(!chunkCoordIntPairQueue.contains(ccip))
- chunkCoordIntPairQueue.add(ccip);
- // }
- }
- System.out.print("Replacing blocks: "+(ts2 - ts)+"ms - relighting chunk: "+(ts3-ts2)+"ms - Adding package to queues: "+(System.currentTimeMillis()-ts3)+"ms");
- // loc = null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement