Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-17 00:20:09 +01:00
fix: apply origin to sponge v3 schematics (#2909)
* fix(#2864) * Cherry-picked EngineHub/WorldEdit@cfd9eea Co-authored-by: Pierre Maurice Schwang <mail@pschwang.eu> * Allow metadata tags to be optional + default value for this.origin Co-authored-by: Pierre Maurice Schwang <mail@pschwang.eu> * Correct depth to be default of `0` Co-authored-by: Pierre Maurice Schwang <mail@pschwang.eu> --------- Co-authored-by: Pierre Maurice Schwang <mail@pschwang.eu>
Dieser Commit ist enthalten in:
Ursprung
7daafa97f0
Commit
8e1922dfe7
@ -41,6 +41,8 @@ import org.apache.logging.log4j.Logger;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.enginehub.linbus.tree.LinCompoundTag;
|
||||
import org.enginehub.linbus.tree.LinIntArrayTag;
|
||||
import org.enginehub.linbus.tree.LinTagType;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
@ -88,6 +90,7 @@ public class FastSchematicReaderV3 implements ClipboardReader {
|
||||
|
||||
private VersionedDataFixer dataFixer;
|
||||
private BlockVector3 offset;
|
||||
private BlockVector3 origin = BlockVector3.ZERO;
|
||||
private BlockState[] blockPalette;
|
||||
private BiomeType[] biomePalette;
|
||||
private int dataVersion = -1;
|
||||
@ -137,6 +140,24 @@ public class FastSchematicReaderV3 implements ClipboardReader {
|
||||
this.dataVersion = this.dataInputStream.readInt();
|
||||
this.dataFixer = ReaderUtil.getVersionedDataFixer(this.dataVersion, platform, platform.getDataVersion());
|
||||
}
|
||||
case "Metadata" -> {
|
||||
LinCompoundTag metadataCompoundTag =
|
||||
(LinCompoundTag) this.nbtInputStream.readTagPayload(NBTConstants.TYPE_COMPOUND, 0).toLinTag();
|
||||
|
||||
LinCompoundTag worldEditTag = metadataCompoundTag.findTag("WorldEdit", LinTagType.compoundTag());
|
||||
if (worldEditTag != null) { // allowed to be optional
|
||||
LinIntArrayTag originTag = worldEditTag.findTag("Origin", LinTagType.intArrayTag());
|
||||
if (originTag != null) { // allowed to be optional
|
||||
int[] parts = originTag.value();
|
||||
|
||||
if (parts.length != 3) {
|
||||
throw new IOException("`Metadata > WorldEdit > Origin` int array length is invalid.");
|
||||
}
|
||||
|
||||
this.origin = BlockVector3.at(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
case "Offset" -> {
|
||||
this.dataInputStream.skipNBytes(4); // Array Length field (4 byte int)
|
||||
this.offset = BlockVector3.at(
|
||||
@ -173,7 +194,7 @@ public class FastSchematicReaderV3 implements ClipboardReader {
|
||||
|
||||
clipboard.setOrigin(this.offset.multiply(-1));
|
||||
if (clipboard instanceof SimpleClipboard simpleClipboard && !this.offset.equals(BlockVector3.ZERO)) {
|
||||
clipboard = new BlockArrayClipboard(simpleClipboard, this.offset);
|
||||
clipboard = new BlockArrayClipboard(simpleClipboard, this.offset.add(this.origin));
|
||||
}
|
||||
return clipboard;
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ public class SpongeSchematicV3Reader implements ClipboardReader {
|
||||
Map<Integer, BlockState> palette = ReaderUtil.decodePalette(paletteObject, fixer);
|
||||
|
||||
byte[] blocks = blockContainer.getTag("Data", LinTagType.byteArrayTag()).value();
|
||||
LinListTag<LinCompoundTag> blockEntities = blockContainer.getListTag("BlockEntities", LinTagType.compoundTag());
|
||||
LinListTag<LinCompoundTag> blockEntities = blockContainer.findListTag("BlockEntities", LinTagType.compoundTag());
|
||||
|
||||
ReaderUtil.initializeClipboardFromBlocks(clipboard, palette, blocks, blockEntities, fixer, true);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren