aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0698-Add-ItemFactory-getMonsterEgg-API.patch
blob: 19449140816630be97110732f44a9315772a56e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: William Blake Galbreath <blake.galbreath@gmail.com>
Date: Thu, 14 Oct 2021 12:09:39 -0500
Subject: [PATCH] Add ItemFactory#getMonsterEgg API


diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
index f3a6a4d97b5be2e75c438a6f7010a8f588afe86c..4a8ac558d308c4e3bc63cdd8d7071a3f9ff3aa81 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -440,5 +440,17 @@ public final class CraftItemFactory implements ItemFactory {
             entity.getUniqueId().toString(),
             new net.md_5.bungee.api.chat.TextComponent(customName));
     }
+
+    @Override
+    public ItemStack getSpawnEgg(org.bukkit.entity.EntityType type) {
+        if (type == null) {
+            return null;
+        }
+        String typeId = type.getKey().toString();
+        net.minecraft.resources.ResourceLocation typeKey = new net.minecraft.resources.ResourceLocation(typeId);
+        net.minecraft.world.entity.EntityType<?> nmsType = net.minecraft.core.Registry.ENTITY_TYPE.get(typeKey);
+        net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.BY_ID.get(nmsType);
+        return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror();
+    }
     // Paper end
 }