Paper/patches/server/0830-Add-ItemFactory-getMonsterEgg-API.patch
Finn Künstner a284e40c70
Updated Upstream (Bukkit/CraftBukkit) (#6848)
Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
9b45fa2f #667: Allow setting BrewEvent results
8c776ddc SPIGOT-6762: ChatPaginator.wordWrap only transfers one modifier
da372966 SPIGOT-4590, SPIGOT-6769: Clarify DamageCause documentation

CraftBukkit Changes:
cef1fda3 #947: Add missing spawn eggs for SpawnEggMeta
eb9a0f34 #945: Allow setting BrewEvent results
2021-10-31 08:34:10 +01:00

29 lines
1.5 KiB
Diff

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 fcbd28fdeab4815c005c7dca547aee246f52fd26..1c0ecd8bb3156a8e1718e84455dd9af667adaf7a 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java
@@ -410,5 +410,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
}