Skip to content

Commit

Permalink
make newMCAFile public / check if palette is null
Browse files Browse the repository at this point in the history
  • Loading branch information
Querz committed May 4, 2020
1 parent 5d80a38 commit ea6ef16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/querz/mca/MCAUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public static int chunkToBlock(int chunk) {

private static final Pattern mcaFilePattern = Pattern.compile("^.*r\\.(?<regionX>-?\\d+)\\.(?<regionZ>-?\\d+)\\.mca$");

private static MCAFile newMCAFile(File file) {
public static MCAFile newMCAFile(File file) {
Matcher m = mcaFilePattern.matcher(file.getName());
if (m.find()) {
return new MCAFile(Integer.parseInt(m.group("regionX")), Integer.parseInt(m.group("regionZ")));
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/net/querz/mca/Section.java
Original file line number Diff line number Diff line change
Expand Up @@ -371,10 +371,18 @@ public static Section newSection() {
*/
public CompoundTag updateHandle(int y) {
data.putByte("Y", (byte) y);
data.put("Palette", palette);
if (blockLight != null) data.putByteArray("BlockLight", blockLight);
data.putLongArray("BlockStates", blockStates);
if (skyLight != null) data.putByteArray("SkyLight", skyLight);
if (palette != null) {
data.put("Palette", palette);
}
if (blockLight != null) {
data.putByteArray("BlockLight", blockLight);
}
if (blockStates != null) {
data.putLongArray("BlockStates", blockStates);
}
if (skyLight != null) {
data.putByteArray("SkyLight", skyLight);
}
return data;
}
}

0 comments on commit ea6ef16

Please sign in to comment.