mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-06-23 00:06:54 +00:00
Support Sponge Schematic v3 (#2776)
* Update to Sponge Schematic 3 Includes a major refactoring of how schematics are read. (cherry picked from commit bd475b1d4acbcf2a95e5a8f3aee50d2fb2100ae8) * Licenses lol (cherry picked from commit a5ce8a47657aa987da8ca625cd658856d2eb3477) * Fix imports (cherry picked from commit e1892b7bd4ff0ca4592f8cb4e1b2d9363c4cd6ff) * Update for final changes (cherry picked from commit 2f6b50a4276b33b615d9dbc52e73e958308735f9) * chore: ensure flushed clipboard in spongev2 writer * feat: initial work on FastSchematicWriterV2 * fix: only write into palette once, write into data as varint * chore: more work on FastSchematicWriterV3 * fix: make FastSchematicWriterV3 work * fix/chore: write pos as doubles * chore: start on reader (class exists at least) * chore: replace while loop with simple if as char can be max 2 bytes * chore/feat: more work on the fast v3 reader * fix: offset must be inverted for origin * chore: use the actual FileChannel for mark / reset (if present) * chore: add null check again * chore: buffer streams in isFormat check * chore/feat: read schematic fully * chore: don't hold a lazyreference (seems harder to gc with already computed value?) * chore: remove debugs * chore: optimize FastSchematicReaderV3 * chore: remove logger warn for now * chore: constant not required anymore * chore/feat: support non-file based inputstreams (using in memory LZ4 cache) * chore: don't wrap streams unnecessary * chore: cleanup * chore: since comment for reader + writer * chore: FAST_V3 not for testing anymore * chore: update schematic and clipboard logic for linbus changes * chore: undo format check on load * fix: remove usages of old nbt types * fix: use LinBus in FaweDelegateSchematicHandler * fix: use ReaderUtil again * chore: update supported schematic types for Arkitektonika * chore: check for magic bytes in schematic (not tested yet) * revert: magic bytes check * fix: fix paletteAlreadyInitialized + biome placement on linear clipboards * Update worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriterV3.java --------- Co-authored-by: Octavia Togami <octavia.togami@gmail.com> Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
514da16d19
commit
1ec87e7092
@ -3,8 +3,8 @@ package com.fastasyncworldedit.bukkit.regions.plotsquared;
|
||||
import com.fastasyncworldedit.core.Fawe;
|
||||
import com.fastasyncworldedit.core.FaweAPI;
|
||||
import com.fastasyncworldedit.core.FaweCache;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReaderV2;
|
||||
import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriterV2;
|
||||
import com.fastasyncworldedit.core.jnbt.CompressedCompoundTag;
|
||||
import com.fastasyncworldedit.core.jnbt.CompressedSchematicTag;
|
||||
import com.fastasyncworldedit.core.util.IOUtil;
|
||||
@ -29,17 +29,19 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.sponge.SpongeSchematicV3Reader;
|
||||
import com.sk89q.worldedit.internal.util.LogManagerCompat;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import net.jpountz.lz4.LZ4BlockInputStream;
|
||||
import org.anarres.parallelgzip.ParallelGZIPOutputStream;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.enginehub.linbus.stream.LinBinaryIO;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.EOFException;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
@ -182,7 +184,7 @@ public class FaweDelegateSchematicHandler {
|
||||
try (OutputStream stream = new FileOutputStream(tmp);
|
||||
NBTOutputStream output = new NBTOutputStream(
|
||||
new BufferedOutputStream(new ParallelGZIPOutputStream(stream)))) {
|
||||
new FastSchematicWriter(output).write(clipboard);
|
||||
new FastSchematicWriterV2(output).write(clipboard);
|
||||
}
|
||||
} else {
|
||||
try (OutputStream stream = new FileOutputStream(tmp);
|
||||
@ -239,7 +241,7 @@ public class FaweDelegateSchematicHandler {
|
||||
|
||||
public Schematic getSchematic(@Nonnull InputStream is) {
|
||||
try {
|
||||
FastSchematicReader schematicReader = new FastSchematicReader(
|
||||
FastSchematicReaderV2 schematicReader = new FastSchematicReaderV2(
|
||||
new NBTInputStream(new BufferedInputStream(new GZIPInputStream(new BufferedInputStream(is)))));
|
||||
Clipboard clip = schematicReader.read();
|
||||
return new Schematic(clip);
|
||||
@ -249,8 +251,8 @@ public class FaweDelegateSchematicHandler {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
SpongeSchematicReader schematicReader =
|
||||
new SpongeSchematicReader(new NBTInputStream(new GZIPInputStream(is)));
|
||||
SpongeSchematicV3Reader schematicReader =
|
||||
new SpongeSchematicV3Reader(LinBinaryIO.read(new DataInputStream(new GZIPInputStream(is))));
|
||||
Clipboard clip = schematicReader.read();
|
||||
return new Schematic(clip);
|
||||
} catch (IOException e2) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package com.fastasyncworldedit.bukkit.util;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
import it.unimi.dsi.fastutil.io.FastBufferedInputStream;
|
||||
import it.unimi.dsi.fastutil.io.FastBufferedOutputStream;
|
||||
import it.unimi.dsi.fastutil.longs.Long2ObjectLinkedOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.longs.LongArraySet;
|
||||
import it.unimi.dsi.fastutil.longs.LongIterator;
|
||||
@ -19,5 +21,7 @@ final class DoNotMiniseThese {
|
||||
private final LongSet d = null;
|
||||
private final Int2ObjectMap<?> e = null;
|
||||
private final Object2ObjectArrayMap<?, ?> f = null;
|
||||
private final FastBufferedInputStream g = null;
|
||||
private final FastBufferedOutputStream h = null;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user