|
11 | 11 | import com.mojang.brigadier.exceptions.CommandSyntaxException; |
12 | 12 | import com.mojang.logging.LogUtils; |
13 | 13 | import com.mojang.serialization.Dynamic; |
| 14 | +import com.mojang.serialization.JavaOps; |
14 | 15 | import com.mojang.serialization.JsonOps; |
| 16 | +import io.papermc.paper.adventure.AdventureCodecs; |
| 17 | +import io.papermc.paper.adventure.PaperAdventure; |
15 | 18 | import io.papermc.paper.registry.RegistryKey; |
16 | 19 | import java.io.File; |
17 | 20 | import java.io.IOException; |
|
26 | 29 | import java.util.logging.Level; |
27 | 30 | import java.util.stream.Stream; |
28 | 31 | import io.papermc.paper.entity.EntitySerializationFlag; |
| 32 | +import net.kyori.adventure.text.event.HoverEvent; |
29 | 33 | import net.minecraft.SharedConstants; |
30 | 34 | import net.minecraft.advancements.AdvancementHolder; |
31 | 35 | import net.minecraft.commands.Commands; |
|
39 | 43 | import net.minecraft.nbt.Tag; |
40 | 44 | import net.minecraft.nbt.TagParser; |
41 | 45 | import net.minecraft.resources.Identifier; |
| 46 | +import net.minecraft.resources.RegistryOps; |
42 | 47 | import net.minecraft.server.MinecraftServer; |
43 | 48 | import net.minecraft.server.level.ServerLevel; |
44 | 49 | import net.minecraft.util.ProblemReporter; |
|
56 | 61 | import org.bukkit.Keyed; |
57 | 62 | import org.bukkit.Material; |
58 | 63 | import org.bukkit.NamespacedKey; |
| 64 | +import org.bukkit.Registry; |
59 | 65 | import org.bukkit.UnsafeValues; |
60 | 66 | import org.bukkit.World; |
61 | 67 | import org.bukkit.advancement.Advancement; |
@@ -860,4 +866,15 @@ public io.papermc.paper.plugin.lifecycle.event.LifecycleEventManager<org.bukkit. |
860 | 866 | public org.bukkit.inventory.ItemStack createEmptyStack() { |
861 | 867 | return CraftItemStack.asCraftMirror(null); |
862 | 868 | } |
| 869 | + |
| 870 | + @Override |
| 871 | + public ItemStack deserializeItemHover(final HoverEvent.ShowItem itemHover) { |
| 872 | + final RegistryOps<Object> ops = CraftRegistry.getMinecraftRegistry().createSerializationContext(JavaOps.INSTANCE); |
| 873 | + final Object encoded = AdventureCodecs.SHOW_ITEM_CODEC.codec() |
| 874 | + .encodeStart(ops, HoverEvent.showItem(itemHover)).getOrThrow(IllegalStateException::new); |
| 875 | + |
| 876 | + return CraftItemStack.asBukkitCopy(net.minecraft.network.chat.HoverEvent.ShowItem.CODEC.codec() |
| 877 | + .parse(ops, encoded).getOrThrow(IllegalStateException::new) |
| 878 | + .item()); |
| 879 | + } |
863 | 880 | } |
0 commit comments