mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-08 11:24:11 +01:00
SPIGOT-6836: Add more API methods in MerchantRecipe
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
13aa9b7211
commit
3736fd83de
2 changed files with 56 additions and 5 deletions
|
@ -9,8 +9,14 @@
|
||||||
public class MerchantRecipe {
|
public class MerchantRecipe {
|
||||||
|
|
||||||
public ItemStack baseCostA;
|
public ItemStack baseCostA;
|
||||||
@@ -17,6 +19,18 @@
|
@@ -13,10 +15,26 @@
|
||||||
private int demand;
|
public int uses;
|
||||||
|
public int maxUses;
|
||||||
|
public boolean rewardExp;
|
||||||
|
- private int specialPriceDiff;
|
||||||
|
- private int demand;
|
||||||
|
+ public int specialPriceDiff; // PAIL private -> public
|
||||||
|
+ public int demand; // PAIL private -> public
|
||||||
public float priceMultiplier;
|
public float priceMultiplier;
|
||||||
public int xp;
|
public int xp;
|
||||||
+ // CraftBukkit start
|
+ // CraftBukkit start
|
||||||
|
@ -21,14 +27,18 @@
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, CraftMerchantRecipe bukkit) {
|
+ 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);
|
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, 0, bukkit);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public MerchantRecipe(ItemStack itemstack, ItemStack itemstack1, ItemStack itemstack2, int uses, int maxUses, int experience, float priceMultiplier, int demand, CraftMerchantRecipe bukkit) {
|
||||||
|
+ this(itemstack, itemstack1, itemstack2, uses, maxUses, experience, priceMultiplier, demand);
|
||||||
+ this.bukkitHandle = bukkit;
|
+ this.bukkitHandle = bukkit;
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
|
|
||||||
public MerchantRecipe(NBTTagCompound nbttagcompound) {
|
public MerchantRecipe(NBTTagCompound nbttagcompound) {
|
||||||
this.rewardExp = true;
|
this.rewardExp = true;
|
||||||
@@ -78,6 +92,7 @@
|
@@ -78,6 +96,7 @@
|
||||||
|
|
||||||
public ItemStack getCostA() {
|
public ItemStack getCostA() {
|
||||||
int i = this.baseCostA.getCount();
|
int i = this.baseCostA.getCount();
|
||||||
|
@ -36,3 +46,16 @@
|
||||||
ItemStack itemstack = this.baseCostA.copy();
|
ItemStack itemstack = this.baseCostA.copy();
|
||||||
int j = Math.max(0, MathHelper.floor((float) (i * this.demand) * this.priceMultiplier));
|
int j = Math.max(0, MathHelper.floor((float) (i * this.demand) * this.priceMultiplier));
|
||||||
|
|
||||||
|
@@ -199,7 +218,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());
|
||||||
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package org.bukkit.craftbukkit.inventory;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.MerchantRecipe;
|
import org.bukkit.inventory.MerchantRecipe;
|
||||||
|
|
||||||
|
@ -17,7 +19,11 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||||
}
|
}
|
||||||
|
|
||||||
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) {
|
public CraftMerchantRecipe(ItemStack result, int uses, int maxUses, boolean experienceReward, int experience, float priceMultiplier) {
|
||||||
super(result, uses, maxUses, experienceReward, experience, priceMultiplier);
|
this(result, uses, maxUses, experienceReward, experience, priceMultiplier, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.handle = new net.minecraft.world.item.trading.MerchantRecipe(
|
this.handle = new net.minecraft.world.item.trading.MerchantRecipe(
|
||||||
net.minecraft.world.item.ItemStack.EMPTY,
|
net.minecraft.world.item.ItemStack.EMPTY,
|
||||||
net.minecraft.world.item.ItemStack.EMPTY,
|
net.minecraft.world.item.ItemStack.EMPTY,
|
||||||
|
@ -26,11 +32,33 @@ public class CraftMerchantRecipe extends MerchantRecipe {
|
||||||
maxUses,
|
maxUses,
|
||||||
experience,
|
experience,
|
||||||
priceMultiplier,
|
priceMultiplier,
|
||||||
|
demand,
|
||||||
this
|
this
|
||||||
);
|
);
|
||||||
|
this.setSpecialPrice(specialPrice);
|
||||||
this.setExperienceReward(experienceReward);
|
this.setExperienceReward(experienceReward);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getSpecialPrice() {
|
||||||
|
return handle.getSpecialPriceDiff();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setSpecialPrice(int specialPrice) {
|
||||||
|
handle.specialPriceDiff = specialPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDemand() {
|
||||||
|
return handle.demand;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setDemand(int demand) {
|
||||||
|
handle.demand = demand;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getUses() {
|
public int getUses() {
|
||||||
return handle.uses;
|
return handle.uses;
|
||||||
|
|
Loading…
Reference in a new issue