Add ignore discounts API
This commit is contained in:
@@ -24,11 +24,19 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
|
||||
@Deprecated
|
||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) {
|
||||
this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0);
|
||||
// Paper start - add ignoreDiscounts param
|
||||
this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0, false);
|
||||
}
|
||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, boolean ignoreDiscounts) {
|
||||
this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0, ignoreDiscounts);
|
||||
}
|
||||
|
||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice) {
|
||||
super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice);
|
||||
this(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice, false);
|
||||
}
|
||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier, int demand, int specialPrice, boolean ignoreDiscounts) {
|
||||
super(result, uses, maxUses, experienceReward, experience, priceMultiplier, demand, specialPrice, ignoreDiscounts);
|
||||
// Paper end
|
||||
this.handle = new net.minecraft.world.item.trading.MerchantOffer(
|
||||
new ItemCost(Items.AIR),
|
||||
Optional.empty(),
|
||||
@@ -38,6 +46,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
experience,
|
||||
priceMultiplier,
|
||||
demand,
|
||||
ignoreDiscounts, // Paper - add ignoreDiscounts param
|
||||
this
|
||||
);
|
||||
this.setSpecialPrice(specialPrice);
|
||||
@@ -114,6 +123,18 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
this.handle.priceMultiplier = priceMultiplier;
|
||||
}
|
||||
|
||||
// Paper start
|
||||
@Override
|
||||
public boolean shouldIgnoreDiscounts() {
|
||||
return this.handle.ignoreDiscounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIgnoreDiscounts(boolean ignoreDiscounts) {
|
||||
this.handle.ignoreDiscounts = ignoreDiscounts;
|
||||
}
|
||||
// Paper end
|
||||
|
||||
public net.minecraft.world.item.trading.MerchantOffer toMinecraft() {
|
||||
List<ItemStack> ingredients = this.getIngredients();
|
||||
Preconditions.checkState(!ingredients.isEmpty(), "No offered ingredients");
|
||||
@@ -134,7 +155,7 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||
if (recipe instanceof CraftMerchantRecipe) {
|
||||
return (CraftMerchantRecipe) recipe;
|
||||
} else {
|
||||
CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.getDemand(), recipe.getSpecialPrice());
|
||||
CraftMerchantRecipe craft = new CraftMerchantRecipe(recipe.getResult(), recipe.getUses(), recipe.getMaxUses(), recipe.hasExperienceReward(), recipe.getVillagerExperience(), recipe.getPriceMultiplier(), recipe.getDemand(), recipe.getSpecialPrice(), recipe.shouldIgnoreDiscounts()); // Paper - shouldIgnoreDiscounts
|
||||
craft.setIngredients(recipe.getIngredients());
|
||||
|
||||
return craft;
|
||||
|
||||
Reference in New Issue
Block a user