private void mapCalc() {
if (Minecraft.getMinecraft().thePlayer == null || Minecraft.getMinecraft().theWorld == null)
return;
try {
final boolean square = MinimapConfig.getInstance().isSquare();
final World data = Minecraft.getMinecraft().theWorld;
int renderSize;
int startX;
int startZ;
synchronized (map) {
if (map.zoom != MinimapConfig.getInstance().getZoom()) {
map.zoom = MinimapConfig.getInstance().getZoom();
switch (map.zoom) {
case 0:
map.renderSize = Map.ZOOM_0;
break;
case 1:
map.renderSize = Map.ZOOM_1;
break;
case 2:
map.renderSize = Map.ZOOM_2;
break;
default:
map.renderSize = Map.ZOOM_2;
break;
}
map.renderOff = map.renderSize / 2;
map.clear();
}
map.square = square;
map.update(Minecraft.getMinecraft().thePlayer.posX, Minecraft.getMinecraft().thePlayer.posZ);
renderSize = map.renderSize;
startX = (int) (map.getPlayerX() - map.renderOff);
startZ = (int) (map.getPlayerZ() - map.renderOff);
}
for (int worldX = startX; worldX < startX + renderSize; worldX++) {
for (int worldZ = startZ; worldZ < startZ + renderSize; worldZ++) {
int worldY = getBlockHeight(data, worldX, worldZ);
int pixelX = worldX - startX;
if (pixelX >= renderSize) {
pixelX -= renderSize;
}
int pixelZ = worldZ - startZ;
pixelZ = renderSize - pixelZ;
if (pixelZ >= renderSize) {
pixelZ -= renderSize;
}
if (square || MinimapUtils.insideCircle(startX + renderSize / 2, startZ + renderSize / 2, renderSize / 2, worldX, worldZ)) {
int color = getBlockColor(data, worldX, worldY, worldZ);
if (color == 0) {
map.clearColorPixel(pixelX, pixelZ);
} else {
map.setColorPixel(pixelX, pixelZ, color);
}
short height = (short) data.getHeightValue(worldX, worldZ);
short reference = (short) data.getHeightValue(worldX + 1, worldZ + 1);
map.heightimg.setARGB(pixelZ, pixelX, getHeightColor(height, reference));
map.setLightPixel(pixelX, pixelZ, getBlockLight(data, worldX, worldY, worldZ));
} else {
map.clearColorPixel(pixelX, pixelZ);