aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch73
1 files changed, 73 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/world/item/trading/MerchantOffer.java.patch
new file mode 100644
index 0000000000..497a5ecc84
--- /dev/null
+++ b/patch-remap/mache-spigotflower-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,20 +5,38 @@
+ 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;
+- private final ItemStack result;
+- private int uses;
+- private final int maxUses;
+- private boolean rewardExp;
+- private int specialPriceDiff;
+- private int demand;
+- private float priceMultiplier;
+- private int xp;
++ 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 MerchantOffer(CompoundTag compoundtag) {
++ 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.rewardExp = true;
+ this.xp = 1;
+ this.baseCostA = ItemStack.of(compoundtag.getCompound("buy"));
+@@ -96,6 +114,7 @@
+ return ItemStack.EMPTY;
+ } else {
+ 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()));
+@@ -216,7 +235,11 @@
+ if (!this.satisfiedBy(itemstack, itemstack1)) {
+ return false;
+ } else {
+- itemstack.shrink(this.getCostA().getCount());
++ // CraftBukkit start
++ if (!this.getCostA().isEmpty()) {
++ playerOfferA.shrink(this.getCostA().getCount());
++ }
++ // CraftBukkit end
+ if (!this.getCostB().isEmpty()) {
+ itemstack1.shrink(this.getCostB().getCount());
+ }