3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-03 01:50:07 +01:00

Move paperweight to BinaryTag

- Upstream put paperweight into master branch, which doesn't have BinaryTags
 - Fixes #1374
Dieser Commit ist enthalten in:
dordsor21 2021-10-22 16:00:51 +01:00
Ursprung 7b775ca57d
Commit ae949d607b
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
7 geänderte Dateien mit 141 neuen und 91 gelöschten Zeilen

Datei anzeigen

@ -30,21 +30,7 @@ import com.mojang.datafixers.util.Either;
import com.mojang.serialization.Codec; import com.mojang.serialization.Codec;
import com.mojang.serialization.Dynamic; import com.mojang.serialization.Dynamic;
import com.mojang.serialization.Lifecycle; import com.mojang.serialization.Lifecycle;
import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.ByteTag;
import com.sk89q.jnbt.CompoundTag; 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.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; 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.Component;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import com.sk89q.worldedit.util.io.file.SafeFiles; 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.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.DataFixer;
import com.sk89q.worldedit.world.RegenOptions; import com.sk89q.worldedit.world.RegenOptions;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
@ -342,7 +341,9 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
if (te != null) { if (te != null) {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
readTileEntityIntoTag(te, tag); // Load data readTileEntityIntoTag(te, tag); // Load data
return state.toBaseBlock((CompoundTag) toNative(tag)); //FAWE start - BinaryTag
return state.toBaseBlock((CompoundBinaryTag) toNativeBinary(tag));
//FAWE end
} }
return state.toBaseBlock(); return state.toBaseBlock();
@ -750,7 +751,9 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
if (blockEntity != null) { if (blockEntity != null) {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
blockEntity.save(tag); blockEntity.save(tag);
state = state.toBaseBlock(((CompoundTag) toNative(tag))); //FAWE start - BinaryTag
state = state.toBaseBlock(((CompoundBinaryTag) toNativeBinary(tag)));
//FAWE end
} }
extent.setBlock(vec, state.toBaseBlock()); extent.setBlock(vec, state.toBaseBlock());
if (options.shouldRegenBiomes()) { if (options.shouldRegenBiomes()) {
@ -835,49 +838,50 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
* @param foreign non-native NMS NBT structure * @param foreign non-native NMS NBT structure
* @return native WorldEdit NBT structure * @return native WorldEdit NBT structure
*/ */
//FAWE start - BinaryTag
@Override @Override
public Tag toNative(net.minecraft.nbt.Tag foreign) { public BinaryTag toNativeBinary(net.minecraft.nbt.Tag foreign) {
if (foreign == null) { if (foreign == null) {
return null; return null;
} }
if (foreign instanceof net.minecraft.nbt.CompoundTag) { if (foreign instanceof net.minecraft.nbt.CompoundTag) {
Map<String, Tag> values = new HashMap<>(); Map<String, BinaryTag> values = new HashMap<>();
Set<String> foreignKeys = ((net.minecraft.nbt.CompoundTag) foreign).getAllKeys(); Set<String> foreignKeys = ((net.minecraft.nbt.CompoundTag) foreign).getAllKeys();
for (String str : foreignKeys) { for (String str : foreignKeys) {
net.minecraft.nbt.Tag base = ((net.minecraft.nbt.CompoundTag) foreign).get(str); 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) { } 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) { } 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) { } 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) { } 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) { } 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) { } 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) { } 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) { } else if (foreign instanceof net.minecraft.nbt.ListTag) {
try { try {
return toNativeList((net.minecraft.nbt.ListTag) foreign); return toNativeList((net.minecraft.nbt.ListTag) foreign);
} catch (Throwable e) { } catch (Throwable e) {
logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e); logger.log(Level.WARNING, "Failed to convert net.minecraft.nbt.ListTag", e);
return new ListTag(ByteTag.class, new ArrayList<ByteTag>()); return ListBinaryTag.empty();
} }
} else if (foreign instanceof net.minecraft.nbt.LongTag) { } 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) { } 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) { } 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) { } else if (foreign instanceof net.minecraft.nbt.EndTag) {
return new EndTag(); return EndBinaryTag.get();
} else { } else {
throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName()); throw new IllegalArgumentException("Don't know how to make native " + foreign.getClass().getCanonicalName());
} }
@ -891,16 +895,14 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
* @throws SecurityException on error * @throws SecurityException on error
* @throws IllegalArgumentException on error * @throws IllegalArgumentException on error
*/ */
private ListTag toNativeList(net.minecraft.nbt.ListTag foreign) throws SecurityException, IllegalArgumentException { private ListBinaryTag toNativeList(net.minecraft.nbt.ListTag foreign) throws SecurityException, IllegalArgumentException {
List<Tag> values = new ArrayList<>(); ListBinaryTag.Builder values = ListBinaryTag.builder();
int type = foreign.getElementType();
for (net.minecraft.nbt.Tag tag : foreign) { for (net.minecraft.nbt.Tag tag : foreign) {
values.add(toNative(tag)); values.add(toNativeBinary(tag));
} }
Class<? extends Tag> cls = NBTConstants.getClassFromType(type); return values.build();
return new ListTag(cls, values);
} }
/** /**
@ -910,50 +912,50 @@ public final class PaperweightAdapter implements BukkitImplAdapter<net.minecraft
* @return non-native structure * @return non-native structure
*/ */
@Override @Override
public net.minecraft.nbt.Tag fromNative(Tag foreign) { public net.minecraft.nbt.Tag fromNativeBinary(BinaryTag foreign) {
if (foreign == null) { if (foreign == null) {
return null; return null;
} }
if (foreign instanceof CompoundTag) { if (foreign instanceof CompoundBinaryTag) {
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag(); net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
for (Map.Entry<String, Tag> entry : ((CompoundTag) foreign) for (String key : ((CompoundBinaryTag) foreign).keySet()) {
.getValue().entrySet()) { tag.put(key, fromNativeBinary(((CompoundBinaryTag) foreign).get(key)));
tag.put(entry.getKey(), fromNative(entry.getValue()));
} }
return tag; return tag;
} else if (foreign instanceof ByteTag) { } else if (foreign instanceof ByteBinaryTag) {
return net.minecraft.nbt.ByteTag.valueOf(((ByteTag) foreign).getValue()); return net.minecraft.nbt.ByteTag.valueOf(((ByteBinaryTag) foreign).value());
} else if (foreign instanceof ByteArrayTag) { } else if (foreign instanceof ByteArrayBinaryTag) {
return new net.minecraft.nbt.ByteArrayTag(((ByteArrayTag) foreign).getValue()); return new net.minecraft.nbt.ByteArrayTag(((ByteArrayBinaryTag) foreign).value());
} else if (foreign instanceof DoubleTag) { } else if (foreign instanceof DoubleBinaryTag) {
return net.minecraft.nbt.DoubleTag.valueOf(((DoubleTag) foreign).getValue()); return net.minecraft.nbt.DoubleTag.valueOf(((DoubleBinaryTag) foreign).value());
} else if (foreign instanceof FloatTag) { } else if (foreign instanceof FloatBinaryTag) {
return net.minecraft.nbt.FloatTag.valueOf(((FloatTag) foreign).getValue()); return net.minecraft.nbt.FloatTag.valueOf(((FloatBinaryTag) foreign).value());
} else if (foreign instanceof IntTag) { } else if (foreign instanceof IntBinaryTag) {
return net.minecraft.nbt.IntTag.valueOf(((IntTag) foreign).getValue()); return net.minecraft.nbt.IntTag.valueOf(((IntBinaryTag) foreign).value());
} else if (foreign instanceof IntArrayTag) { } else if (foreign instanceof IntArrayBinaryTag) {
return new net.minecraft.nbt.IntArrayTag(((IntArrayTag) foreign).getValue()); return new net.minecraft.nbt.IntArrayTag(((IntArrayBinaryTag) foreign).value());
} else if (foreign instanceof LongArrayTag) { } else if (foreign instanceof LongArrayBinaryTag) {
return new net.minecraft.nbt.LongArrayTag(((LongArrayTag) foreign).getValue()); return new net.minecraft.nbt.LongArrayTag(((LongArrayBinaryTag) foreign).value());
} else if (foreign instanceof ListTag) { } else if (foreign instanceof ListBinaryTag) {
net.minecraft.nbt.ListTag tag = new net.minecraft.nbt.ListTag(); net.minecraft.nbt.ListTag tag = new net.minecraft.nbt.ListTag();
ListTag foreignList = (ListTag) foreign; ListBinaryTag foreignList = (ListBinaryTag) foreign;
for (Tag t : foreignList.getValue()) { for (BinaryTag t : foreignList) {
tag.add(fromNative(t)); tag.add(fromNativeBinary(t));
} }
return tag; return tag;
} else if (foreign instanceof LongTag) { } else if (foreign instanceof LongBinaryTag) {
return net.minecraft.nbt.LongTag.valueOf(((LongTag) foreign).getValue()); return net.minecraft.nbt.LongTag.valueOf(((LongBinaryTag) foreign).value());
} else if (foreign instanceof ShortTag) { } else if (foreign instanceof ShortBinaryTag) {
return net.minecraft.nbt.ShortTag.valueOf(((ShortTag) foreign).getValue()); return net.minecraft.nbt.ShortTag.valueOf(((ShortBinaryTag) foreign).value());
} else if (foreign instanceof StringTag) { } else if (foreign instanceof StringBinaryTag) {
return net.minecraft.nbt.StringTag.valueOf(((StringTag) foreign).getValue()); return net.minecraft.nbt.StringTag.valueOf(((StringBinaryTag) foreign).value());
} else if (foreign instanceof EndTag) { } else if (foreign instanceof EndBinaryTag) {
return net.minecraft.nbt.EndTag.INSTANCE; return net.minecraft.nbt.EndTag.INSTANCE;
} else { } else {
throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName()); throw new IllegalArgumentException("Don't know how to make NMS " + foreign.getClass().getCanonicalName());
} }
} }
//FAWE end
@Override @Override
public boolean supportsWatchdog() { public boolean supportsWatchdog() {

Datei anzeigen

@ -34,7 +34,7 @@ import com.mojang.datafixers.DataFixer;
import com.mojang.datafixers.DataFixerBuilder; import com.mojang.datafixers.DataFixerBuilder;
import com.mojang.datafixers.schemas.Schema; import com.mojang.datafixers.schemas.Schema;
import com.mojang.serialization.Dynamic; 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.core.Direction;
import net.minecraft.nbt.NbtOps; import net.minecraft.nbt.NbtOps;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
@ -78,15 +78,16 @@ import java.util.stream.Collectors;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer { class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.worldedit.world.DataFixer {
//FAWE start - BinaryTag
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override @Override
public <T> T fixUp(FixType<T> type, T original, int srcVer) { public <T> T fixUp(FixType<T> type, T original, int srcVer) {
if (type == FixTypes.CHUNK) { if (type == FixTypes.CHUNK) {
return (T) fixChunk((CompoundTag) original, srcVer); return (T) fixChunk((CompoundBinaryTag) original, srcVer);
} else if (type == FixTypes.BLOCK_ENTITY) { } else if (type == FixTypes.BLOCK_ENTITY) {
return (T) fixBlockEntity((CompoundTag) original, srcVer); return (T) fixBlockEntity((CompoundBinaryTag) original, srcVer);
} else if (type == FixTypes.ENTITY) { } else if (type == FixTypes.ENTITY) {
return (T) fixEntity((CompoundTag) original, srcVer); return (T) fixEntity((CompoundBinaryTag) original, srcVer);
} else if (type == FixTypes.BLOCK_STATE) { } else if (type == FixTypes.BLOCK_STATE) {
return (T) fixBlockState((String) original, srcVer); return (T) fixBlockState((String) original, srcVer);
} else if (type == FixTypes.ITEM_TYPE) { } else if (type == FixTypes.ITEM_TYPE) {
@ -97,23 +98,24 @@ class PaperweightDataConverters extends DataFixerBuilder implements com.sk89q.wo
return original; return original;
} }
private CompoundTag fixChunk(CompoundTag originalChunk, int srcVer) { private CompoundBinaryTag fixChunk(CompoundBinaryTag originalChunk, int srcVer) {
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNative(originalChunk); net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNativeBinary(originalChunk);
net.minecraft.nbt.CompoundTag fixed = convert(LegacyType.CHUNK, tag, srcVer); 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) { private CompoundBinaryTag fixBlockEntity(CompoundBinaryTag origTileEnt, int srcVer) {
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNative(origTileEnt); net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNativeBinary(origTileEnt);
net.minecraft.nbt.CompoundTag fixed = convert(LegacyType.BLOCK_ENTITY, tag, srcVer); 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) { private CompoundBinaryTag fixEntity(CompoundBinaryTag origEnt, int srcVer) {
net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNative(origEnt); net.minecraft.nbt.CompoundTag tag = (net.minecraft.nbt.CompoundTag) adapter.fromNativeBinary(origEnt);
net.minecraft.nbt.CompoundTag fixed = convert(LegacyType.ENTITY, tag, srcVer); 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) { private String fixBlockState(String blockState, int srcVer) {
net.minecraft.nbt.CompoundTag stateNBT = stateToNBT(blockState); net.minecraft.nbt.CompoundTag stateNBT = stateToNBT(blockState);

Datei anzeigen

@ -9,6 +9,7 @@ import com.fastasyncworldedit.core.internal.io.FaweInputStream;
import com.fastasyncworldedit.core.internal.io.FaweOutputStream; import com.fastasyncworldedit.core.internal.io.FaweOutputStream;
import com.fastasyncworldedit.core.jnbt.streamer.StreamDelegate; import com.fastasyncworldedit.core.jnbt.streamer.StreamDelegate;
import com.fastasyncworldedit.core.jnbt.streamer.ValueReader; import com.fastasyncworldedit.core.jnbt.streamer.ValueReader;
import com.sk89q.jnbt.AdventureNBTConverter;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.NBTInputStream; import com.sk89q.jnbt.NBTInputStream;
@ -108,14 +109,26 @@ public class FastSchematicReader extends NBTSchematicReader {
if (fixer == null || dataVersion == -1) { if (fixer == null || dataVersion == -1) {
return tag; 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) { private CompoundTag fixEntity(CompoundTag tag) {
if (fixer == null || dataVersion == -1) { if (fixer == null || dataVersion == -1) {
return tag; 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) { private String fixBiome(String biomePalettePart) {

Datei anzeigen

@ -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;
@ -228,7 +229,13 @@ public class MCEditSchematicReader extends NBTSchematicReader {
} }
if (fixer != null && t != null) { 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); BlockVector3 vec = BlockVector3.at(x, y, z);
@ -289,7 +296,13 @@ public class MCEditSchematicReader extends NBTSchematicReader {
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); //FAWE start - BinaryTag
compound = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(
DataFixer.FixTypes.ENTITY,
compound.asBinaryTag(),
-1
));
//FAWE end
} }
String id = convertEntityId(compound.getString("id")); String id = convertEntityId(compound.getString("id"));
Location location = NBTConversions.toLocation( Location location = NBTConversions.toLocation(

Datei anzeigen

@ -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;
@ -270,7 +271,13 @@ public class SpongeSchematicReader extends NBTSchematicReader {
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(); //FAWE start - BinaryTag
tileEntity = ((CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(
DataFixer.FixTypes.BLOCK_ENTITY,
new CompoundTag(values).asBinaryTag(),
dataVersion
))).getValue();
//FAWE end
} else { } else {
tileEntity = values; tileEntity = values;
} }
@ -411,7 +418,13 @@ public class SpongeSchematicReader extends NBTSchematicReader {
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); //FAWE start - BinaryTag
entityTag = (CompoundTag) AdventureNBTConverter.fromAdventure(fixer.fixUp(
DataFixer.FixTypes.ENTITY,
entityTag.asBinaryTag(),
dataVersion
));
//FAWE end
} }
EntityType entityType = EntityTypes.get(id); EntityType entityType = EntityTypes.get(id);

Datei anzeigen

@ -41,9 +41,11 @@ public interface DataFixer {
private FixTypes() { private FixTypes() {
} }
public static FixType<CompoundTag> CHUNK = new FixType<>(); //FAWE start - BinaryTag
public static FixType<CompoundTag> BLOCK_ENTITY = new FixType<>(); public static FixType<CompoundBinaryTag> CHUNK = new FixType<>();
public static FixType<CompoundTag> ENTITY = 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> 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<>();

Datei anzeigen

@ -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;
@ -119,7 +120,11 @@ public class ChunkStoreHelper {
.containsKey("Sections") && dataVersion < currentDataVersion) { // only fix up MCA format, DFU doesn't support MCR chunks .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"); //FAWE start - BinaryTag
tag = (CompoundTag) AdventureNBTConverter.fromAdventure(dataFixer
.fixUp(DataFixer.FixTypes.CHUNK, rootTag.asBinaryTag(), dataVersion)
.get("Level"));
//FAWE end
dataVersion = currentDataVersion; dataVersion = currentDataVersion;
} }
} }