Skip to content

Instantly share code, notes, and snippets.

@ihatecsv
Created December 31, 2015 02:08
Show Gist options
  • Save ihatecsv/fd6be83938e997fe413d to your computer and use it in GitHub Desktop.
Save ihatecsv/fd6be83938e997fe413d to your computer and use it in GitHub Desktop.
mapChunk
@SubscribeEvent(priority=EventPriority.LOWEST)
public void onChunkLoad(ChunkEvent.Load event) {
int chunkX = event.getChunk().xPosition;
int chunkZ = event.getChunk().zPosition;
int cornerX = chunkX*16;
int cornerZ = chunkZ*16;
//System.out.println("chunk at " + chunkX + ", " + chunkZ + " getting loaded");
//System.out.println("Boundries at " + cornerX + ", " + cornerZ);
//System.out.println("-----------------------------");
RadChunk chunk = new RadChunk(chunkX,chunkZ);
radChunks.add(chunk);
for(int i = cornerX; i < cornerX+16; i++){
for(int k = cornerZ; k < cornerZ+16; k++){
for(int j = 0; j < 256; j++){
Block sourceBlock = event.world.getBlock(i, j, k);
String sourceName = sourceBlock.getUnlocalizedName();
int sourceMeta = event.world.getBlockMetadata(i, j, k);
RadObj source = RadObjects.findObj(sourceName + "/" + sourceMeta);
if(source != null && source.radStrength > 0 && source.radValue > 0){
chunk.addLoc(new Coord3D(i,j,k));
System.out.println("Found new sourceblock at " + i + ", " + j + ", " + k);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment