PaperMC/paper-server/nms-patches/net/minecraft/world/inventory/ContainerMerchant.patch
CraftBukkit/Spigot 65bc2541a3 Update to Minecraft 1.20.5
By: md_5 <git@md-5.net>
2024-04-24 01:15:00 +10:00

48 lines
1.9 KiB
Diff

--- a/net/minecraft/world/inventory/ContainerMerchant.java
+++ b/net/minecraft/world/inventory/ContainerMerchant.java
@@ -13,6 +13,8 @@
import net.minecraft.world.item.trading.MerchantRecipe;
import net.minecraft.world.item.trading.MerchantRecipeList;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerMerchant extends Container {
protected static final int PAYMENT1_SLOT = 0;
@@ -32,6 +34,19 @@
private boolean showProgressBar;
private boolean canRestock;
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity == null) {
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(trader, tradeContainer), this);
+ }
+ return bukkitEntity;
+ }
+ // CraftBukkit end
+
public ContainerMerchant(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new MerchantWrapper(playerinventory.player));
}
@@ -43,6 +58,7 @@
this.addSlot(new Slot(this.tradeContainer, 0, 136, 37));
this.addSlot(new Slot(this.tradeContainer, 1, 162, 37));
this.addSlot(new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37));
+ this.player = playerinventory; // CraftBukkit - save player
int j;
@@ -155,7 +171,7 @@
}
private void playTradeSound() {
- if (!this.trader.isClientSide()) {
+ if (!this.trader.isClientSide() && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
Entity entity = (Entity) this.trader;
entity.level().playLocalSound(entity.getX(), entity.getY(), entity.getZ(), this.trader.getNotifyTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);