diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch new file mode 100644 index 0000000000..260f3829e8 --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch @@ -0,0 +1,73 @@ +--- a/net/minecraft/world/item/trading/MerchantOffer.java ++++ b/net/minecraft/world/item/trading/MerchantOffer.java +@@ -5,6 +5,8 @@ + import net.minecraft.util.Mth; + import net.minecraft.world.item.ItemStack; + ++import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit ++ + public class MerchantOffer { + private final ItemStack baseCostA; + private final ItemStack costB; +@@ -17,6 +9,33 @@ + private float priceMultiplier; + private int xp = 1; + ++ public ItemStack baseCostA; ++ public ItemStack costB; ++ public final ItemStack result; ++ public int uses; ++ public int maxUses; ++ public boolean rewardExp; ++ public int specialPriceDiff; ++ public int demand; ++ public float priceMultiplier; ++ public int xp; ++ // CraftBukkit start ++ private CraftMerchantRecipe bukkitHandle; ++ ++ public CraftMerchantRecipe asBukkit() { ++ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle; ++ } ++ ++ public MerchantOffer(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 MerchantOffer(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 MerchantOffer(CompoundTag compoundTag) { + this.baseCostA = ItemStack.of(compoundTag.getCompound("buy")); + this.costB = ItemStack.of(compoundTag.getCompound("buyB")); +@@ -88,9 +113,11 @@ + if (this.baseCostA.isEmpty()) { + return ItemStack.EMPTY; + } else { +- int count = this.baseCostA.getCount(); +- int max = Math.max(0, Mth.floor((float)(count * this.demand) * this.priceMultiplier)); +- return this.baseCostA.copyWithCount(Mth.clamp(count + max + this.specialPriceDiff, 1, this.baseCostA.getItem().getMaxStackSize())); ++ int i = this.baseCostA.getCount(); ++ if (i <= 0) return ItemStack.EMPTY; // CraftBukkit - SPIGOT-5476 ++ int j = Math.max(0, Mth.floor((float) (i * this.demand) * this.priceMultiplier)); ++ ++ return this.baseCostA.copyWithCount(Mth.clamp(i + j + this.specialPriceDiff, 1, this.baseCostA.getItem().getMaxStackSize())); + } + } + +@@ -210,7 +235,11 @@ + if (!this.satisfiedBy(playerOfferA, playerOfferB)) { + return false; + } else { +- playerOfferA.shrink(this.getCostA().getCount()); ++ // CraftBukkit start ++ if (!this.getCostA().isEmpty()) { ++ playerOfferA.shrink(this.getCostA().getCount()); ++ } ++ // CraftBukkit end + if (!this.getCostB().isEmpty()) { + playerOfferB.shrink(this.getCostB().getCount()); + } |