change storage format to single block array
This commit is contained in:
parent
9e72902142
commit
b9753203ec
2 changed files with 11 additions and 46 deletions
|
@ -1723,9 +1723,7 @@ public abstract class Converter {
|
||||||
|
|
||||||
NbtTag sect = sections[y];
|
NbtTag sect = sections[y];
|
||||||
if(sect != null) {
|
if(sect != null) {
|
||||||
byte[] newblks = new byte[4096];
|
byte[] newblks = new byte[4096 << 1];
|
||||||
NibbleArray datanew = new NibbleArray();
|
|
||||||
NibbleArray addnew = null;
|
|
||||||
for(int c = 0; c < blocks.length; ++c) {
|
for(int c = 0; c < blocks.length; ++c) {
|
||||||
int cx = c & 15;
|
int cx = c & 15;
|
||||||
int cy = c >> 8 & 15;
|
int cy = c >> 8 & 15;
|
||||||
|
@ -1735,21 +1733,13 @@ public abstract class Converter {
|
||||||
continue;
|
continue;
|
||||||
char cd = mapping[BlockRegistry.getId(getState(block, data.get(cx, cy, cz), cy == 0 ? (lastData == null ? 0 : lastData.get(cx, 15, cz)) : data.get(cx, cy - 1, cz),
|
char cd = mapping[BlockRegistry.getId(getState(block, data.get(cx, cy, cz), cy == 0 ? (lastData == null ? 0 : lastData.get(cx, 15, cz)) : data.get(cx, cy - 1, cz),
|
||||||
cy == 15 ? (nextData == null ? 0 : nextData.get(cx, 0, cz)) : data.get(cx, cy + 1, cz)))];
|
cy == 15 ? (nextData == null ? 0 : nextData.get(cx, 0, cz)) : data.get(cx, cy + 1, cz)))];
|
||||||
if(cd >> 12 != 0) {
|
newblks[c << 1] = (byte)((cd >> 8) & 255);
|
||||||
if(addnew == null)
|
newblks[(c << 1) | 1] = (byte)(cd & 255);
|
||||||
addnew = new NibbleArray();
|
|
||||||
addnew.set(cx, cy, cz, cd >> 12);
|
|
||||||
}
|
|
||||||
newblks[c] = (byte)(cd & 255);
|
|
||||||
datanew.set(cx, cy, cz, cd >> 8 & 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TagObject nsect = new TagObject();
|
TagObject nsect = new TagObject();
|
||||||
nsect.setInt("Y", y);
|
nsect.setInt("Y", y);
|
||||||
nsect.setByteArray("Dat0", newblks);
|
nsect.setByteArray("Data", newblks);
|
||||||
nsect.setByteArray("Dat1", datanew.getData());
|
|
||||||
if(addnew != null)
|
|
||||||
nsect.setByteArray("Dat2", addnew.getData());
|
|
||||||
nsect.setByteArray("BlockLight", sect.getByteArray("BlockLight"));
|
nsect.setByteArray("BlockLight", sect.getByteArray("BlockLight"));
|
||||||
nsect.setByteArray("SkyLight", sect.getByteArray("SkyLight"));
|
nsect.setByteArray("SkyLight", sect.getByteArray("SkyLight"));
|
||||||
entities.add(nsect);
|
entities.add(nsect);
|
||||||
|
|
|
@ -496,17 +496,11 @@ public class Region {
|
||||||
TagObject sect = sects.get(n);
|
TagObject sect = sects.get(n);
|
||||||
int y = sect.getInt("Y");
|
int y = sect.getInt("Y");
|
||||||
BlockArray storage = new BlockArray(y << 4, light, y < 0 ? world.dimension.getFiller() : null);
|
BlockArray storage = new BlockArray(y << 4, light, y < 0 ? world.dimension.getFiller() : null);
|
||||||
byte[] blocks = sect.getByteArray("Dat0");
|
byte[] blocks = sect.getByteArray("Data");
|
||||||
NibbleArray data = new NibbleArray(sect.getByteArray("Dat1"));
|
char[] seg = new char[blocks.length >> 1];
|
||||||
NibbleArray adddata = sect.hasByteArray("Dat2") ? new NibbleArray(sect.getByteArray("Dat2")) : null;
|
|
||||||
char[] seg = new char[blocks.length];
|
|
||||||
|
|
||||||
for(int c = 0; c < seg.length; ++c) {
|
for(int c = 0; c < seg.length; ++c) {
|
||||||
int cx = c & 15;
|
seg[c] = DECODE_MAP[(blocks[c << 1] & 255) << 8 | (blocks[(c << 1) | 1] & 255)];
|
||||||
int cy = c >> 8 & 15;
|
|
||||||
int cz = c >> 4 & 15;
|
|
||||||
int ca = adddata != null ? adddata.get(cx, cy, cz) : 0;
|
|
||||||
seg[c] = DECODE_MAP[ca << 12 | data.get(cx, cy, cz) << 8 | (blocks[c] & 255)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
storage.setData(seg);
|
storage.setData(seg);
|
||||||
|
@ -608,34 +602,15 @@ public class Region {
|
||||||
if(storage != null) {
|
if(storage != null) {
|
||||||
TagObject sect = new TagObject();
|
TagObject sect = new TagObject();
|
||||||
sect.setInt("Y", storage.getY() >> 4);
|
sect.setInt("Y", storage.getY() >> 4);
|
||||||
byte[] blocks = new byte[storage.getData().length];
|
byte[] blocks = new byte[storage.getData().length << 1];
|
||||||
NibbleArray data = new NibbleArray();
|
|
||||||
NibbleArray adddata = null;
|
|
||||||
|
|
||||||
for(int c = 0; c < storage.getData().length; ++c) {
|
for(int c = 0; c < storage.getData().length; ++c) {
|
||||||
char cd = ENCODE_MAP[storage.getData()[c]];
|
char cd = ENCODE_MAP[storage.getData()[c]];
|
||||||
int cx = c & 15;
|
blocks[c << 1] = (byte)((cd >> 8) & 255);
|
||||||
int cy = c >> 8 & 15;
|
blocks[(c << 1) | 1] = (byte)(cd & 255);
|
||||||
int cz = c >> 4 & 15;
|
|
||||||
|
|
||||||
if(cd >> 12 != 0) {
|
|
||||||
if(adddata == null) {
|
|
||||||
adddata = new NibbleArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
adddata.set(cx, cy, cz, cd >> 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
blocks[c] = (byte)(cd & 255);
|
|
||||||
data.set(cx, cy, cz, cd >> 8 & 15);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sect.setByteArray("Dat0", blocks);
|
sect.setByteArray("Data", blocks);
|
||||||
sect.setByteArray("Dat1", data.getData());
|
|
||||||
|
|
||||||
if(adddata != null) {
|
|
||||||
sect.setByteArray("Dat2", adddata.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
|
sect.setByteArray("BlockLight", storage.getBlocklight().getData());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue