diff options
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/inventory/MerchantContainer.java.patch')
-rw-r--r-- | patch-remap/mache-spigotflower/net/minecraft/world/inventory/MerchantContainer.java.patch | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/inventory/MerchantContainer.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/MerchantContainer.java.patch new file mode 100644 index 0000000000..d99120520f --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/inventory/MerchantContainer.java.patch @@ -0,0 +1,213 @@ +--- a/net/minecraft/world/inventory/MerchantContainer.java ++++ b/net/minecraft/world/inventory/MerchantContainer.java +@@ -5,11 +5,20 @@ + import net.minecraft.core.NonNullList; + import net.minecraft.world.Container; + import net.minecraft.world.ContainerHelper; ++import net.minecraft.world.entity.npc.AbstractVillager; ++import net.minecraft.world.entity.npc.Villager; + import net.minecraft.world.entity.player.Player; + import net.minecraft.world.item.ItemStack; + import net.minecraft.world.item.trading.Merchant; + import net.minecraft.world.item.trading.MerchantOffer; + import net.minecraft.world.item.trading.MerchantOffers; ++// CraftBukkit start ++import java.util.List; ++import org.bukkit.Location; ++import org.bukkit.craftbukkit.entity.CraftHumanEntity; ++import org.bukkit.craftbukkit.entity.CraftAbstractVillager; ++import org.bukkit.entity.HumanEntity; ++// CraftBukkit end + + public class MerchantContainer implements Container { + +@@ -17,22 +26,60 @@ + private final NonNullList<ItemStack> itemStacks; + @Nullable + private MerchantOffer activeOffer; +- private int selectionHint; ++ public int selectionHint; + private int futureXp; + ++ // CraftBukkit start - add fields and methods ++ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>(); ++ private int maxStack = MAX_STACK; ++ ++ public List<ItemStack> getContents() { ++ return this.itemStacks; ++ } ++ ++ public void onOpen(CraftHumanEntity who) { ++ transaction.add(who); ++ } ++ ++ public void onClose(CraftHumanEntity who) { ++ transaction.remove(who); ++ merchant.setTradingPlayer((Player) null); // SPIGOT-4860 ++ } ++ ++ public List<HumanEntity> getViewers() { ++ return transaction; ++ } ++ ++ @Override ++ public int getMaxStackSize() { ++ return maxStack; ++ } ++ ++ public void setMaxStackSize(int i) { ++ maxStack = i; ++ } ++ ++ public org.bukkit.inventory.InventoryHolder getOwner() { ++ return (merchant instanceof AbstractVillager) ? (CraftAbstractVillager) ((AbstractVillager) this.merchant).getBukkitEntity() : null; ++ } ++ ++ @Override ++ public Location getLocation() { ++ return (merchant instanceof Villager) ? ((Villager) this.merchant).getBukkitEntity().getLocation() : null; ++ } ++ // CraftBukkit end ++ + public MerchantContainer(Merchant merchant) { + this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY); + this.merchant = merchant; + } + + @Override +- @Override + public int getContainerSize() { + return this.itemStacks.size(); + } + + @Override +- @Override + public boolean isEmpty() { + Iterator iterator = this.itemStacks.iterator(); + +@@ -50,22 +97,20 @@ + } + + @Override +- @Override +- public ItemStack getItem(int i) { +- return (ItemStack) this.itemStacks.get(i); ++ public ItemStack getItem(int index) { ++ return (ItemStack) this.itemStacks.get(index); + } + + @Override +- @Override +- public ItemStack removeItem(int i, int j) { +- ItemStack itemstack = (ItemStack) this.itemStacks.get(i); ++ public ItemStack removeItem(int index, int count) { ++ ItemStack itemstack = (ItemStack) this.itemStacks.get(index); + +- if (i == 2 && !itemstack.isEmpty()) { +- return ContainerHelper.removeItem(this.itemStacks, i, itemstack.getCount()); ++ if (index == 2 && !itemstack.isEmpty()) { ++ return ContainerHelper.removeItem(this.itemStacks, index, itemstack.getCount()); + } else { +- ItemStack itemstack1 = ContainerHelper.removeItem(this.itemStacks, i, j); ++ ItemStack itemstack1 = ContainerHelper.removeItem(this.itemStacks, index, count); + +- if (!itemstack1.isEmpty() && this.isPaymentSlot(i)) { ++ if (!itemstack1.isEmpty() && this.isPaymentSlot(index)) { + this.updateSellItem(); + } + +@@ -73,38 +118,34 @@ + } + } + +- private boolean isPaymentSlot(int i) { +- return i == 0 || i == 1; ++ private boolean isPaymentSlot(int slot) { ++ return slot == 0 || slot == 1; + } + + @Override +- @Override +- public ItemStack removeItemNoUpdate(int i) { +- return ContainerHelper.takeItem(this.itemStacks, i); ++ public ItemStack removeItemNoUpdate(int index) { ++ return ContainerHelper.takeItem(this.itemStacks, index); + } + + @Override +- @Override +- public void setItem(int i, ItemStack itemstack) { +- this.itemStacks.set(i, itemstack); +- if (!itemstack.isEmpty() && itemstack.getCount() > this.getMaxStackSize()) { +- itemstack.setCount(this.getMaxStackSize()); ++ public void setItem(int index, ItemStack stack) { ++ this.itemStacks.set(index, stack); ++ if (!stack.isEmpty() && stack.getCount() > this.getMaxStackSize()) { ++ stack.setCount(this.getMaxStackSize()); + } + +- if (this.isPaymentSlot(i)) { ++ if (this.isPaymentSlot(index)) { + this.updateSellItem(); + } + + } + + @Override +- @Override + public boolean stillValid(Player player) { + return this.merchant.getTradingPlayer() == player; + } + + @Override +- @Override + public void setChanged() { + this.updateSellItem(); + } +@@ -126,20 +167,20 @@ + this.setItem(2, ItemStack.EMPTY); + this.futureXp = 0; + } else { +- MerchantOffers merchantoffers = this.merchant.getOffers(); ++ MerchantOffers merchantrecipelist = this.merchant.getOffers(); + +- if (!merchantoffers.isEmpty()) { +- MerchantOffer merchantoffer = merchantoffers.getRecipeFor(itemstack, itemstack1, this.selectionHint); ++ if (!merchantrecipelist.isEmpty()) { ++ MerchantOffer merchantrecipe = merchantrecipelist.getRecipeFor(itemstack, itemstack1, this.selectionHint); + +- if (merchantoffer == null || merchantoffer.isOutOfStock()) { +- this.activeOffer = merchantoffer; +- merchantoffer = merchantoffers.getRecipeFor(itemstack1, itemstack, this.selectionHint); ++ if (merchantrecipe == null || merchantrecipe.isOutOfStock()) { ++ this.activeOffer = merchantrecipe; ++ merchantrecipe = merchantrecipelist.getRecipeFor(itemstack1, itemstack, this.selectionHint); + } + +- if (merchantoffer != null && !merchantoffer.isOutOfStock()) { +- this.activeOffer = merchantoffer; +- this.setItem(2, merchantoffer.assemble()); +- this.futureXp = merchantoffer.getXp(); ++ if (merchantrecipe != null && !merchantrecipe.isOutOfStock()) { ++ this.activeOffer = merchantrecipe; ++ this.setItem(2, merchantrecipe.assemble()); ++ this.futureXp = merchantrecipe.getXp(); + } else { + this.setItem(2, ItemStack.EMPTY); + this.futureXp = 0; +@@ -155,13 +196,12 @@ + return this.activeOffer; + } + +- public void setSelectionHint(int i) { +- this.selectionHint = i; ++ public void setSelectionHint(int currentRecipeIndex) { ++ this.selectionHint = currentRecipeIndex; + this.updateSellItem(); + } + + @Override +- @Override + public void clearContent() { + this.itemStacks.clear(); + } |