3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-08 17:40:04 +01:00

Fix disconnect when encoding empty ItemStack

Dieser Commit ist enthalten in:
Moulberry 2024-06-27 03:17:09 +08:00
Ursprung 73e81de300
Commit cc4e729728

Datei anzeigen

@ -29,7 +29,7 @@ public class ItemStackDataType implements PersistentDataType<PersistentDataConta
public @NotNull PersistentDataContainer toPrimitive(@NotNull ItemStack complex, @NotNull PersistentDataAdapterContext context) { public @NotNull PersistentDataContainer toPrimitive(@NotNull ItemStack complex, @NotNull PersistentDataAdapterContext context) {
net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(complex); net.minecraft.world.item.ItemStack nmsStack = CraftItemStack.asNMSCopy(complex);
if (nmsStack == null) nmsStack = net.minecraft.world.item.ItemStack.EMPTY; if (nmsStack == null) nmsStack = net.minecraft.world.item.ItemStack.EMPTY;
CompoundTag tag = (CompoundTag) nmsStack.save(MinecraftServer.getServer().registryAccess()); CompoundTag tag = (CompoundTag) nmsStack.saveOptional(MinecraftServer.getServer().registryAccess());
PersistentDataContainer container = context.newPersistentDataContainer(); PersistentDataContainer container = context.newPersistentDataContainer();
((CraftPersistentDataContainer)container).putAll(tag); ((CraftPersistentDataContainer)container).putAll(tag);