Skip to content

Commit

Permalink
Actually fix NPE when loading chunks sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Feb 24, 2024
1 parent 0d36a0f commit 5bb7a77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@

public class Chunk_1_13 extends MCAChunk {

private static final Level EMPTY_LEVEL = new Level();
private static final HeightmapsData EMPTY_HEIGHTMAPS_DATA = new HeightmapsData();

private static final Key STATUS_EMPTY = new Key("minecraft", "empty");
private static final Key STATUS_FULL = new Key("minecraft", "full");
private static final Key STATUS_FULLCHUNK = new Key("minecraft", "fullchunk");
Expand Down Expand Up @@ -265,15 +262,15 @@ public int getSectionY() {
@Getter
@SuppressWarnings("FieldMayBeFinal")
public static class Data extends MCAChunk.Data {
private Level level = EMPTY_LEVEL;
private Level level = new Level();
}

@Getter
@SuppressWarnings("FieldMayBeFinal")
public static class Level {
private Key status = STATUS_EMPTY;
private long inhabitedTime = 0;
private HeightmapsData heightmaps = EMPTY_HEIGHTMAPS_DATA;
private HeightmapsData heightmaps = new HeightmapsData();
private SectionData @Nullable [] sections = null;
private int[] biomes = EMPTY_INT_ARRAY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@

public class Chunk_1_16 extends MCAChunk {

private static final Level EMPTY_LEVEL = new Level();
private static final HeightmapsData EMPTY_HEIGHTMAPS_DATA = new HeightmapsData();

private static final Key STATUS_EMPTY = new Key("minecraft", "empty");
private static final Key STATUS_FULL = new Key("minecraft", "full");

Expand Down Expand Up @@ -253,15 +250,15 @@ public int getSectionY() {
@Getter
@SuppressWarnings("FieldMayBeFinal")
public static class Data extends MCAChunk.Data {
private Level level = EMPTY_LEVEL;
private Level level = new Level();
}

@Getter
@SuppressWarnings("FieldMayBeFinal")
public static class Level {
private Key status = STATUS_EMPTY;
private long inhabitedTime = 0;
private HeightmapsData heightmaps = EMPTY_HEIGHTMAPS_DATA;
private HeightmapsData heightmaps = new HeightmapsData();
private SectionData @Nullable [] sections = null;
private int[] biomes = EMPTY_INT_ARRAY;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@

public class Chunk_1_18 extends MCAChunk {

private static final BlockStatesData EMPTY_BLOCKSTATESDATA = new BlockStatesData();
private static final BiomesData EMPTY_BIOMESDATA = new BiomesData();
private static final HeightmapsData EMPTY_HEIGHTMAPS_DATA = new HeightmapsData();

private static final Key STATUS_EMPTY = new Key("minecraft", "empty");
private static final Key STATUS_FULL = new Key("minecraft", "full");

Expand Down Expand Up @@ -265,7 +261,7 @@ public int getSectionY() {
public static class Data extends MCAChunk.Data {
private Key status = STATUS_EMPTY;
private long inhabitedTime = 0;
private HeightmapsData heightmaps = EMPTY_HEIGHTMAPS_DATA;
private HeightmapsData heightmaps = new HeightmapsData();
private SectionData @Nullable [] sections = null;
}

Expand All @@ -282,8 +278,8 @@ public static class SectionData {
private int y = 0;
private byte[] blockLight = EMPTY_BYTE_ARRAY;
private byte[] skyLight = EMPTY_BYTE_ARRAY;
@NBTName("block_states") private BlockStatesData blockStates = EMPTY_BLOCKSTATESDATA;
private BiomesData biomes = EMPTY_BIOMESDATA;
@NBTName("block_states") private BlockStatesData blockStates = new BlockStatesData();
private BiomesData biomes = new BiomesData();
}

@Getter
Expand Down

0 comments on commit 5bb7a77

Please sign in to comment.