PaperMC/nms-patches/MerchantRecipe.patch

38 lines
1.4 KiB
Diff
Raw Normal View History

2016-02-29 22:32:46 +01:00
--- a/net/minecraft/server/MerchantRecipe.java
+++ b/net/minecraft/server/MerchantRecipe.java
2016-11-17 02:41:03 +01:00
@@ -1,5 +1,7 @@
2016-02-29 22:32:46 +01:00
package net.minecraft.server;
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 {
2016-11-17 02:41:03 +01:00
public ItemStack buyingItem1;
2019-04-23 04:00:00 +02:00
@@ -12,6 +14,18 @@
2019-05-14 02:00:00 +02:00
private int demand;
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) {
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier);
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;
2019-12-24 00:20:39 +01:00
@@ -73,6 +87,7 @@
public ItemStack getBuyItem1() {
int i = this.buyingItem1.getCount();
2020-06-25 02:00:00 +02:00
+ if (i <= 0) return ItemStack.b; // CraftBukkit - SPIGOT-5476
2019-12-24 00:20:39 +01:00
ItemStack itemstack = this.buyingItem1.cloneItemStack();
int j = Math.max(0, MathHelper.d((float) (i * this.demand) * this.priceMultiplier));