Commits
md_5 authored aaf484f6fdb
1 1 | package org.bukkit.craftbukkit.inventory; |
2 2 | |
3 3 | import com.google.common.base.Preconditions; |
4 4 | import java.util.List; |
5 - | import net.minecraft.util.MathHelper; |
6 - | import org.bukkit.Material; |
7 5 | import org.bukkit.inventory.ItemStack; |
8 6 | import org.bukkit.inventory.MerchantRecipe; |
9 7 | |
10 8 | public class CraftMerchantRecipe extends MerchantRecipe { |
11 9 | |
12 10 | private final net.minecraft.world.item.trading.MerchantRecipe handle; |
13 11 | |
14 12 | public CraftMerchantRecipe(net.minecraft.world.item.trading.MerchantRecipe merchantRecipe) { |
15 13 | super(CraftItemStack.asBukkitCopy(merchantRecipe.result), 0); |
16 14 | this.handle = merchantRecipe; |
17 15 | addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.baseCostA)); |
18 16 | addIngredient(CraftItemStack.asBukkitCopy(merchantRecipe.costB)); |
19 17 | } |
20 18 | |
19 + | |
21 20 | public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) { |
22 21 | this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0); |
23 22 | } |
24 23 | |
25 24 | public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice) { |
26 25 | super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice); |
27 26 | this.handle = new net.minecraft.world.item.trading.MerchantRecipe( |
28 27 | net.minecraft.world.item.ItemStack.EMPTY, |
29 28 | net.minecraft.world.item.ItemStack.EMPTY, |
30 29 | CraftItemStack.asNMSCopy(result), |
116 115 | if (ingredients.size() > 1) { |
117 116 | handle.costB = CraftItemStack.asNMSCopy(ingredients.get(1)); |
118 117 | } |
119 118 | return handle; |
120 119 | } |
121 120 | |
122 121 | public static CraftMerchantRecipe fromBukkit(MerchantRecipe recipe) { |
123 122 | if (recipe instanceof CraftMerchantRecipe) { |
124 123 | return (CraftMerchantRecipe) recipe; |
125 124 | } else { |
126 - | CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier()); |
125 + | CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.getDemand(), recipe.getSpecialPrice()); |
127 126 | craft.setIngredients(recipe.getIngredients()); |
128 127 | |
129 128 | return craft; |
130 129 | } |
131 130 | } |
132 131 | } |