From dd9c9c8f6c5540bd9b45de0c7fed814283b95430 Mon Sep 17 00:00:00 2001 From: Luis Date: Sat, 27 Jan 2024 18:32:05 +0000 Subject: [PATCH] Make spawn egg colours visible (#10158) Co-authored-by: Yannick Lamprecht <1420893+yannicklamprecht@users.noreply.github.com> --- ...Add-api-for-spawn-egg-texture-colors.patch | 28 +++++++++++++++++++ ...Add-api-for-spawn-egg-texture-colors.patch | 26 +++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 patches/api/Add-api-for-spawn-egg-texture-colors.patch create mode 100644 patches/server/Add-api-for-spawn-egg-texture-colors.patch diff --git a/patches/api/Add-api-for-spawn-egg-texture-colors.patch b/patches/api/Add-api-for-spawn-egg-texture-colors.patch new file mode 100644 index 0000000000..57c9aca5cf --- /dev/null +++ b/patches/api/Add-api-for-spawn-egg-texture-colors.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luis +Date: Thu, 11 Jan 2024 19:58:17 +0100 +Subject: [PATCH] Add api for spawn egg texture colors + + +diff --git a/src/main/java/org/bukkit/UnsafeValues.java b/src/main/java/org/bukkit/UnsafeValues.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/UnsafeValues.java ++++ b/src/main/java/org/bukkit/UnsafeValues.java +@@ -0,0 +0,0 @@ public interface UnsafeValues { + + String getStatisticCriteriaKey(@NotNull org.bukkit.Statistic statistic); + // Paper end ++ ++ // Paper start - spawn egg color visibility ++ /** ++ * Obtains the underlying color informating for a spawn egg of a given ++ * entity type, or null if the entity passed does not have a spawn egg. ++ * Spawn eggs have two colors - the background layer (0), and the ++ * foreground layer (1) ++ * @param entityType The entity type to get the color for ++ * @param layer The texture layer to get a color for ++ * @return The color of the layer for the entity's spawn egg ++ */ ++ @Nullable org.bukkit.Color getSpawnEggLayerColor(org.bukkit.entity.EntityType entityType, int layer); ++ // Paper end - spawn egg color visibility + } diff --git a/patches/server/Add-api-for-spawn-egg-texture-colors.patch b/patches/server/Add-api-for-spawn-egg-texture-colors.patch new file mode 100644 index 0000000000..529c61964b --- /dev/null +++ b/patches/server/Add-api-for-spawn-egg-texture-colors.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Luis +Date: Thu, 11 Jan 2024 19:58:23 +0100 +Subject: [PATCH] Add api for spawn egg texture colors + + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/CraftMagicNumbers.java +@@ -0,0 +0,0 @@ public final class CraftMagicNumbers implements UnsafeValues { + } + // Paper end + ++ // Paper start - spawn egg color visibility ++ @Override ++ public org.bukkit.Color getSpawnEggLayerColor(final EntityType entityType, final int layer) { ++ final net.minecraft.world.entity.EntityType nmsType = org.bukkit.craftbukkit.entity.CraftEntityType.bukkitToMinecraft(entityType); ++ final net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.byId(nmsType); ++ return eggItem == null ? null : org.bukkit.Color.fromRGB(eggItem.getColor(layer)); ++ } ++ // Paper end - spawn egg color visibility ++ + /** + * This helper class represents the different NBT Tags. + *