mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-10 10:17:38 +01:00
65bc2541a3
By: md_5 <git@md-5.net>
44 lines
1.8 KiB
Diff
44 lines
1.8 KiB
Diff
--- a/net/minecraft/world/item/trading/MerchantRecipe.java
|
|
+++ b/net/minecraft/world/item/trading/MerchantRecipe.java
|
|
@@ -8,6 +8,8 @@
|
|
import net.minecraft.util.MathHelper;
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
+import org.bukkit.craftbukkit.inventory.CraftMerchantRecipe; // CraftBukkit
|
|
+
|
|
public class MerchantRecipe {
|
|
|
|
public static final Codec<MerchantRecipe> CODEC = RecordCodecBuilder.create((instance) -> {
|
|
@@ -44,6 +46,18 @@
|
|
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 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);
|
|
+ this.bukkitHandle = bukkit;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
|
|
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 @@
|
|
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());
|
|
}
|