id | ");
- for(int i = minY; i < maxY; i++) {
+ for(int i = minY; i <= maxY; i++) {
data.append(i);
data.append(" | ");
}
@@ -209,7 +192,7 @@ public String generateTable(double totalBlocks, double totalExcludingAir) {
data.append(" | ");
data.append(Main.modernizeIDs ? Main.getStringID(key) : key);
data.append(" | ");
- for(int i = minY; i < maxY; i++) {
+ for(int i = minY; i <= maxY; i++) {
if(!heightCounter.get(key).containsKey(i)) {
data.append("0 | ");
} else {
@@ -256,7 +239,7 @@ static boolean mergeStates(byte id) {
static void airHack(Analysis a, int sectionY, String airID) {
if(Main.allowHack && sectionY < 15) {
if(!a.blocks.containsKey(airID)) a.blocks.put(airID, 0L);
- if(!a.heights.containsKey(airID)) a.heights.put(airID, new HashMap());
+ if(!a.heights.containsKey(airID)) a.heights.put(airID, new Hashtable());
for(; sectionY < 16; sectionY++) {
a.blocks.put(airID, a.blocks.get(airID) + 4096L);
for(int y = sectionY * 16; y < sectionY * 16 + 16; y++) {
@@ -270,7 +253,7 @@ static void airHack(Analysis a, int sectionY, String airID) {
}
}
- int getMinimumY() {
+ private int getMinimumY() {
int min = Integer.MAX_VALUE;
for(Map map : heightCounter.values()) {
for(int i : map.keySet()) {
@@ -286,7 +269,7 @@ int getMinimumY() {
}
}
- int getMaximumY() {
+ private int getMaximumY() {
int max = Integer.MIN_VALUE;
for(Map map : heightCounter.values()) {
for(int i : map.keySet()) {
@@ -296,12 +279,29 @@ int getMaximumY() {
}
}
if(version == Version.INDEV || version == Version.ALPHA || version == Version.MCREGION) {
- return 128;
+ return 127;
} else {
return max > 255 ? max : 255;
}
}
+ synchronized void add(Analysis a) {
+ for(String s : a.blocks.keySet()) {
+ blockCounter.put(s, blockCounter.getOrDefault(s, 0L) + a.blocks.get(s));
+ }
+ for(String s : a.heights.keySet()) {
+ if(heightCounter.containsKey(s)) {
+ Map existing = heightCounter.get(s);
+ Map heights = a.heights.get(s);
+ for(int i : heights.keySet()) {
+ existing.put(i, existing.getOrDefault(i, 0L) + heights.get(i));
+ }
+ } else {
+ heightCounter.put(s, a.heights.get(s));
+ }
+ }
+ }
+
public enum Version {
ANVIL_118(RegionAnalyzerAnvil118.class, true),
ANVIL_2021(RegionAnalyzerAnvil2021.class, true),
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java
index 3293e9c..e601b8c 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAlpha.java
@@ -3,7 +3,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.util.ArrayList;
-import java.util.HashMap;
+import java.util.Hashtable;
import java.util.List;
import net.minecraft.nbt.CompressedStreamTools;
@@ -89,7 +89,7 @@ private void analyzeChunk(byte[] blocks, byte[] data) {
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(y)) {
a.heights.get(blockName).put(y, a.heights.get(blockName).get(y) + 1L);
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil118.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil118.java
index f27c7c8..7071684 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil118.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil118.java
@@ -3,7 +3,7 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.Hashtable;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -40,9 +40,8 @@ public void findChunks(File regionDir) {
@Override
public void analyze() {
for(Region r : regions) {
- threads.add(new AnalyzerThread(r) {
- @Override
- public void run() {
+ threads.add(new AnalyzerThread(this, r) {
+ public void process() {
for(Chunk c : r.chunks) {
try {
Analysis a = processRegion(r.file, c.x(), c.z());
@@ -98,7 +97,7 @@ private Analysis analyzeChunk(NBTTagList sections) {
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(actualY)) {
a.heights.get(blockName).put(actualY, a.heights.get(blockName).get(actualY) + 1L);
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2012.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2012.java
index 58e1d45..da68f0b 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2012.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2012.java
@@ -3,7 +3,7 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.Hashtable;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -39,9 +39,8 @@ public void findChunks(File regionDir) {
@Override
public void analyze() {
for(Region r : regions) {
- threads.add(new AnalyzerThread(r) {
- @Override
- public void run() {
+ threads.add(new AnalyzerThread(this, r) {
+ public void process() {
for(Chunk c : r.chunks) {
try {
Analysis a = processRegion(r.file, c.x(), c.z());
@@ -107,7 +106,7 @@ private Analysis analyzeChunk(NBTTagList sections) {
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(actualY)) {
a.heights.get(blockName).put(actualY, a.heights.get(blockName).get(actualY) + 1L);
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2018.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2018.java
index badfc2a..dfcb9e7 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2018.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2018.java
@@ -3,7 +3,7 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.Hashtable;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -42,9 +42,8 @@ public void analyze() {
// The air hack does not seem to work for this version
Main.allowHack = false;
for(Region r : regions) {
- threads.add(new AnalyzerThread(r) {
- @Override
- public void run() {
+ threads.add(new AnalyzerThread(this, r) {
+ public void process() {
for(Chunk c : r.chunks) {
try {
Analysis a = processRegion(r.file, c.x(), c.z());
@@ -100,7 +99,7 @@ private Analysis analyzeChunk(NBTTagList sections) {
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(actualY)) {
a.heights.get(blockName).put(actualY, a.heights.get(blockName).get(actualY) + 1L);
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2021.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2021.java
index cc34573..8ebb560 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2021.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerAnvil2021.java
@@ -3,7 +3,7 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.Hashtable;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -40,9 +40,8 @@ public void findChunks(File regionDir) {
@Override
public void analyze() {
for(Region r : regions) {
- threads.add(new AnalyzerThread(r) {
- @Override
- public void run() {
+ threads.add(new AnalyzerThread(this, r) {
+ public void process() {
for(Chunk c : r.chunks) {
try {
Analysis a = processRegion(r.file, c.x(), c.z());
@@ -98,7 +97,7 @@ private Analysis analyzeChunk(NBTTagList sections) {
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(actualY)) {
a.heights.get(blockName).put(actualY, a.heights.get(blockName).get(actualY) + 1L);
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java
index 38172a8..f59ce92 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerIndev.java
@@ -3,7 +3,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.Hashtable;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -72,7 +72,7 @@ private Analysis analyzeWorld(byte[] blocks, byte[] data, int width, int height)
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(y)) {
a.heights.get(blockName).put(y, a.heights.get(blockName).get(y) + 1L);
diff --git a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerMCRegion.java b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerMCRegion.java
index 501acac..16e8a67 100644
--- a/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerMCRegion.java
+++ b/src/main/java/io/github/meeples10/mcresourceanalyzer/RegionAnalyzerMCRegion.java
@@ -3,7 +3,7 @@
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
-import java.util.HashMap;
+import java.util.Hashtable;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
@@ -34,9 +34,8 @@ public void findChunks(File regionDir) {
@Override
public void analyze() {
for(Region r : regions) {
- threads.add(new AnalyzerThread(r) {
- @Override
- public void run() {
+ threads.add(new AnalyzerThread(this, r) {
+ public void process() {
for(Chunk c : r.chunks) {
try {
Analysis a = processRegion(r.file, c.x(), c.z());
@@ -95,7 +94,7 @@ private Analysis analyzeChunk(byte[] blocks, byte[] data) {
a.blocks.put(blockName, 1L);
}
if(!a.heights.containsKey(blockName)) {
- a.heights.put(blockName, new HashMap());
+ a.heights.put(blockName, new Hashtable());
}
if(a.heights.get(blockName).containsKey(y)) {
a.heights.get(blockName).put(y, a.heights.get(blockName).get(y) + 1L);
---|