2021-10-20 21:35:52 +00:00
|
|
|
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
|
2022-03-01 03:25:13 +00:00
|
|
|
index def8caa7e991cc5f6e8aefcf9e9e3b18149bfdfa..446dfea89b4fbab55d1379315247172b6cc4730c 100644
|
2021-10-20 21:35:52 +00:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
2021-10-31 07:34:10 +00:00
|
|
|
@@ -410,5 +410,17 @@ public final class CraftItemFactory implements ItemFactory {
|
2021-10-20 21:35:52 +00:00
|
|
|
entity.getUniqueId().toString(),
|
|
|
|
new net.md_5.bungee.api.chat.TextComponent(customName));
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
2021-10-20 21:41:54 +00:00
|
|
|
+ public ItemStack getSpawnEgg(org.bukkit.entity.EntityType type) {
|
2021-10-20 21:35:52 +00:00
|
|
|
+ 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
|
|
|
|
}
|