mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-01 04:32:11 -07:00
Fix PlayerDropItemEvent using wrong item
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
--- a/net/minecraft/server/commands/GiveCommand.java
|
||||
+++ b/net/minecraft/server/commands/GiveCommand.java
|
||||
@@ -60,7 +60,7 @@
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
private static int giveItem(CommandSourceStack source, ItemInput item, Collection<ServerPlayer> targets, int count) throws CommandSyntaxException {
|
||||
ItemStack itemstack = item.createItemStack(1, false);
|
||||
+ final Component displayName = itemstack.getDisplayName(); // Paper - get display name early
|
||||
int j = itemstack.getMaxStackSize();
|
||||
int k = j * 100;
|
||||
|
||||
@@ -60,7 +61,7 @@
|
||||
ItemEntity entityitem;
|
||||
|
||||
if (flag && itemstack1.isEmpty()) {
|
||||
@@ -9,3 +17,17 @@
|
||||
if (entityitem != null) {
|
||||
entityitem.makeFakeItem();
|
||||
}
|
||||
@@ -79,11 +80,11 @@
|
||||
|
||||
if (targets.size() == 1) {
|
||||
source.sendSuccess(() -> {
|
||||
- return Component.translatable("commands.give.success.single", count, itemstack.getDisplayName(), ((ServerPlayer) targets.iterator().next()).getDisplayName());
|
||||
+ return Component.translatable("commands.give.success.single", count, displayName, ((ServerPlayer) targets.iterator().next()).getDisplayName()); // Paper - use cached display name
|
||||
}, true);
|
||||
} else {
|
||||
source.sendSuccess(() -> {
|
||||
- return Component.translatable("commands.give.success.single", count, itemstack.getDisplayName(), targets.size());
|
||||
+ return Component.translatable("commands.give.success.single", count, displayName, targets.size()); // Paper - use cached display name
|
||||
}, true);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user