|
17 | 17 |
|
18 | 18 | import org.glavo.nbt.NBTElement; |
19 | 19 | import org.glavo.nbt.NBTParent; |
20 | | -import org.glavo.nbt.internal.ChunkMetadata; |
21 | 20 | import org.glavo.nbt.internal.ChunkUtils; |
22 | 21 | import org.glavo.nbt.tag.CompoundTag; |
23 | 22 | import org.jetbrains.annotations.Nullable; |
24 | 23 |
|
25 | 24 | public final class Chunk implements NBTParent<CompoundTag>, NBTElement { |
26 | | - @Nullable ChunkRegion region; |
27 | | - int localIndex = -1; |
| 25 | + final ChunkRegion region; |
| 26 | + final int localIndex; |
28 | 27 |
|
29 | | - CompoundTag rootTag; |
| 28 | + @Nullable CompoundTag rootTag; |
30 | 29 |
|
31 | 30 | Chunk(ChunkRegion region, int localIndex) { |
32 | 31 | this.region = region; |
33 | 32 | this.localIndex = localIndex; |
34 | 33 | } |
35 | 34 |
|
36 | | - Chunk(ChunkRegion region, ChunkMetadata metadata, CompoundTag rootTag) { |
37 | | - this.region = region; |
38 | | - this.localIndex = metadata.localIndex(); |
39 | | - this.rootTag = rootTag; |
40 | | - } |
41 | | - |
42 | | - public Chunk() { |
43 | | - } |
44 | | - |
45 | 35 | /// Return the region of this chunk, or `null` if this chunk is not in any region. |
46 | | - public @Nullable ChunkRegion getRegion() { |
| 36 | + public ChunkRegion getRegion() { |
47 | 37 | return region; |
48 | 38 | } |
49 | 39 |
|
50 | 40 | /// Return the local x coordinate of this chunk in its region, or -1 if this chunk is not in any region. |
51 | 41 | public int getLocalX() { |
52 | | - return localIndex >= 0 ? localIndex % ChunkUtils.CHUNKS_PER_REGION_SIDE : -1; |
| 42 | + return localIndex >= 0 ? ChunkUtils.getLocalX(localIndex) : -1; |
53 | 43 | } |
54 | 44 |
|
55 | 45 | /// Return the local z coordinate of this chunk in its region, or -1 if this chunk is not in any region. |
56 | 46 | public int getLocalZ() { |
57 | | - return localIndex >= 0 ? localIndex / ChunkUtils.CHUNKS_PER_REGION_SIDE : -1; |
| 47 | + return localIndex >= 0 ? ChunkUtils.getLocalZ(localIndex) : -1; |
58 | 48 | } |
59 | 49 |
|
60 | | - public CompoundTag getRootTag() { |
| 50 | + public @Nullable CompoundTag getRootTag() { |
61 | 51 | return rootTag; |
62 | 52 | } |
63 | 53 | } |
0 commit comments