fix(PlayerReadWriteNBT): use NbtList for the upper list

Signed-off-by: Forgejo <forgejo@mctaylors.ddns.net>
This commit is contained in:
Octol1ttle 2023-11-29 17:36:40 +05:00 committed by Forgejo
parent f2b55452d5
commit c81403ed53
Signed by untrusted user who does not match committer: Forgejo
GPG key ID: F2B3CB736682B201

View file

@ -53,7 +53,7 @@ public abstract class PlayerEntityMixin {
@Inject(method = "writeCustomDataToNbt", at = @At("TAIL"))
public void writeMyDataToNbt(NbtCompound playerNbt, CallbackInfo ci) {
// create a new NBT record for our list
NbtCompound myListNbt = new NbtCompound();
NbtList myListNbt = new NbtList();
// you can use a regular for-loop if you want, there's no difference. FabricMC wiki uses Iterable#forEach so that's why it's used here
myList.forEach(myObject -> {
@ -71,7 +71,7 @@ public abstract class PlayerEntityMixin {
myObjectNbt.put("MyNotSupportedObject", myNotSupportedObjectNbt);
// put our newly created record into the list record
myListNbt.put("MyObject", myObjectNbt);
myListNbt.add(myObjectNbt);
});
// finally, put our list record into the player's NBT