Use new compound shortcuts

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2021-12-16 22:39:14 +01:00
parent fe02cf73cf
commit d15da98182

View File

@ -38,8 +38,7 @@ public class Tag<T> {
final var updated = new SNBTParser(new StringReader(snbt)).parse(); final var updated = new SNBTParser(new StringReader(snbt)).parse();
if (!(updated instanceof NBTCompound updatedCompound)) if (!(updated instanceof NBTCompound updatedCompound))
throw new IllegalArgumentException("'" + snbt + "' is not a compound!"); throw new IllegalArgumentException("'" + snbt + "' is not a compound!");
original.clear(); original.copyFrom(updatedCompound);
updatedCompound.forEach(original::set);
} catch (NBTException e) { } catch (NBTException e) {
MinecraftServer.getExceptionManager().handleException(e); MinecraftServer.getExceptionManager().handleException(e);
} }
@ -51,10 +50,7 @@ public class Tag<T> {
* Writing will override all tags. Proceed with caution. * Writing will override all tags. Proceed with caution.
*/ */
@ApiStatus.Experimental @ApiStatus.Experimental
public static final Tag<NBTCompound> NBT = new Tag<>(null, NBTCompoundLike::toCompound, (original, updated) -> { public static final Tag<NBTCompound> NBT = new Tag<>(null, NBTCompoundLike::toCompound, MutableNBTCompound::copyFrom);
original.clear();
updated.forEach(original::set);
});
private final String key; private final String key;
private final Function<NBTCompoundLike, T> readFunction; private final Function<NBTCompoundLike, T> readFunction;