Attempted fix for NBT Data Fixer error (#1689)

This commit is contained in:
Matthew Miller 2021-03-11 10:04:00 +10:00 committed by GitHub
parent 79fe1deca9
commit 9a5ef70858
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 9 deletions

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.extent.clipboard.io; package com.sk89q.worldedit.extent.clipboard.io;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
@ -219,7 +220,7 @@ public Clipboard read() throws IOException {
} }
if (fixer != null && t != null) { if (fixer != null && t != null) {
t = fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, t, -1); t = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, t.asBinaryTag(), -1));
} }
BlockVector3 vec = BlockVector3.at(x, y, z); BlockVector3 vec = BlockVector3.at(x, y, z);
@ -274,7 +275,7 @@ public Clipboard read() throws IOException {
if (tag instanceof CompoundTag) { if (tag instanceof CompoundTag) {
CompoundTag compound = (CompoundTag) tag; CompoundTag compound = (CompoundTag) tag;
if (fixer != null) { if (fixer != null) {
compound = fixer.fixUp(DataFixer.FixTypes.ENTITY, compound, -1); compound = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.ENTITY, compound.asBinaryTag(), -1));
} }
String id = convertEntityId(compound.getString("id")); String id = convertEntityId(compound.getString("id"));
Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation")); Location location = NBTConversions.toLocation(clipboard, compound.getListTag("Pos"), compound.getListTag("Rotation"));

View File

@ -20,6 +20,7 @@
package com.sk89q.worldedit.extent.clipboard.io; package com.sk89q.worldedit.extent.clipboard.io;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntArrayTag; import com.sk89q.jnbt.IntArrayTag;
@ -247,7 +248,7 @@ private BlockArrayClipboard readVersion1(CompoundTag schematicTag) throws IOExce
values.remove("Id"); values.remove("Id");
values.remove("Pos"); values.remove("Pos");
if (fixer != null) { if (fixer != null) {
tileEntity = fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, new CompoundTag(values), dataVersion).getValue(); tileEntity = ((CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.BLOCK_ENTITY, new CompoundTag(values).asBinaryTag(), dataVersion))).getValue();
} else { } else {
tileEntity = values; tileEntity = values;
} }
@ -385,7 +386,7 @@ private void readEntities(BlockArrayClipboard clipboard, Map<String, Tag> schema
entityTag = entityTag.createBuilder().putString("id", id).remove("Id").build(); entityTag = entityTag.createBuilder().putString("id", id).remove("Id").build();
if (fixer != null) { if (fixer != null) {
entityTag = fixer.fixUp(DataFixer.FixTypes.ENTITY, entityTag, dataVersion); entityTag = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(DataFixer.FixTypes.ENTITY, entityTag.asBinaryTag(), dataVersion));
} }
EntityType entityType = EntityTypes.get(id); EntityType entityType = EntityTypes.get(id);

View File

@ -20,7 +20,7 @@
package com.sk89q.worldedit.world; package com.sk89q.worldedit.world;
import com.google.common.annotations.Beta; import com.google.common.annotations.Beta;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
/** /**
* This entire class is subject to heavy changes. Do not use this as API. * This entire class is subject to heavy changes. Do not use this as API.
@ -37,9 +37,9 @@ final class FixTypes {
private FixTypes() { private FixTypes() {
} }
public static FixType<CompoundTag> CHUNK = new FixType<>(); public static FixType<CompoundBinaryTag> CHUNK = new FixType<>();
public static FixType<CompoundTag> BLOCK_ENTITY = new FixType<>(); public static FixType<CompoundBinaryTag> BLOCK_ENTITY = new FixType<>();
public static FixType<CompoundTag> ENTITY = new FixType<>(); public static FixType<CompoundBinaryTag> ENTITY = new FixType<>();
public static FixType<String> BLOCK_STATE = new FixType<>(); public static FixType<String> BLOCK_STATE = new FixType<>();
public static FixType<String> BIOME = new FixType<>(); public static FixType<String> BIOME = new FixType<>();
public static FixType<String> ITEM_TYPE = new FixType<>(); public static FixType<String> ITEM_TYPE = new FixType<>();

View File

@ -19,6 +19,7 @@
package com.sk89q.worldedit.world.storage; package com.sk89q.worldedit.world.storage;
import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
@ -96,7 +97,7 @@ public static Chunk getChunk(CompoundTag rootTag) throws DataException {
if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks if (tag.getValue().containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks
final DataFixer dataFixer = platform.getDataFixer(); final DataFixer dataFixer = platform.getDataFixer();
if (dataFixer != null) { if (dataFixer != null) {
tag = (CompoundTag) dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag, dataVersion).getValue().get("Level"); tag = (CompoundTag) ((CompoundTag) AdventureNBTConverter.fromAdventure(dataFixer.fixUp(DataFixer.FixTypes.CHUNK, rootTag.asBinaryTag(), dataVersion))).getValue().get("Level");
dataVersion = currentDataVersion; dataVersion = currentDataVersion;
} }
} }