3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 07:10:10 +01:00
Paper/nms-patches/ContainerMerchant.patch
2019-07-20 09:00:00 +10:00

46 Zeilen
1.8 KiB
Diff

--- a/net/minecraft/server/ContainerMerchant.java
+++ b/net/minecraft/server/ContainerMerchant.java
@@ -1,10 +1,25 @@
package net.minecraft.server;
+import org.bukkit.craftbukkit.inventory.CraftInventoryView; // CraftBukkit
+
public class ContainerMerchant extends Container {
private final IMerchant merchant;
private final InventoryMerchant inventoryMerchant;
+ // 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(merchant, inventoryMerchant), this);
+ }
+ return bukkitEntity;
+ }
+ // CraftBukkit end
+
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
int j;
@@ -96,7 +112,7 @@
}
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;
this.merchant.getWorld().a(entity.locX, entity.locY, entity.locZ, this.merchant.eb(), SoundCategory.NEUTRAL, 1.0F, 1.0F, false);