2021-10-20 23:35:52 +02: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
|
2022-11-20 00:53:20 +01:00
|
|
|
Subject: [PATCH] Add ItemFactory#getSpawnEgg API
|
2021-10-20 23:35:52 +02:00
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
2023-06-08 04:12:38 +02:00
|
|
|
index f5610d0746b67dfe69dc79d71c4d082c083f2ee4..b32c06b1f03751c164da7049976c473dff20e4ef 100644
|
2021-10-20 23:35:52 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
|
2023-06-08 04:12:38 +02:00
|
|
|
@@ -508,5 +508,17 @@ public final class CraftItemFactory implements ItemFactory {
|
2021-10-20 23:35:52 +02:00
|
|
|
entity.getUniqueId().toString(),
|
|
|
|
new net.md_5.bungee.api.chat.TextComponent(customName));
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
2021-10-20 23:41:54 +02:00
|
|
|
+ public ItemStack getSpawnEgg(org.bukkit.entity.EntityType type) {
|
2021-10-20 23:35:52 +02:00
|
|
|
+ if (type == null) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ String typeId = type.getKey().toString();
|
|
|
|
+ net.minecraft.resources.ResourceLocation typeKey = new net.minecraft.resources.ResourceLocation(typeId);
|
2022-12-08 04:24:00 +01:00
|
|
|
+ net.minecraft.world.entity.EntityType<?> nmsType = net.minecraft.core.registries.BuiltInRegistries.ENTITY_TYPE.get(typeKey);
|
2022-11-20 00:53:20 +01:00
|
|
|
+ net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.byId(nmsType);
|
2021-10-20 23:35:52 +02:00
|
|
|
+ return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror();
|
|
|
|
+ }
|
|
|
|
// Paper end
|
|
|
|
}
|