PaperMC/nms-patches/ContainerMerchant.patch

46 lines
1.8 KiB
Diff
Raw Normal View History

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/ContainerMerchant.java
+++ b/net/minecraft/server/ContainerMerchant.java
2019-04-23 04:00:00 +02:00
@@ -1,10 +1,25 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
2016-11-17 02:41:03 +01:00
+
public class ContainerMerchant extends Container {
2016-11-17 02:41:03 +01:00
private final IMerchant merchant;
2019-04-23 04:00:00 +02:00
private final InventoryMerchant inventoryMerchant;
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start
+ private CraftInventoryView bukkitEntity = null;
+ private PlayerInventory player;
+
+ @Override
+ public CraftInventoryView getBukkitView() {
+ if (bukkitEntity == null) {
2019-04-28 04:35:28 +02:00
+ bukkitEntity = new CraftInventoryView(this.player.player.getBukkitEntity(), new org.bukkit.craftbukkit.inventory.CraftInventoryMerchant(merchant, inventoryMerchant), this);
+ }
+ 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));
}
@@ -16,6 +31,7 @@
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)));
+ this.player = playerinventory; // CraftBukkit - save player
2019-04-23 04:00:00 +02:00
int j;
@@ -96,7 +112,7 @@
}
2019-06-21 12:00:00 +02:00
private void k() {
- if (!this.merchant.getWorld().isClientSide) {
+ if (!this.merchant.getWorld().isClientSide && this.merchant instanceof Entity) { // CraftBukkit - SPIGOT-5035
Entity entity = (Entity) this.merchant;
2019-12-10 23:00:00 +01:00
this.merchant.getWorld().a(entity.locX(), entity.locY(), entity.locZ(), this.merchant.getTradeSound(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);