fix some issues on the todo list

This commit is contained in:
Jake Potrebic 2024-04-26 09:22:55 -07:00
parent 8a37019dc2
commit a55b0c8097
3 changed files with 29 additions and 3 deletions

View File

@ -143,7 +143,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ static Codec<HoverEvent.ShowItem> showItemCodec(final Codec<Component> componentCodec) { + static Codec<HoverEvent.ShowItem> showItemCodec(final Codec<Component> componentCodec) {
+ return net.minecraft.network.chat.HoverEvent.ItemStackInfo.CODEC.xmap(isi -> { + return net.minecraft.network.chat.HoverEvent.ItemStackInfo.CODEC.xmap(isi -> {
+ @Subst("key") final String typeKey = isi.item.unwrapKey().orElseThrow().toString(); + @Subst("key") final String typeKey = isi.item.unwrapKey().orElseThrow().location().toString();
+ return HoverEvent.ShowItem.showItem(Key.key(typeKey), isi.count, PaperAdventure.asAdventure(isi.getItemStack().getComponentsPatch())); + return HoverEvent.ShowItem.showItem(Key.key(typeKey), isi.count, PaperAdventure.asAdventure(isi.getItemStack().getComponentsPatch()));
+ }, si -> { + }, si -> {
+ final Item itemType = BuiltInRegistries.ITEM.get(PaperAdventure.asVanilla(si.item())); + final Item itemType = BuiltInRegistries.ITEM.get(PaperAdventure.asVanilla(si.item()));

View File

@ -4,6 +4,32 @@ Date: Sun, 20 Jun 2021 21:55:59 -0700
Subject: [PATCH] Fix PlayerDropItemEvent using wrong item Subject: [PATCH] Fix PlayerDropItemEvent using wrong item
diff --git a/src/main/java/net/minecraft/server/commands/GiveCommand.java b/src/main/java/net/minecraft/server/commands/GiveCommand.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/commands/GiveCommand.java
+++ b/src/main/java/net/minecraft/server/commands/GiveCommand.java
@@ -0,0 +0,0 @@ public class GiveCommand {
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;
@@ -0,0 +0,0 @@ public class GiveCommand {
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);
}
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java

View File

@ -67,12 +67,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ +
+ if (entity != null) { + if (entity != null) {
+ if (entity instanceof Mob mob) { + if (entity instanceof Mob mob) {
+ this.setTarget(mob); + this.setTarget(mob, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true);
+ this.setLastHurtByMob(mob); + this.setLastHurtByMob(mob);
+ } + }
+ +
+ if (entity instanceof Player player) { + if (entity instanceof Player player) {
+ this.setTarget(player); + this.setTarget(player, org.bukkit.event.entity.EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY, true);
+ this.setLastHurtByPlayer(player); + this.setLastHurtByPlayer(player);
+ } + }
+ } + }