blob: f983bebff97e41ad3118c76271f0abed889cf5a6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
package makamys.neodymium.renderer;
import net.minecraft.entity.Entity;
public class NeoRegion {
private NeoChunk[][] data = new NeoChunk[32][32];
int regionX, regionZ;
public int meshes = 0;
private int emptyTicks = 0;
public NeoRegion(int regionX, int regionZ) {
this.regionX = regionX;
this.regionZ = regionZ;
for(int i = 0; i < 32; i++) {
for(int j = 0; j < 32; j++) {
data[i][j] = new NeoChunk(regionX * 32 + i, regionZ * 32 + j, this);
}
}
}
public static NeoRegion load(int regionX, int regionZ) {
return new NeoRegion(regionX, regionZ);
}
public NeoChunk getChunkAbsolute(int chunkXAbs, int chunkZAbs) {
return getChunk(chunkXAbs - regionX * 32, chunkZAbs - regionZ * 32);
}
public NeoChunk getChunk(int x, int z) {
if(x >= 0 && x < 32 && z >= 0 && z < 32) {
return data[x][z];
} else {
return null;
}
}
public void tick() {
for(int i = 0; i < 32; i++) {
for(int j = 0; j < 32; j++) {
NeoChunk chunk = data[i][j];
if(chunk != null) {
chunk.tick();
}
}
}
if(meshes == 0) {
emptyTicks++;
} else {
emptyTicks = 0;
}
}
public void destroy() {
for(int i = 0; i < 32; i++) {
for(int j = 0; j < 32; j++) {
NeoChunk chunk = data[i][j];
if(chunk != null) {
chunk.destroy();
}
}
}
}
public double distanceTaxicab(Entity entity) {
double centerX = ((regionX * 32) + 16) * 16;
double centerZ = ((regionZ * 32) + 16) * 16;
return Math.max(Math.abs(centerX - entity.posX), Math.abs(centerZ - entity.posZ));
}
@Override
public String toString() {
return "LODRegion(" + regionX + ", " + regionZ + ")";
}
public boolean shouldDelete() {
return emptyTicks > 100;
}
}
|