Skip to content

Commit

Permalink
Add support for worlds with heights outside the 0-255 range
Browse files Browse the repository at this point in the history
  • Loading branch information
Meeples10 committed Aug 5, 2021
1 parent 275b52f commit 2b1c9ae
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>io.github.meeples10.mcresourceanalyzer</groupId>
<artifactId>mc-resource-analyzer</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.1.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,30 @@ void airHack(int sectionY, String airID) {
}
}

int getMinimumY() {
int min = Integer.MAX_VALUE;
for(HashMap<Integer, Long> map : heightCounter.values()) {
for(int i : map.keySet()) {
if(i < min) {
min = i;
}
}
}
return min;
}

int getMaximumY() {
int max = Integer.MIN_VALUE;
for(HashMap<Integer, Long> map : heightCounter.values()) {
for(int i : map.keySet()) {
if(i > max) {
max = i;
}
}
}
return max;
}

public enum Version {
ANVIL_2021("Anvil (1.16 to 1.17)", RegionAnalyzerAnvil2021.class), ANVIL_2018("Anvil (1.13 to 1.15)",
RegionAnalyzerAnvil2018.class), ANVIL_2012("Anvil (1.2 to 1.12)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ public int compare(String arg0, String arg1) {
+ "\n";
}
data += "id,";
for(int i = 0; i < 256; i++) {
int minY = getMinimumY();
int maxY = getMaximumY();
for(int i = minY; i <= maxY; i++) {
data += i + ",";
}
data += "total,percent_of_total,percent_excluding_air\n";
Expand All @@ -91,7 +93,7 @@ public int compare(String arg0, String arg1) {
keyIndex += 1;
System.out.print("\rGenerating CSV... " + String.format(completionFormat, keyIndex, blockCounter.size()));
data += key + ",";
for(int i = 0; i < 256; i++) {
for(int i = minY; i <= maxY; i++) {
if(!heightCounter.get(key).containsKey(i)) {
data += "0,";
} else {
Expand Down

0 comments on commit 2b1c9ae

Please sign in to comment.