implement properties in janky pregen

This commit is contained in:
dfsek
2021-01-04 01:58:25 -07:00
parent 75fbda5a9f
commit bd0726db37
3 changed files with 20 additions and 5 deletions

View File

@@ -10,8 +10,19 @@ public class Data implements BlockData, MaterialData {
public Data(String data) {
this.data = new CompoundTag();
if(data.contains("[")) noProp = data.substring(0, data.indexOf('[')); // Strip properties for now TODO: actually do properties lol
else noProp = data;
if(data.contains("[")) {
noProp = data.substring(0, data.indexOf('[')); // Strip properties
String properties = data.substring(data.indexOf('[') + 1, data.indexOf(']'));
String[] props = properties.split(",");
CompoundTag pTag = new CompoundTag();
for(String property : props) {
String name = property.substring(0, property.indexOf('='));
String val = property.substring(property.indexOf('=') + 1);
pTag.putString(name, val);
}
this.data.put("Properties", pTag);
} else noProp = data;
this.data.putString("Name", noProp);
}
@@ -23,10 +34,10 @@ public class Data implements BlockData, MaterialData {
this.data = tag;
}
String id = data.getString("Name");
if(id.contains("[")) noProp = id.substring(0, id.indexOf('[')); // Strip properties for now TODO: actually do properties lol
else noProp = id;
noProp = id;
}
@Override
public MaterialData getMaterial() {
return this;

View File

@@ -64,7 +64,10 @@ public class DirectWorld implements World {
public Chunk getChunkAt(int x, int z) {
MCAFile file = compute(x, z);
net.querz.mca.Chunk chunk = file.getChunk(x, z);
if(chunk == null) chunk = net.querz.mca.Chunk.newChunk();
if(chunk == null) {
chunk = net.querz.mca.Chunk.newChunk();
file.setChunk(x, z, chunk);
}
return new DirectChunkData(chunk, this, x, z);
}

View File

@@ -83,6 +83,7 @@ public class Generator {
}
for(Map.Entry<Long, MCAFile> entry : world.getFiles().entrySet()) {
if(entry.getValue() == null) continue;
entry.getValue().cleanupPalettesAndBlockStates();
int x = (int) (entry.getKey() >> 32);
int z = (int) (long) entry.getKey();