mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Update SpongeSchematicReader.java
This commit is contained in:
parent
88b6d60f8e
commit
23e0b0ef02
@ -60,6 +60,7 @@ import net.jpountz.lz4.LZ4BlockOutputStream;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.io.DataInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -228,6 +229,17 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
});
|
});
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private BlockState getBlockState(int id) {
|
||||||
|
return BlockTypes.states[palette[id]];
|
||||||
|
}
|
||||||
|
|
||||||
|
private BiomeType getBiomeType(FaweInputStream fis) throws IOException {
|
||||||
|
char biomeId = biomePalette[fis.readVarInt()];
|
||||||
|
BiomeType biome = BiomeTypes.get(biomeId);
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Clipboard read(UUID uuid, Function<BlockVector3, Clipboard> createOutput) throws IOException {
|
public Clipboard read(UUID uuid, Function<BlockVector3, Clipboard> createOutput) throws IOException {
|
||||||
StreamDelegate root = createDelegate();
|
StreamDelegate root = createDelegate();
|
||||||
@ -236,32 +248,58 @@ public class SpongeSchematicReader extends NBTSchematicReader {
|
|||||||
Clipboard clipboard = createOutput.apply(dimensions);
|
Clipboard clipboard = createOutput.apply(dimensions);
|
||||||
|
|
||||||
BlockVector3 origin = min;
|
BlockVector3 origin = min;
|
||||||
CuboidRegion region;
|
|
||||||
if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) {
|
if (offsetX != Integer.MIN_VALUE && offsetY != Integer.MIN_VALUE && offsetZ != Integer.MIN_VALUE) {
|
||||||
origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ));
|
origin = origin.subtract(BlockVector3.at(offsetX, offsetY, offsetZ));
|
||||||
}
|
}
|
||||||
region = new CuboidRegion(min, min.add(width, height, length).subtract(BlockVector3.ONE));
|
|
||||||
if (blocksOut.getSize() != 0) {
|
if (blocksOut.getSize() != 0) {
|
||||||
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) {
|
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(blocksOut.toByteArrays())))) {
|
||||||
int volume = width * height * length;
|
if (clipboard instanceof LinearClipboard) {
|
||||||
if (palette.length < 128) {
|
LinearClipboard linear = (LinearClipboard) clipboard;
|
||||||
for (int index = 0; index < volume; index++) {
|
int volume = width * height * length;
|
||||||
BlockState state = BlockTypes.states[palette[fis.read()]];
|
if (palette.length < 128) {
|
||||||
clipboard.setBlock(index, state);
|
for (int index = 0; index < volume; index++) {
|
||||||
|
linear.setBlock(index, getBlockState(fis.read()));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int index = 0; index < volume; index++) {
|
||||||
|
linear.setBlock(index, getBlockState(fis.readVarInt()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (int index = 0; index < volume; index++) {
|
if (palette.length < 128) {
|
||||||
BlockState state = BlockTypes.states[palette[fis.readVarInt()]];
|
for (int y = 0; y < height; y++) {
|
||||||
clipboard.setBlock(index, state);
|
for (int z = 0; z < length; z++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
clipboard.setBlock(x, y, z, getBlockState(fis.read()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int y = 0; y < height; y++) {
|
||||||
|
for (int z = 0; z < length; z++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
clipboard.setBlock(x, y, z, getBlockState(fis.readVarInt()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (biomesOut.getSize() != 0) {
|
if (biomesOut.getSize() != 0) {
|
||||||
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) {
|
try (FaweInputStream fis = new FaweInputStream(new LZ4BlockInputStream(new FastByteArraysInputStream(biomesOut.toByteArrays())))) {
|
||||||
int volume = width * length;
|
if (clipboard instanceof LinearClipboard) {
|
||||||
for (int index = 0; index < volume; index++) {
|
LinearClipboard linear = (LinearClipboard) clipboard;
|
||||||
clipboard.setBiome(index, BiomeTypes.get(fis.read()));
|
int volume = width * length;
|
||||||
|
for (int index = 0; index < volume; index++) {
|
||||||
|
linear.setBiome(index, getBiomeType(fis));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int z = 0; z < length; z++) {
|
||||||
|
for (int x = 0; x < width; x++) {
|
||||||
|
clipboard.setBiome(x, 0, z, getBiomeType(fis));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user