2021-03-16 09:00:00 +11:00
--- a/net/minecraft/world/item/trading/MerchantRecipe.java
+++ b/net/minecraft/world/item/trading/MerchantRecipe.java
2024-04-24 01:15:00 +10:00
@@ -8,6 +8,8 @@
2021-03-16 09:00:00 +11:00
import net.minecraft.util.MathHelper;
import net.minecraft.world.item.ItemStack;
2016-03-01 08:32:46 +11:00
2016-05-10 21:47:39 +10:00
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit
2016-11-17 12:41:03 +11:00
+
2016-03-01 08:32:46 +11:00
public class MerchantRecipe {
2024-04-24 01:15:00 +10:00
public static final Codec<MerchantRecipe> CODEC = RecordCodecBuilder.create((instance) -> {
@@ -44,6 +46,18 @@
2022-06-08 02:00:00 +10:00
public int demand;
2019-04-23 12:00:00 +10:00
public float priceMultiplier;
public int xp;
2016-03-01 08:32:46 +11:00
+ // CraftBukkit start
+ private CraftMerchantRecipe bukkitHandle;
+
+ public CraftMerchantRecipe asBukkit() {
+ return (bukkitHandle == null) ? bukkitHandle = new CraftMerchantRecipe(this) : bukkitHandle;
+ }
+
2024-04-24 01:15:00 +10:00
+ public MerchantRecipe(ItemCost baseCostA, Optional<ItemCost> costB, ItemStack result, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
+ this(baseCostA, costB, result, uses, maxUses, experience, priceMultiplier, demand);
2016-03-01 08:32:46 +11:00
+ this.bukkitHandle = bukkit;
+ }
+ // CraftBukkit end
2024-04-24 01:15:00 +10:00
private MerchantRecipe(ItemCost itemcost, Optional<ItemCost> optional, ItemStack itemstack, int i, int j, boolean flag, int k, int l, float f, int i1) {
this.baseCostA = itemcost;
@@ -185,7 +199,11 @@
2021-12-18 11:44:34 +11:00
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());
}