mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 18:27:41 +01:00
3736fd83de
By: Doc <nachito94@msn.com>
62 lines
2.4 KiB
Diff
62 lines
2.4 KiB
Diff
--- 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;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit
|
|
+
|
|
public class MerchantRecipe {
|
|
|
|
public ItemStack baseCostA;
|
|
@@ -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
|
|
public float priceMultiplier;
|
|
public int xp;
|
|
+ // CraftBukkit start
|
|
+ private CraftMerchantRecipe bukkitHandle;
|
|
+
|
|
+ public CraftMerchantRecipe asBukkit() {
|
|
+ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle;
|
|
+ }
|
|
+
|
|
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) {
|
|
+ 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);
|
|
+ this.bukkitHandle = bukkit;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
public MerchantRecipe(NBTTagCompound nbttagcompound) {
|
|
this.rewardExp = true;
|
|
@@ -78,6 +96,7 @@
|
|
|
|
public ItemStack getCostA() {
|
|
int i = this.baseCostA.getCount();
|
|
+ if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476
|
|
ItemStack itemstack = this.baseCostA.copy();
|
|
int j = Math.max(0, MathHelper.floor((float) (i * this.demand) * this.priceMultiplier));
|
|
|
|
@@ -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());
|
|
}
|