Fix PlayerTradeEvent visual issue when being cancelled (#11773)

This commit is contained in:
Kobe ⑧ 2024-12-23 01:40:04 -08:00 committed by GitHub
parent cbf630d5b5
commit 17f649de1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,6 +1,6 @@
--- a/net/minecraft/world/inventory/MerchantResultSlot.java --- a/net/minecraft/world/inventory/MerchantResultSlot.java
+++ b/net/minecraft/world/inventory/MerchantResultSlot.java +++ b/net/minecraft/world/inventory/MerchantResultSlot.java
@@ -47,13 +_,32 @@ @@ -47,13 +_,34 @@
@Override @Override
public void onTake(Player player, ItemStack stack) { public void onTake(Player player, ItemStack stack) {
@ -19,6 +19,8 @@
+ if (!event.callEvent()) { + if (!event.callEvent()) {
+ stack.setCount(0); + stack.setCount(0);
+ event.getPlayer().updateInventory(); + event.getPlayer().updateInventory();
+ int level = merchant instanceof net.minecraft.world.entity.npc.Villager villager ? villager.getVillagerData().getLevel() : 1;
+ serverPlayer.sendMerchantOffers(player.containerMenu.containerId, merchant.getOffers(), level, merchant.getVillagerXp(), merchant.showProgressBar(), merchant.canRestock());
+ return; + return;
+ } + }
+ activeOffer = org.bukkit.craftbukkit.inventory.CraftMerchantRecipe.fromBukkit(event.getTrade()).toMinecraft(); + activeOffer = org.bukkit.craftbukkit.inventory.CraftMerchantRecipe.fromBukkit(event.getTrade()).toMinecraft();