Fix schem load

This commit is contained in:
Jesse Boyd 2019-11-01 23:48:52 +01:00
parent 09bb9c18ca
commit c2cb463dae
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 11 additions and 5 deletions

View File

@ -156,11 +156,11 @@ public class StreamDelegate {
}
public StreamDelegate withLong(LongValueReader valueReader) {
return withValue(valueReader);
return withElem(valueReader);
}
public StreamDelegate withInt(IntValueReader valueReader) {
return withValue(valueReader);
return withElem(valueReader);
}
public StreamDelegate withValue(ValueReader valueReader) {

View File

@ -183,6 +183,7 @@ public final class NBTInputStream implements Closeable {
return;
case NBTConstants.TYPE_BYTE: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
if (value != null) {
value.applyInt(0, is.readByte());
} else {
@ -192,6 +193,7 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_SHORT: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
if (value != null) {
value.applyInt(0, is.readShort());
} else {
@ -201,6 +203,7 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_INT: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
if (value != null) {
value.applyInt(0, is.readInt());
} else {
@ -210,6 +213,7 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_LONG: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
if (value != null) {
value.applyLong(0, is.readLong());
} else {
@ -219,6 +223,7 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_FLOAT: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
if (value != null) {
value.applyFloat(0, is.readFloat());
} else {
@ -228,6 +233,7 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_DOUBLE: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
if (value != null) {
value.applyDouble(0, is.readDouble());
} else {
@ -237,6 +243,7 @@ public final class NBTInputStream implements Closeable {
}
case NBTConstants.TYPE_STRING: {
ValueReader value = scope.getValueReader();
if (value == null) value = scope.getElemReader();
int length = is.readShort() & 0xFFFF;
if (value != null) {
byte[] bytes = new byte[length];

View File

@ -591,7 +591,6 @@ public class SchematicCommands {
String filter,
Arguments arguments
) throws WorldEditException {
if (formatName.isEmpty()) formatName = null;
if (oldFirst && newFirst) {
throw new StopExecutionException(TextComponent.of("Cannot sort by oldest and newest."));
}

View File

@ -251,7 +251,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) {
origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ));
}
if (blocksOut.getSize() != 0) {
if (blocksOut != null && blocksOut.getSize() != 0) {
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) {
if (clipboard instanceof LinearClipboard) {
LinearClipboard linear = (LinearClipboard) clipboard;
@ -286,7 +286,7 @@ public class SpongeSchematicReader extends NBTSchematicReader {
}
}
}
if (biomesOut.getSize() != 0) {
if (biomesOut != null && biomesOut.getSize() != 0) {
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) {
if (clipboard instanceof LinearClipboard) {
LinearClipboard linear = (LinearClipboard) clipboard;