2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/inventory/ContainerMerchant.java
+++ b/net/minecraft/world/inventory/ContainerMerchant.java
2021-06-11 07:00:00 +02:00
@@ -12,6 +12,8 @@
2021-03-15 23:00:00 +01:00
import net.minecraft.world.item.trading.MerchantRecipe;
import net.minecraft.world.item.trading.MerchantRecipeList;
2014-11-25 22:32:16 +01:00
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
2016-11-17 02:41:03 +01:00
+
2014-11-25 22:32:16 +01:00
public class ContainerMerchant extends Container {
2021-06-11 07:00:00 +02:00
protected static final int PAYMENT1_SLOT = 0;
@@ -31,6 +33,19 @@
private boolean showProgressBar;
private boolean canRestock;
2015-02-26 23:41:06 +01:00
2014-11-25 22:32:16 +01:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity == null) {
2021-06-11 07:00:00 +02:00
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(trader, tradeContainer), this);
2014-11-25 22:32:16 +01:00
+ }
+ return bukkitEntity;
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
2019-04-23 04:00:00 +02:00
public ContainerMerchant(int i, PlayerInventory playerinventory) {
this(i, playerinventory, new MerchantWrapper(playerinventory.player));
}
2021-06-11 07:00:00 +02:00
@@ -42,6 +57,7 @@
this.a(new Slot(this.tradeContainer, 0, 136, 37));
this.a(new Slot(this.tradeContainer, 1, 162, 37));
this.a((Slot) (new SlotMerchantResult(playerinventory.player, imerchant, this.tradeContainer, 2, 220, 37)));
2014-11-25 22:32:16 +01:00
+ this.player = playerinventory; // CraftBukkit - save player
2019-04-23 04:00:00 +02:00
int j;
2014-11-25 22:32:16 +01:00
2021-06-11 07:00:00 +02:00
@@ -154,7 +170,7 @@
2019-06-06 12:51:53 +02:00
}
2021-06-11 07:00:00 +02:00
private void o() {
- if (!this.trader.getWorld().isClientSide) {
+ if (!this.trader.getWorld().isClientSide && this.trader instanceof Entity) { // CraftBukkit - SPIGOT-5035
Entity entity = (Entity) this.trader;
2019-06-06 12:51:53 +02:00
2021-06-11 07:00:00 +02:00
this.trader.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.trader.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);