2021-03-15 23:00:00 +01:00
--- a/net/minecraft/world/item/trading/MerchantRecipe.java
+++ b/net/minecraft/world/item/trading/MerchantRecipe.java
@@ -5,6 +5,8 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.item.ItemStack;
2016-02-29 22:32:46 +01:00
2016-05-10 13:47:39 +02:00
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit
2016-11-17 02:41:03 +01:00
+
2016-02-29 22:32:46 +01:00
public class MerchantRecipe {
2021-06-11 07:00:00 +02:00
public ItemStack baseCostA;
2021-12-18 01:44:34 +01:00
@@ -13,10 +15,26 @@
public int uses;
public int maxUses;
public boolean rewardExp;
- private int specialPriceDiff;
- private int demand;
+ public int specialPriceDiff; // PAIL private -> public
+ public int demand; // PAIL private -> public
2019-04-23 04:00:00 +02:00
public float priceMultiplier;
public int xp;
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ private CraftMerchantRecipe bukkitHandle;
+
+ public CraftMerchantRecipe asBukkit() {
+ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle;
+ }
+
2019-04-23 04:00:00 +02:00
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) {
2021-12-18 01:44:34 +01:00
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, 0, bukkit);
+ }
+
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand);
2016-02-29 22:32:46 +01:00
+ this.bukkitHandle = bukkit;
+ }
+ // CraftBukkit end
public MerchantRecipe(NBTTagCompound nbttagcompound) {
2019-04-23 04:00:00 +02:00
this.rewardExp = true;
2021-12-18 01:44:34 +01:00
@@ -78,6 +96,7 @@
2019-12-24 00:20:39 +01:00
2021-11-21 23:00:00 +01:00
public ItemStack getCostA() {
2021-06-11 07:00:00 +02:00
int i = this.baseCostA.getCount();
+ if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476
2021-11-21 23:00:00 +01:00
ItemStack itemstack = this.baseCostA.copy();
int j = Math.max(0, MathHelper.floor((float) (i * this.demand) * this.priceMultiplier));
2019-12-24 00:20:39 +01:00
2021-12-18 01:44:34 +01:00
@@ -199,7 +218,11 @@
if (!this.satisfiedBy(itemstack, itemstack1)) {
return false;
} else {
- itemstack.shrink(this.getCostA().getCount());
+ // CraftBukkit start
+ if (!this.getCostA().isEmpty()) {
+ itemstack.shrink(this.getCostA().getCount());
+ }
+ // CraftBukkit end
if (!this.getCostB().isEmpty()) {
itemstack1.shrink(this.getCostB().getCount());
}