diff --git a/server/src/main/java/server/world/Converter.java b/server/src/main/java/server/world/Converter.java index c36d2217..e74e2d2b 100644 --- a/server/src/main/java/server/world/Converter.java +++ b/server/src/main/java/server/world/Converter.java @@ -1723,9 +1723,7 @@ public abstract class Converter { NbtTag sect = sections[y]; if(sect != null) { - byte[] newblks = new byte[4096]; - NibbleArray datanew = new NibbleArray(); - NibbleArray addnew = null; + byte[] newblks = new byte[4096 << 1]; for(int c = 0; c < blocks.length; ++c) { int cx = c & 15; int cy = c >> 8 & 15; @@ -1735,21 +1733,13 @@ public abstract class Converter { 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), cy == 15 ? (nextData == null ? 0 : nextData.get(cx, 0, cz)) : data.get(cx, cy + 1, cz)))]; - if(cd >> 12 != 0) { - if(addnew == null) - addnew = new NibbleArray(); - addnew.set(cx, cy, cz, cd >> 12); - } - newblks[c] = (byte)(cd & 255); - datanew.set(cx, cy, cz, cd >> 8 & 15); + newblks[c << 1] = (byte)((cd >> 8) & 255); + newblks[(c << 1) | 1] = (byte)(cd & 255); } TagObject nsect = new TagObject(); nsect.setInt("Y", y); - nsect.setByteArray("Dat0", newblks); - nsect.setByteArray("Dat1", datanew.getData()); - if(addnew != null) - nsect.setByteArray("Dat2", addnew.getData()); + nsect.setByteArray("Data", newblks); nsect.setByteArray("BlockLight", sect.getByteArray("BlockLight")); nsect.setByteArray("SkyLight", sect.getByteArray("SkyLight")); entities.add(nsect); diff --git a/server/src/main/java/server/world/Region.java b/server/src/main/java/server/world/Region.java index 75f88bc6..aee77994 100755 --- a/server/src/main/java/server/world/Region.java +++ b/server/src/main/java/server/world/Region.java @@ -496,17 +496,11 @@ public class Region { TagObject sect = sects.get(n); int y = sect.getInt("Y"); BlockArray storage = new BlockArray(y << 4, light, y < 0 ? world.dimension.getFiller() : null); - byte[] blocks = sect.getByteArray("Dat0"); - NibbleArray data = new NibbleArray(sect.getByteArray("Dat1")); - NibbleArray adddata = sect.hasByteArray("Dat2") ? new NibbleArray(sect.getByteArray("Dat2")) : null; - char[] seg = new char[blocks.length]; + byte[] blocks = sect.getByteArray("Data"); + char[] seg = new char[blocks.length >> 1]; for(int c = 0; c < seg.length; ++c) { - int cx = c & 15; - 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)]; + seg[c] = DECODE_MAP[(blocks[c << 1] & 255) << 8 | (blocks[(c << 1) | 1] & 255)]; } storage.setData(seg); @@ -608,34 +602,15 @@ public class Region { if(storage != null) { TagObject sect = new TagObject(); sect.setInt("Y", storage.getY() >> 4); - byte[] blocks = new byte[storage.getData().length]; - NibbleArray data = new NibbleArray(); - NibbleArray adddata = null; + byte[] blocks = new byte[storage.getData().length << 1]; for(int c = 0; c < storage.getData().length; ++c) { char cd = ENCODE_MAP[storage.getData()[c]]; - int cx = c & 15; - int cy = c >> 8 & 15; - 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); + blocks[c << 1] = (byte)((cd >> 8) & 255); + blocks[(c << 1) | 1] = (byte)(cd & 255); } - sect.setByteArray("Dat0", blocks); - sect.setByteArray("Dat1", data.getData()); - - if(adddata != null) { - sect.setByteArray("Dat2", adddata.getData()); - } + sect.setByteArray("Data", blocks); sect.setByteArray("BlockLight", storage.getBlocklight().getData());