From ae949d607b5d2c88f8e12435e1aeb69795e080ea Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Fri, 22 Oct 2021 16:00:51 +0100 Subject: [PATCH] Move paperweight to BinaryTag - Upstream put paperweight into master branch, which doesn't have BinaryTags - Fixes #1374 --- .../adapter/ext/fawe/PaperweightAdapter.java | 138 +++++++++--------- .../ext/fawe/PaperweightDataConverters.java | 28 ++-- .../clipboard/io/FastSchematicReader.java | 17 ++- .../clipboard/io/MCEditSchematicReader.java | 17 ++- .../clipboard/io/SpongeSchematicReader.java | 17 ++- .../com/sk89q/worldedit/world/DataFixer.java | 8 +- .../world/storage/ChunkStoreHelper.java | 7 +- 7 files changed, 141 insertions(+), 91 deletions(-) diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java index eb7c06d16..3df9758e9 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightAdapter.java @@ -30,21 +30,7 @@ import com.mojang.datafixers.util.Either; import com.mojang.serialization.Codec; import com.mojang.serialization.Dynamic; import com.mojang.serialization.Lifecycle; -import com.sk89q.jnbt.ByteArrayTag; -import com.sk89q.jnbt.ByteTag; import com.sk89q.jnbt.CompoundTag; -import com.sk89q.jnbt.DoubleTag; -import com.sk89q.jnbt.EndTag; -import com.sk89q.jnbt.FloatTag; -import com.sk89q.jnbt.IntArrayTag; -import com.sk89q.jnbt.IntTag; -import com.sk89q.jnbt.ListTag; -import com.sk89q.jnbt.LongArrayTag; -import com.sk89q.jnbt.LongTag; -import com.sk89q.jnbt.NBTConstants; -import com.sk89q.jnbt.ShortTag; -import com.sk89q.jnbt.StringTag; -import com.sk89q.jnbt.Tag; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItemStack; @@ -70,7 +56,20 @@ import com.sk89q.worldedit.util.SideEffect; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.io.file.SafeFiles; +import com.sk89q.worldedit.util.nbt.BinaryTag; +import com.sk89q.worldedit.util.nbt.ByteArrayBinaryTag; +import com.sk89q.worldedit.util.nbt.ByteBinaryTag; import com.sk89q.worldedit.util.nbt.CompoundBinaryTag; +import com.sk89q.worldedit.util.nbt.DoubleBinaryTag; +import com.sk89q.worldedit.util.nbt.EndBinaryTag; +import com.sk89q.worldedit.util.nbt.FloatBinaryTag; +import com.sk89q.worldedit.util.nbt.IntArrayBinaryTag; +import com.sk89q.worldedit.util.nbt.IntBinaryTag; +import com.sk89q.worldedit.util.nbt.ListBinaryTag; +import com.sk89q.worldedit.util.nbt.LongArrayBinaryTag; +import com.sk89q.worldedit.util.nbt.LongBinaryTag; +import com.sk89q.worldedit.util.nbt.ShortBinaryTag; +import com.sk89q.worldedit.util.nbt.StringBinaryTag; import com.sk89q.worldedit.world.DataFixer; import com.sk89q.worldedit.world.RegenOptions; import com.sk89q.worldedit.world.biome.BiomeType; @@ -342,7 +341,9 @@ public final class PaperweightAdapter implements BukkitImplAdapter values = new HashMap<>(); + Map values = new HashMap<>(); Set foreignKeys = ((net.minecraft.nbt.CompoundTag) foreign).getAllKeys(); for (String str : foreignKeys) { net.minecraft.nbt.Tag base = ((net.minecraft.nbt.CompoundTag) foreign).get(str); - values.put(str, toNative(base)); + values.put(str, toNativeBinary(base)); } - return new CompoundTag(values); + return CompoundBinaryTag.from(values); } else if (foreign instanceof net.minecraft.nbt.ByteTag) { - return new ByteTag(((net.minecraft.nbt.ByteTag) foreign).getAsByte()); + return ByteBinaryTag.of(((net.minecraft.nbt.ByteTag) foreign).getAsByte()); } else if (foreign instanceof net.minecraft.nbt.ByteArrayTag) { - return new ByteArrayTag(((net.minecraft.nbt.ByteArrayTag) foreign).getAsByteArray()); + return ByteArrayBinaryTag.of(((net.minecraft.nbt.ByteArrayTag) foreign).getAsByteArray()); } else if (foreign instanceof net.minecraft.nbt.DoubleTag) { - return new DoubleTag(((net.minecraft.nbt.DoubleTag) foreign).getAsDouble()); + return DoubleBinaryTag.of(((net.minecraft.nbt.DoubleTag) foreign).getAsDouble()); } else if (foreign instanceof net.minecraft.nbt.FloatTag) { - return new FloatTag(((net.minecraft.nbt.FloatTag) foreign).getAsFloat()); + return FloatBinaryTag.of(((net.minecraft.nbt.FloatTag) foreign).getAsFloat()); } else if (foreign instanceof net.minecraft.nbt.IntTag) { - return new IntTag(((net.minecraft.nbt.IntTag) foreign).getAsInt()); + return IntBinaryTag.of(((net.minecraft.nbt.IntTag) foreign).getAsInt()); } else if (foreign instanceof net.minecraft.nbt.IntArrayTag) { - return new IntArrayTag(((net.minecraft.nbt.IntArrayTag) foreign).getAsIntArray()); + return IntArrayBinaryTag.of(((net.minecraft.nbt.IntArrayTag) foreign).getAsIntArray()); } else if (foreign instanceof net.minecraft.nbt.LongArrayTag) { - return new LongArrayTag(((net.minecraft.nbt.LongArrayTag) foreign).getAsLongArray()); + return LongArrayBinaryTag.of(((net.minecraft.nbt.LongArrayTag) foreign).getAsLongArray()); } else if (foreign instanceof net.minecraft.nbt.ListTag) { try { return toNativeList((net.minecraft.nbt.ListTag) foreign); } catch (Throwable e) { logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e); - return new ListTag(ByteTag.class, new ArrayList()); + return ListBinaryTag.empty(); } } else if (foreign instanceof net.minecraft.nbt.LongTag) { - return new LongTag(((net.minecraft.nbt.LongTag) foreign).getAsLong()); + return LongBinaryTag.of(((net.minecraft.nbt.LongTag) foreign).getAsLong()); } else if (foreign instanceof net.minecraft.nbt.ShortTag) { - return new ShortTag(((net.minecraft.nbt.ShortTag) foreign).getAsShort()); + return ShortBinaryTag.of(((net.minecraft.nbt.ShortTag) foreign).getAsShort()); } else if (foreign instanceof net.minecraft.nbt.StringTag) { - return new StringTag(foreign.getAsString()); + return StringBinaryTag.of(foreign.getAsString()); } else if (foreign instanceof net.minecraft.nbt.EndTag) { - return new EndTag(); + return EndBinaryTag.get(); } else { throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName()); } @@ -891,16 +895,14 @@ public final class PaperweightAdapter implements BukkitImplAdapter values = new ArrayList<>(); - int type = foreign.getElementType(); + private ListBinaryTag toNativeList(net.minecraft.nbt.ListTag foreign) throws SecurityException, IllegalArgumentException { + ListBinaryTag.Builder values = ListBinaryTag.builder(); for (net.minecraft.nbt.Tag tag : foreign) { - values.add(toNative(tag)); + values.add(toNativeBinary(tag)); } - Class cls = NBTConstants.getClassFromType(type); - return new ListTag(cls, values); + return values.build(); } /** @@ -910,50 +912,50 @@ public final class PaperweightAdapter implements BukkitImplAdapter entry : ((CompoundTag) foreign) - .getValue().entrySet()) { - tag.put(entry.getKey(), fromNative(entry.getValue())); + for (String key : ((CompoundBinaryTag) foreign).keySet()) { + tag.put(key, fromNativeBinary(((CompoundBinaryTag) foreign).get(key))); } return tag; - } else if (foreign instanceof ByteTag) { - return net.minecraft.nbt.ByteTag.valueOf(((ByteTag) foreign).getValue()); - } else if (foreign instanceof ByteArrayTag) { - return new net.minecraft.nbt.ByteArrayTag(((ByteArrayTag) foreign).getValue()); - } else if (foreign instanceof DoubleTag) { - return net.minecraft.nbt.DoubleTag.valueOf(((DoubleTag) foreign).getValue()); - } else if (foreign instanceof FloatTag) { - return net.minecraft.nbt.FloatTag.valueOf(((FloatTag) foreign).getValue()); - } else if (foreign instanceof IntTag) { - return net.minecraft.nbt.IntTag.valueOf(((IntTag) foreign).getValue()); - } else if (foreign instanceof IntArrayTag) { - return new net.minecraft.nbt.IntArrayTag(((IntArrayTag) foreign).getValue()); - } else if (foreign instanceof LongArrayTag) { - return new net.minecraft.nbt.LongArrayTag(((LongArrayTag) foreign).getValue()); - } else if (foreign instanceof ListTag) { + } else if (foreign instanceof ByteBinaryTag) { + return net.minecraft.nbt.ByteTag.valueOf(((ByteBinaryTag) foreign).value()); + } else if (foreign instanceof ByteArrayBinaryTag) { + return new net.minecraft.nbt.ByteArrayTag(((ByteArrayBinaryTag) foreign).value()); + } else if (foreign instanceof DoubleBinaryTag) { + return net.minecraft.nbt.DoubleTag.valueOf(((DoubleBinaryTag) foreign).value()); + } else if (foreign instanceof FloatBinaryTag) { + return net.minecraft.nbt.FloatTag.valueOf(((FloatBinaryTag) foreign).value()); + } else if (foreign instanceof IntBinaryTag) { + return net.minecraft.nbt.IntTag.valueOf(((IntBinaryTag) foreign).value()); + } else if (foreign instanceof IntArrayBinaryTag) { + return new net.minecraft.nbt.IntArrayTag(((IntArrayBinaryTag) foreign).value()); + } else if (foreign instanceof LongArrayBinaryTag) { + return new net.minecraft.nbt.LongArrayTag(((LongArrayBinaryTag) foreign).value()); + } else if (foreign instanceof ListBinaryTag) { net.minecraft.nbt.ListTag tag = new net.minecraft.nbt.ListTag(); - ListTag foreignList = (ListTag) foreign; - for (Tag t : foreignList.getValue()) { - tag.add(fromNative(t)); + ListBinaryTag foreignList = (ListBinaryTag) foreign; + for (BinaryTag t : foreignList) { + tag.add(fromNativeBinary(t)); } return tag; - } else if (foreign instanceof LongTag) { - return net.minecraft.nbt.LongTag.valueOf(((LongTag) foreign).getValue()); - } else if (foreign instanceof ShortTag) { - return net.minecraft.nbt.ShortTag.valueOf(((ShortTag) foreign).getValue()); - } else if (foreign instanceof StringTag) { - return net.minecraft.nbt.StringTag.valueOf(((StringTag) foreign).getValue()); - } else if (foreign instanceof EndTag) { + } else if (foreign instanceof LongBinaryTag) { + return net.minecraft.nbt.LongTag.valueOf(((LongBinaryTag) foreign).value()); + } else if (foreign instanceof ShortBinaryTag) { + return net.minecraft.nbt.ShortTag.valueOf(((ShortBinaryTag) foreign).value()); + } else if (foreign instanceof StringBinaryTag) { + return net.minecraft.nbt.StringTag.valueOf(((StringBinaryTag) foreign).value()); + } else if (foreign instanceof EndBinaryTag) { return net.minecraft.nbt.EndTag.INSTANCE; } else { throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName()); } } + //FAWE end @Override public boolean supportsWatchdog() { diff --git a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java index b21fa7dde..6678bdc52 100644 --- a/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java +++ b/worldedit-bukkit/adapters/adapter-1_17_1/src/main/java/com/sk89q/worldedit/bukkit/adapter/ext/fawe/PaperweightDataConverters.java @@ -34,7 +34,7 @@ import com.mojang.datafixers.DataFixer; import com.mojang.datafixers.DataFixerBuilder; import com.mojang.datafixers.schemas.Schema; import com.mojang.serialization.Dynamic; -import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.util.nbt.CompoundBinaryTag; import net.minecraft.core.Direction; import net.minecraft.nbt.NbtOps; import net.minecraft.network.chat.Component; @@ -78,15 +78,16 @@ import java.util.stream.Collectors; @SuppressWarnings({"rawtypes", "unchecked"}) class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer { + //FAWE start - BinaryTag @SuppressWarnings("unchecked") @Override public T fixUp(FixType type, T original, int srcVer) { if (type == FixTypes.CHUNK) { - return (T) fixChunk((CompoundTag) original, srcVer); + return (T) fixChunk((CompoundBinaryTag) original, srcVer); } else if (type == FixTypes.BLOCK_ENTITY) { - return (T) fixBlockEntity((CompoundTag) original, srcVer); + return (T) fixBlockEntity((CompoundBinaryTag) original, srcVer); } else if (type == FixTypes.ENTITY) { - return (T) fixEntity((CompoundTag) original, srcVer); + return (T) fixEntity((CompoundBinaryTag) original, srcVer); } else if (type == FixTypes.BLOCK_STATE) { return (T) fixBlockState((String) original, srcVer); } else if (type == FixTypes.ITEM_TYPE) { @@ -97,23 +98,24 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo return original; } - private CompoundTag fixChunk(CompoundTag originalChunk, int srcVer) { - net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNative(originalChunk); + private CompoundBinaryTag fixChunk(CompoundBinaryTag originalChunk, int srcVer) { + net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNativeBinary(originalChunk); net.minecraft.nbt.CompoundTag fixed = convert(LegacyType.CHUNK, tag, srcVer); - return (CompoundTag) adapter.toNative(fixed); + return (CompoundBinaryTag) adapter.toNativeBinary(fixed); } - private CompoundTag fixBlockEntity(CompoundTag origTileEnt, int srcVer) { - net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNative(origTileEnt); + private CompoundBinaryTag fixBlockEntity(CompoundBinaryTag origTileEnt, int srcVer) { + net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNativeBinary(origTileEnt); net.minecraft.nbt.CompoundTag fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer); - return (CompoundTag) adapter.toNative(fixed); + return (CompoundBinaryTag) adapter.toNativeBinary(fixed); } - private CompoundTag fixEntity(CompoundTag origEnt, int srcVer) { - net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNative(origEnt); + private CompoundBinaryTag fixEntity(CompoundBinaryTag origEnt, int srcVer) { + net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNativeBinary(origEnt); net.minecraft.nbt.CompoundTag fixed = convert(LegacyType.ENTITY, tag, srcVer); - return (CompoundTag) adapter.toNative(fixed); + return (CompoundBinaryTag) adapter.toNativeBinary(fixed); } + //FAWE end private String fixBlockState(String blockState, int srcVer) { net.minecraft.nbt.CompoundTag stateNBT = stateToNBT(blockState); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java index 0f4351660..9b755ee3d 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicReader.java @@ -9,6 +9,7 @@ import com.fastasyncworldedit.core.internal.io.FaweInputStream; import com.fastasyncworldedit.core.internal.io.FaweOutputStream; import com.fastasyncworldedit.core.jnbt.streamer.StreamDelegate; import com.fastasyncworldedit.core.jnbt.streamer.ValueReader; +import com.sk89q.jnbt.AdventureNBTConverter; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.NBTInputStream; @@ -108,14 +109,26 @@ public class FastSchematicReader extends NBTSchematicReader { if (fixer == null || dataVersion == -1) { return tag; } - return fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, tag, dataVersion); + //FAWE start - BinaryTag + return (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp( + DataFixer.FixTypes.BLOCK_ENTITY, + tag.asBinaryTag(), + dataVersion + )); + //FAWE end } private CompoundTag fixEntity(CompoundTag tag) { if (fixer == null || dataVersion == -1) { return tag; } - return fixer.fixUp(DataFixer.FixTypes.ENTITY, tag, dataVersion); + //FAWE start - BinaryTag + return (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp( + DataFixer.FixTypes.ENTITY, + tag.asBinaryTag(), + dataVersion + )); + //FAWE end } private String fixBiome(String biomePalettePart) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java index 17adaae10..2c743fd74 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/MCEditSchematicReader.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.google.common.collect.ImmutableList; +import com.sk89q.jnbt.AdventureNBTConverter; import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntTag; @@ -228,7 +229,13 @@ public class MCEditSchematicReader extends NBTSchematicReader { } if (fixer != null && t != null) { - t = fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, t, -1); + //FAWE start - BinaryTag + t = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp( + DataFixer.FixTypes.BLOCK_ENTITY, + t.asBinaryTag(), + -1 + )); + //FAWE end } BlockVector3 vec = BlockVector3.at(x, y, z); @@ -289,7 +296,13 @@ public class MCEditSchematicReader extends NBTSchematicReader { if (tag instanceof CompoundTag) { CompoundTag compound = (CompoundTag) tag; if (fixer != null) { - compound = fixer.fixUp(DataFixer.FixTypes.ENTITY, compound, -1); + //FAWE start - BinaryTag + compound = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp( + DataFixer.FixTypes.ENTITY, + compound.asBinaryTag(), + -1 + )); + //FAWE end } String id = convertEntityId(compound.getString("id")); Location location = NBTConversions.toLocation( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index 6971e440d..9ad799b4c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.extent.clipboard.io; import com.google.common.collect.Maps; +import com.sk89q.jnbt.AdventureNBTConverter; import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.IntArrayTag; @@ -270,7 +271,13 @@ public class SpongeSchematicReader extends NBTSchematicReader { values.remove("Id"); values.remove("Pos"); if (fixer != null) { - tileEntity = fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, new CompoundTag(values), dataVersion).getValue(); + //FAWE start - BinaryTag + tileEntity = ((CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp( + DataFixer.FixTypes.BLOCK_ENTITY, + new CompoundTag(values).asBinaryTag(), + dataVersion + ))).getValue(); + //FAWE end } else { tileEntity = values; } @@ -411,7 +418,13 @@ public class SpongeSchematicReader extends NBTSchematicReader { entityTag = entityTag.createBuilder().putString("id", id).remove("Id").build(); if (fixer != null) { - entityTag = fixer.fixUp(DataFixer.FixTypes.ENTITY, entityTag, dataVersion); + //FAWE start - BinaryTag + entityTag = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp( + DataFixer.FixTypes.ENTITY, + entityTag.asBinaryTag(), + dataVersion + )); + //FAWE end } EntityType entityType = EntityTypes.get(id); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/DataFixer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/DataFixer.java index 7e1f05cce..5b69ddff0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/DataFixer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/DataFixer.java @@ -41,9 +41,11 @@ public interface DataFixer { private FixTypes() { } - public static FixType CHUNK = new FixType<>(); - public static FixType BLOCK_ENTITY = new FixType<>(); - public static FixType ENTITY = new FixType<>(); + //FAWE start - BinaryTag + public static FixType CHUNK = new FixType<>(); + public static FixType BLOCK_ENTITY = new FixType<>(); + public static FixType ENTITY = new FixType<>(); + //FAWE end public static FixType BLOCK_STATE = new FixType<>(); public static FixType BIOME = new FixType<>(); public static FixType ITEM_TYPE = new FixType<>(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreHelper.java index 792a139ec..00970efd3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/storage/ChunkStoreHelper.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.world.storage; +import com.sk89q.jnbt.AdventureNBTConverter; import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.Tag; @@ -119,7 +120,11 @@ public class ChunkStoreHelper { .containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks final DataFixer dataFixer = platform.getDataFixer(); if (dataFixer != null) { - tag = (CompoundTag) dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag, dataVersion).getValue().get("Level"); + //FAWE start - BinaryTag + tag = (CompoundTag) AdventureNBTConverter.fromAdventure(dataFixer + .fixUp(DataFixer.FixTypes.CHUNK, rootTag.asBinaryTag(), dataVersion) + .get("Level")); + //FAWE end dataVersion = currentDataVersion; } }