Move paperweight to BinaryTag

- Upstream put paperweight into master branch, which doesn't have BinaryTags
 - Fixes #1374
This commit is contained in:
dordsor21
2021-10-22 16:00:51 +01:00
parent 7b775ca57d
commit ae949d607b
7 changed files with 141 additions and 91 deletions

View File

@ -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) {

View File

@ -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(

View File

@ -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);

View File

@ -41,9 +41,11 @@ public interface DataFixer {
private FixTypes() {
}
public static FixType<CompoundTag> CHUNK = new FixType<>();
public static FixType<CompoundTag> BLOCK_ENTITY = new FixType<>();
public static FixType<CompoundTag> ENTITY = new FixType<>();
//FAWE start - BinaryTag
public static FixType<CompoundBinaryTag> CHUNK = new FixType<>();
public static FixType<CompoundBinaryTag> BLOCK_ENTITY = new FixType<>();
public static FixType<CompoundBinaryTag> ENTITY = new FixType<>();
//FAWE end
public static FixType<String> BLOCK_STATE = new FixType<>();
public static FixType<String> BIOME = new FixType<>();
public static FixType<String> ITEM_TYPE = new FixType<>();

View File

@ -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;
}
}