some fixes

Use sponge schematic format instead of structure block
Fix VS undo running on main thread
Fix missing sections when setting blocks
This commit is contained in:
Jesse Boyd
2018-09-18 12:49:33 +10:00
parent 83464013ba
commit 5b5336cc83
19 changed files with 431 additions and 322 deletions

View File

@ -44,7 +44,7 @@ import java.util.function.Function;
*/
public final class NBTInputStream implements Closeable {
private final DataInput is;
private final DataInputStream is;
/**
* Creates a new {@code NBTInputStream}, which will source its data
@ -61,8 +61,8 @@ public final class NBTInputStream implements Closeable {
this.is = dis;
}
public NBTInputStream(DataInput di) {
this.is = di;
public DataInputStream getInputStream() {
return is;
}
/**
@ -178,7 +178,7 @@ public final class NBTInputStream implements Closeable {
NBTStreamer.ByteReader byteReader = (NBTStreamer.ByteReader) reader;
int i = 0;
if (is instanceof InputStream) {
DataInputStream dis = (DataInputStream) is;
DataInputStream dis = is;
if (length > 1024) {
if (buf == null) {
buf = new byte[1024];
@ -211,6 +211,8 @@ public final class NBTInputStream implements Closeable {
byteReader.run(i, is.readByte() & 0xFF);
}
}
} else if (reader instanceof NBTStreamer.LazyReader) {
reader.accept(length, is);
} else {
for (int i = 0; i < length; i++) {
reader.accept(i, is.readByte());
@ -273,6 +275,8 @@ public final class NBTInputStream implements Closeable {
for (int i = 0; i < length; i++) {
byteReader.run(i, is.readInt());
}
} else if (reader instanceof NBTStreamer.LazyReader) {
reader.accept(length, is);
} else {
for (int i = 0; i < length; i++) {
reader.accept(i, is.readInt());
@ -296,6 +300,8 @@ public final class NBTInputStream implements Closeable {
for (int i = 0; i < length; i++) {
longReader.run(i, is.readLong());
}
} else if (reader instanceof NBTStreamer.LazyReader) {
reader.accept(length, is);
} else {
for (int i = 0; i < length; i++) {
reader.accept(i, is.readLong());

View File

@ -201,7 +201,7 @@ public final class NBTOutputStream implements Closeable {
* @param tag The tag.
* @throws IOException if an I/O error occurs.
*/
private void writeTagPayload(Tag tag) throws IOException {
public void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
case NBTConstants.TYPE_END:
@ -408,6 +408,4 @@ public final class NBTOutputStream implements Closeable {
public void flush() throws IOException {
if (os instanceof Flushable) ((Flushable) os).flush();
}
}