Add Tag#NBT write support

This commit is contained in:
TheMode 2021-06-26 19:44:35 +02:00
parent bf44625730
commit 5ddfff22f2

View File

@ -33,10 +33,13 @@ public class Tag<T> {
/** /**
* Reads the complete tag holder compound. * Reads the complete tag holder compound.
* <p> * <p>
* Writing is not supported. * Writing will override all tags. Proceed with caution.
*/ */
@ApiStatus.Experimental @ApiStatus.Experimental
public static final Tag<NBTCompound> NBT = new Tag<>(null, NBTCompound::deepClone, null, null); public static final Tag<NBTCompound> NBT = new Tag<>(null, NBTCompound::deepClone, (original, updated) -> {
original.clear();
updated.getKeys().forEach(s -> original.set(s, Objects.requireNonNull(updated.get(s))));
}, null);
private final String key; private final String key;
private final Function<NBTCompound, T> readFunction; private final Function<NBTCompound, T> readFunction;