mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-02 11:26:42 +00:00
Fix fast schematic reader/writer
- Have both sponge and fast r/w available but default to "fast" - Correctly "offset" entities in the schematic, and add a legacy mode for loading old FAWE schematics with entities required. - Lazily reading means it's read in order of appearance in the inputstream so we need to read schematic version first (skip past everything) and then reset the stream. Fixes #740 - Add an FAWEVersion to the metadata - Correctly actually return a BlockArrayClipboard when required. Fixes #454
This commit is contained in:
@ -61,6 +61,14 @@ public final class NBTInputStream implements Closeable {
|
||||
this.is = dis;
|
||||
}
|
||||
|
||||
public void mark(int mark) {
|
||||
is.mark(mark);
|
||||
}
|
||||
|
||||
public void reset() throws IOException {
|
||||
is.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads an NBT tag from the stream.
|
||||
*
|
||||
@ -99,7 +107,7 @@ public final class NBTInputStream implements Closeable {
|
||||
if (child != null) {
|
||||
child.acceptRoot(this, type, 0);
|
||||
} else {
|
||||
readTagPaylodLazy(type, 0);
|
||||
readTagPayloadLazy(type, 0);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
@ -119,7 +127,7 @@ public final class NBTInputStream implements Closeable {
|
||||
|
||||
private byte[] buf;
|
||||
|
||||
public void readTagPaylodLazy(int type, int depth) throws IOException {
|
||||
public void readTagPayloadLazy(int type, int depth) throws IOException {
|
||||
switch (type) {
|
||||
case NBTConstants.TYPE_END:
|
||||
return;
|
||||
@ -152,7 +160,7 @@ public final class NBTInputStream implements Closeable {
|
||||
int childType = is.readByte();
|
||||
length = is.readInt();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
readTagPaylodLazy(childType, depth + 1);
|
||||
readTagPayloadLazy(childType, depth + 1);
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -165,7 +173,7 @@ public final class NBTInputStream implements Closeable {
|
||||
return;
|
||||
}
|
||||
is.skipBytes(is.readShort() & 0xFFFF);
|
||||
readTagPaylodLazy(childType, depth + 1);
|
||||
readTagPayloadLazy(childType, depth + 1);
|
||||
}
|
||||
}
|
||||
case NBTConstants.TYPE_INT_ARRAY: {
|
||||
@ -181,7 +189,7 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
}
|
||||
|
||||
public void readTagPaylodLazy(int type, int depth, StreamDelegate scope) throws IOException {
|
||||
public void readTagPayloadLazy(int type, int depth, StreamDelegate scope) throws IOException {
|
||||
switch (type) {
|
||||
case NBTConstants.TYPE_END:
|
||||
return;
|
||||
@ -293,11 +301,11 @@ public final class NBTInputStream implements Closeable {
|
||||
child = scope.get0();
|
||||
if (child == null) {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
readTagPaylodLazy(childType, depth + 1);
|
||||
readTagPayloadLazy(childType, depth + 1);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < length; ++i) {
|
||||
readTagPaylodLazy(childType, depth + 1, child);
|
||||
readTagPayloadLazy(childType, depth + 1, child);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -330,9 +338,9 @@ public final class NBTInputStream implements Closeable {
|
||||
}
|
||||
StreamDelegate child = scope.get(is);
|
||||
if (child == null) {
|
||||
readTagPaylodLazy(childType, depth + 1);
|
||||
readTagPayloadLazy(childType, depth + 1);
|
||||
} else {
|
||||
readTagPaylodLazy(childType, depth + 1, child);
|
||||
readTagPayloadLazy(childType, depth + 1, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user