new nbt serializer
This commit is contained in:
parent
0c51ad8eb7
commit
d8c3bac31f
|
|
@ -5,6 +5,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
import net.minecraft.nbt.TagParser;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
@ -45,7 +46,7 @@ public class MixinPCStore {
|
||||||
ResultSet rs = qr.resultSet();
|
ResultSet rs = qr.resultSet();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String serializedData = rs.getString("pc");
|
String serializedData = rs.getString("pc");
|
||||||
loadedNbt = NbtUtils.snbtToStructure(serializedData);
|
loadedNbt = TagParser.parseTag(serializedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.core.RegistryAccess;
|
import net.minecraft.core.RegistryAccess;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
import net.minecraft.nbt.TagParser;
|
||||||
import org.spongepowered.asm.mixin.Final;
|
import org.spongepowered.asm.mixin.Final;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
|
|
@ -45,7 +46,7 @@ public class MixinPartyStore {
|
||||||
ResultSet rs = qr.resultSet();
|
ResultSet rs = qr.resultSet();
|
||||||
if (rs.next()) {
|
if (rs.next()) {
|
||||||
String serializedData = rs.getString("inv");
|
String serializedData = rs.getString("inv");
|
||||||
loadedNbt = NbtUtils.snbtToStructure(serializedData);
|
loadedNbt = TagParser.parseTag(serializedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package vip.fubuki.playersync.sync.addons;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.nbt.NbtUtils;
|
import net.minecraft.nbt.NbtUtils;
|
||||||
|
import net.minecraft.nbt.TagParser;
|
||||||
import net.minecraft.world.entity.player.Player;
|
import net.minecraft.world.entity.player.Player;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.neoforged.fml.ModList;
|
import net.neoforged.fml.ModList;
|
||||||
|
|
@ -43,7 +44,7 @@ public class ModsSupport {
|
||||||
if (rsBackpack.next()) {
|
if (rsBackpack.next()) {
|
||||||
String serialized = rsBackpack.getString("backpack_nbt");
|
String serialized = rsBackpack.getString("backpack_nbt");
|
||||||
String nbtString = VanillaSync.deserializeString(serialized);
|
String nbtString = VanillaSync.deserializeString(serialized);
|
||||||
CompoundTag backpackNbt = NbtUtils.snbtToStructure(nbtString);
|
CompoundTag backpackNbt = TagParser.parseTag(nbtString);
|
||||||
// Update BackpackStorage with the retrieved NBT
|
// Update BackpackStorage with the retrieved NBT
|
||||||
net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackStorage.get().setBackpackContents(contentsUuid, backpackNbt);
|
net.p3pp3rf1y.sophisticatedbackpacks.backpack.BackpackStorage.get().setBackpackContents(contentsUuid, backpackNbt);
|
||||||
PlayerSync.LOGGER.info("Restored backpack data for UUID " + contentsUuid);
|
PlayerSync.LOGGER.info("Restored backpack data for UUID " + contentsUuid);
|
||||||
|
|
@ -110,7 +111,7 @@ public class ModsSupport {
|
||||||
String serialized = entry.getValue();
|
String serialized = entry.getValue();
|
||||||
try {
|
try {
|
||||||
String nbtString = VanillaSync.deserializeString(serialized);
|
String nbtString = VanillaSync.deserializeString(serialized);
|
||||||
CompoundTag tag = NbtUtils.snbtToStructure(nbtString);
|
CompoundTag tag = TagParser.parseTag(nbtString);
|
||||||
ItemStack stack = ItemStack.parse(ServerLifecycleHooks.getCurrentServer().registryAccess(),tag).get();
|
ItemStack stack = ItemStack.parse(ServerLifecycleHooks.getCurrentServer().registryAccess(),tag).get();
|
||||||
if (handler.getCurios().containsKey(slotType)) {
|
if (handler.getCurios().containsKey(slotType)) {
|
||||||
ICurioStacksHandler stacksHandler = handler.getCurios().get(slotType);
|
ICurioStacksHandler stacksHandler = handler.getCurios().get(slotType);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user