diff options
author | Jake Potrebic <[email protected]> | 2024-05-29 13:58:57 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2024-05-29 22:58:57 +0200 |
commit | a31dc90741ed9c121a13a3c124c9ebf5bafd0da7 (patch) | |
tree | 81963bd94fe7772ee08bd21710230de21b6b25da /patches/server/0601-Add-ItemFactory-getSpawnEgg-API.patch | |
parent | ed85aac53cfd93d29fa24e6071dbdddd0e49624b (diff) | |
download | Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.tar.gz Paper-a31dc90741ed9c121a13a3c124c9ebf5bafd0da7.zip |
Several fixes and new api for experience merging/stacking (#9242)
Diffstat (limited to 'patches/server/0601-Add-ItemFactory-getSpawnEgg-API.patch')
-rw-r--r-- | patches/server/0601-Add-ItemFactory-getSpawnEgg-API.patch | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/patches/server/0601-Add-ItemFactory-getSpawnEgg-API.patch b/patches/server/0601-Add-ItemFactory-getSpawnEgg-API.patch new file mode 100644 index 0000000000..a1ba12cd83 --- /dev/null +++ b/patches/server/0601-Add-ItemFactory-getSpawnEgg-API.patch @@ -0,0 +1,50 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: William Blake Galbreath <[email protected]> +Date: Thu, 14 Oct 2021 12:09:39 -0500 +Subject: [PATCH] Add ItemFactory#getSpawnEgg API + + +diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +index 46a4518e25a0eaaa99b13e4fb522060974ce4ec2..6b2d2b8397bb95ce6ffd87dc1a2f3292f81dd422 100644 +--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java ++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemFactory.java +@@ -581,4 +581,19 @@ public final class CraftItemFactory implements ItemFactory { + new net.md_5.bungee.api.chat.TextComponent(customName)); + } + // Paper end - bungee hover events ++ ++ // Paper start - old getSpawnEgg API ++ // @Override // used to override, upstream added conflicting method, is called via Commodore now ++ @Deprecated ++ public ItemStack getSpawnEgg0(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.registries.BuiltInRegistries.ENTITY_TYPE.get(typeKey); ++ net.minecraft.world.item.SpawnEggItem eggItem = net.minecraft.world.item.SpawnEggItem.byId(nmsType); ++ return eggItem == null ? null : new net.minecraft.world.item.ItemStack(eggItem).asBukkitMirror(); ++ } ++ // Paper end - old getSpawnEgg API + } +diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +index cdd0463b31a8d2766eaa15881b3b6f0dcf6e3e4a..5c05258ce502a9ff7d6f182f61e3722ec42e9e69 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java +@@ -382,6 +382,15 @@ public class Commodore { + } + // Paper end + ++ // Paper start - ItemFactory#getSpawnEgg (paper had original method that returned ItemStack, upstream added identical but returned Material) ++ if (owner.equals("org/bukkit/inventory/ItemFactory") && name.equals("getSpawnEgg") && desc.equals("(Lorg/bukkit/entity/EntityType;)Lorg/bukkit/inventory/ItemStack;")) { ++ super.visitInsn(Opcodes.SWAP); // has 1 param, this moves the owner instance to the top for the checkcast ++ super.visitTypeInsn(Opcodes.CHECKCAST, runtimeCbPkgPrefix() + "inventory/CraftItemFactory"); ++ super.visitInsn(Opcodes.SWAP); // moves param back to the the top of stack ++ super.visitMethodInsn(Opcodes.INVOKEVIRTUAL, runtimeCbPkgPrefix() + "inventory/CraftItemFactory", "getSpawnEgg0", desc, false); ++ return; ++ } ++ // Paper end - ItemFactory#getSpawnEgg + if (modern) { + if (owner.equals("org/bukkit/Material") || (instantiatedMethodType != null && instantiatedMethodType.getDescriptor().startsWith("(Lorg/bukkit/Material;)"))) { + switch (name) { |