Search in sources :

Example 1 with NBTOutputStream

use of cn.nukkit.nbt.stream.NBTOutputStream in project Nukkit by Nukkit.

the class Chunk method clone.

@Override
public BaseChunk clone() {
    Chunk chunk = (Chunk) super.clone();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    NBTOutputStream out = new NBTOutputStream(baos);
    try {
        nbt.write(out);
        NBTInputStream in = new NBTInputStream(new ByteArrayInputStream(baos.toByteArray()));
        chunk.nbt = new CompoundTag();
        chunk.nbt.load(in);
    } catch (IOException e) {
    }
    return chunk;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NBTInputStream(cn.nukkit.nbt.stream.NBTInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) BaseChunk(cn.nukkit.level.format.generic.BaseChunk) NBTOutputStream(cn.nukkit.nbt.stream.NBTOutputStream)

Aggregations

BaseChunk (cn.nukkit.level.format.generic.BaseChunk)1 NBTInputStream (cn.nukkit.nbt.stream.NBTInputStream)1 NBTOutputStream (cn.nukkit.nbt.stream.NBTOutputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1