Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Sponge Schematic v3 #2776

Merged
merged 46 commits into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
56ae44b
Update to Sponge Schematic 3
octylFractal May 19, 2021
ff08ab8
Licenses lol
octylFractal May 29, 2021
f321632
Fix imports
octylFractal May 29, 2021
5ba7b1f
Update for final changes
octylFractal May 29, 2021
1f73309
chore: ensure flushed clipboard in spongev2 writer
PierreSchwang Jun 9, 2024
e53d3b6
feat: initial work on FastSchematicWriterV2
PierreSchwang Jun 9, 2024
a9c8961
fix: only write into palette once, write into data as varint
PierreSchwang Jun 9, 2024
ff58021
chore: more work on FastSchematicWriterV3
PierreSchwang Jun 9, 2024
c35cd6e
fix: make FastSchematicWriterV3 work
PierreSchwang Jun 10, 2024
7905ee0
fix/chore: write pos as doubles
PierreSchwang Jun 10, 2024
f740ab0
chore: start on reader (class exists at least)
PierreSchwang Jun 11, 2024
cd110f5
chore: replace while loop with simple if as char can be max 2 bytes
PierreSchwang Jun 11, 2024
500812e
Merge remote-tracking branch 'origin/main' into feat/spongeSchemV3
PierreSchwang Jun 12, 2024
870a96e
chore/feat: more work on the fast v3 reader
PierreSchwang Jun 16, 2024
9d7446c
Merge remote-tracking branch 'origin/main' into feat/spongeSchemV3
PierreSchwang Jun 16, 2024
b4b427b
fix: offset must be inverted for origin
PierreSchwang Jun 16, 2024
b150c69
chore: use the actual FileChannel for mark / reset (if present)
PierreSchwang Jun 16, 2024
204a2fc
chore: add null check again
PierreSchwang Jun 16, 2024
9bb0449
chore: buffer streams in isFormat check
PierreSchwang Jun 16, 2024
7b333a9
Merge branch 'main' into feat/spongeSchemV3
PierreSchwang Jun 17, 2024
60cc424
chore/feat: read schematic fully
PierreSchwang Jun 17, 2024
8de3172
chore: don't hold a lazyreference (seems harder to gc with already co…
PierreSchwang Jun 17, 2024
ced11b3
chore: remove debugs
PierreSchwang Jun 17, 2024
408e6fe
chore: optimize FastSchematicReaderV3
PierreSchwang Jun 20, 2024
526c333
chore: remove logger warn for now
PierreSchwang Jun 20, 2024
84ea606
Merge remote-tracking branch 'origin/main' into feat/spongeSchemV3
PierreSchwang Jun 20, 2024
0f3b81f
chore: constant not required anymore
PierreSchwang Jun 20, 2024
fae46c6
chore/feat: support non-file based inputstreams (using in memory LZ4 …
PierreSchwang Jun 22, 2024
c039ae8
chore: don't wrap streams unnecessary
PierreSchwang Jun 23, 2024
510dee4
chore: cleanup
PierreSchwang Jun 23, 2024
ccad438
chore: since comment for reader + writer
PierreSchwang Jun 23, 2024
6b588ea
Merge remote-tracking branch 'origin/main' into feat/spongeSchemV3
PierreSchwang Jun 23, 2024
aa10950
chore: FAST_V3 not for testing anymore
PierreSchwang Jun 23, 2024
e4faefe
Merge remote-tracking branch 'origin/main' into feat/spongeSchemV3
PierreSchwang Jun 26, 2024
b1e791a
chore: update schematic and clipboard logic for linbus changes
PierreSchwang Jun 26, 2024
5aae0c8
chore: undo format check on load
PierreSchwang Jun 26, 2024
7e6df48
fix: remove usages of old nbt types
PierreSchwang Jun 26, 2024
5722ea2
fix: use LinBus in FaweDelegateSchematicHandler
PierreSchwang Jun 26, 2024
ce46993
Merge remote-tracking branch 'origin/main' into feat/spongeSchemV3
PierreSchwang Jun 27, 2024
c63706d
fix: use ReaderUtil again
PierreSchwang Jun 29, 2024
97e8e95
chore: update supported schematic types for Arkitektonika
PierreSchwang Jun 29, 2024
01ade09
chore: check for magic bytes in schematic (not tested yet)
PierreSchwang Jun 30, 2024
8f4c2d5
revert: magic bytes check
PierreSchwang Jun 30, 2024
3fbf1cf
fix: fix paletteAlreadyInitialized + biome placement on linear clipbo…
PierreSchwang Jun 30, 2024
f1f5ed1
Update worldedit-core/src/main/java/com/fastasyncworldedit/core/exten…
PierreSchwang Jul 5, 2024
a3caeb7
Merge branch 'main' into feat/spongeSchemV3
PierreSchwang Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
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;
Expand All @@ -29,17 +29,19 @@
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;
Expand Down Expand Up @@ -182,7 +184,7 @@ public boolean save(CompoundTag tag, String path) {
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);
Expand Down Expand Up @@ -239,7 +241,7 @@ public void run(OutputStream output) {

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);
Expand All @@ -249,8 +251,8 @@ public Schematic getSchematic(@Nonnull InputStream is) {
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
/**
* Reads schematic files using the Sponge Schematic Specification.
*/
public class FastSchematicReader extends NBTSchematicReader {
public class FastSchematicReaderV2 extends NBTSchematicReader {

private static final Logger LOGGER = LogManagerCompat.getLogger();
private final NBTInputStream inputStream;
Expand Down Expand Up @@ -88,7 +88,7 @@ public class FastSchematicReader extends NBTSchematicReader {
*
* @param inputStream the input stream to read from
*/
public FastSchematicReader(NBTInputStream inputStream) {
public FastSchematicReaderV2(NBTInputStream inputStream) {
checkNotNull(inputStream);
this.inputStream = inputStream;
this.fixer = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.WORLD_EDITING).getDataFixer();
Expand Down
Loading
Loading