Add custom experience levels for FurnaceRecipes.

By: hibo98 <hibo98.niklas@gmail.com>
This commit is contained in:
Bukkit/Spigot 2016-03-01 08:30:03 +11:00
parent f2fcb9f8bd
commit 3f578832ea

View File

@ -9,6 +9,7 @@ import org.bukkit.material.MaterialData;
public class FurnaceRecipe implements Recipe { public class FurnaceRecipe implements Recipe {
private ItemStack output; private ItemStack output;
private ItemStack ingredient; private ItemStack ingredient;
private float experience;
/** /**
* Create a furnace recipe to craft the specified ItemStack. * Create a furnace recipe to craft the specified ItemStack.
@ -17,7 +18,7 @@ public class FurnaceRecipe implements Recipe {
* @param source The input material. * @param source The input material.
*/ */
public FurnaceRecipe(ItemStack result, Material source) { public FurnaceRecipe(ItemStack result, Material source) {
this(result, source, 0); this(result, source, 0, 0);
} }
/** /**
@ -27,7 +28,18 @@ public class FurnaceRecipe implements Recipe {
* @param source The input material. * @param source The input material.
*/ */
public FurnaceRecipe(ItemStack result, MaterialData source) { public FurnaceRecipe(ItemStack result, MaterialData source) {
this(result, source.getItemType(), source.getData()); this(result, source.getItemType(), source.getData(), 0);
}
/**
* Create a furnace recipe to craft the specified ItemStack.
*
* @param result The item you want the recipe to create.
* @param source The input material.
* @param experience The experience given by this recipe
*/
public FurnaceRecipe(ItemStack result, MaterialData source, float experience) {
this(result, source.getItemType(), source.getData(), experience);
} }
/** /**
@ -41,8 +53,24 @@ public class FurnaceRecipe implements Recipe {
*/ */
@Deprecated @Deprecated
public FurnaceRecipe(ItemStack result, Material source, int data) { public FurnaceRecipe(ItemStack result, Material source, int data) {
this(result, source, data, 0);
}
/**
* Create a furnace recipe to craft the specified ItemStack.
*
* @param result The item you want the recipe to create.
* @param source The input material.
* @param data The data value. (Note: This is currently ignored by the
* CraftBukkit server.)
* @param experience The experience given by this recipe
* @deprecated Magic value
*/
@Deprecated
public FurnaceRecipe(ItemStack result, Material source, int data, float experience) {
this.output = new ItemStack(result); this.output = new ItemStack(result);
this.ingredient = new ItemStack(source, 1, (short) data); this.ingredient = new ItemStack(source, 1, (short) data);
this.experience = experience;
} }
/** /**
@ -97,4 +125,22 @@ public class FurnaceRecipe implements Recipe {
public ItemStack getResult() { public ItemStack getResult() {
return output.clone(); return output.clone();
} }
/**
* Sets the experience given by this recipe.
*
* @param experience the experience level
*/
public void setExperience(float experience) {
this.experience = experience;
}
/**
* Get the experience given by this recipe.
*
* @return experience level
*/
public float getExperience() {
return experience;
}
} }