2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/inventory/ContainerMerchant.java
+++ b/net/minecraft/world/inventory/ContainerMerchant.java
@@ -12,11 +12,26 @@
import net.minecraft.world.item.trading.MerchantRecipe;
import net.minecraft.world.item.trading.MerchantRecipeList;
2014-11-26 08:32:16 +11:00
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
2016-11-17 12:41:03 +11:00
+
2014-11-26 08:32:16 +11:00
public class ContainerMerchant extends Container {
2016-11-17 12:41:03 +11:00
private final IMerchant merchant;
2019-04-23 12:00:00 +10:00
private final InventoryMerchant inventoryMerchant;
2015-02-26 22:41:06 +00:00
2014-11-26 08:32:16 +11:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity == null) {
2019-04-28 12:35:28 +10:00
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(merchant, inventoryMerchant), this);
2014-11-26 08:32:16 +11:00
+ }
+ return bukkitEntity;
+ }
+ // CraftBukkit end
2015-02-26 22:41:06 +00:00
+
2019-04-23 12:00:00 +10:00
public ContainerMerchant(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new MerchantWrapper(playerinventory.player));
}
2021-03-16 09:00:00 +11:00
@@ -28,6 +43,7 @@
2019-04-23 12:00:00 +10:00
this.a(new Slot(this.inventoryMerchant, 0, 136, 37));
this.a(new Slot(this.inventoryMerchant, 1, 162, 37));
this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.inventoryMerchant, 2, 220, 37)));
2014-11-26 08:32:16 +11:00
+ this.player = playerinventory; // CraftBukkit - save player
2019-04-23 12:00:00 +10:00
int j;
2014-11-26 08:32:16 +11:00
2021-03-16 09:00:00 +11:00
@@ -108,7 +124,7 @@
2019-06-06 20:51:53 +10:00
}
2019-06-21 20:00:00 +10:00
private void k() {
2019-06-06 20:51:53 +10:00
- if (!this.merchant.getWorld().isClientSide) {
+ if (!this.merchant.getWorld().isClientSide && this.merchant instanceof Entity) { // CraftBukkit - SPIGOT-5035
Entity entity = (Entity) this.merchant;
2019-12-11 09:00:00 +11:00
this.merchant.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.merchant.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);