mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-29 12:27:59 +01:00
81 lines
3.0 KiB
Diff
81 lines
3.0 KiB
Diff
--- a/net/minecraft/server/RecipesFurnace.java
|
|
+++ b/net/minecraft/server/RecipesFurnace.java
|
|
@@ -8,8 +8,10 @@
|
|
public class RecipesFurnace {
|
|
|
|
private static final RecipesFurnace a = new RecipesFurnace();
|
|
- public final Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
|
|
+ public Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
|
|
private final Map<ItemStack, Float> experience = Maps.newHashMap();
|
|
+ public Map<ItemStack,ItemStack> customRecipes = Maps.newHashMap(); // CraftBukkit - add field
|
|
+ public Map<ItemStack,Float> customExperience = Maps.newHashMap(); // CraftBukkit - add field
|
|
|
|
public static RecipesFurnace getInstance() {
|
|
return RecipesFurnace.a;
|
|
@@ -94,6 +96,13 @@
|
|
this.a(new ItemStack(Blocks.STAINED_HARDENED_CLAY, 1, EnumColor.BLACK.getColorIndex()), new ItemStack(Blocks.dQ), 0.1F);
|
|
}
|
|
|
|
+ // CraftBukkit start - add method
|
|
+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1, float f) {
|
|
+ this.customRecipes.put(itemstack, itemstack1);
|
|
+ this.customExperience.put(itemstack, f);
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
public void registerRecipe(Block block, ItemStack itemstack, float f) {
|
|
this.a(Item.getItemOf(block), itemstack, f);
|
|
}
|
|
@@ -108,13 +117,23 @@
|
|
}
|
|
|
|
public ItemStack getResult(ItemStack itemstack) {
|
|
- Iterator iterator = this.recipes.entrySet().iterator();
|
|
+ // CraftBukkit start - initialize to customRecipes
|
|
+ boolean vanilla = false;
|
|
+ Iterator<Entry<ItemStack, ItemStack>> iterator = this.customRecipes.entrySet().iterator();
|
|
+ // CraftBukkit end
|
|
|
|
Entry entry;
|
|
|
|
do {
|
|
if (!iterator.hasNext()) {
|
|
- return ItemStack.a;
|
|
+ // CraftBukkit start - fall back to vanilla recipes
|
|
+ if (!vanilla && !this.recipes.isEmpty()) {
|
|
+ iterator = this.recipes.entrySet().iterator();
|
|
+ vanilla = true;
|
|
+ } else {
|
|
+ return ItemStack.a;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
entry = (Entry) iterator.next();
|
|
@@ -132,13 +151,23 @@
|
|
}
|
|
|
|
public float b(ItemStack itemstack) {
|
|
- Iterator iterator = this.experience.entrySet().iterator();
|
|
+ // CraftBukkit start - initialize to customRecipes
|
|
+ boolean vanilla = false;
|
|
+ Iterator<Entry<ItemStack, Float>> iterator = this.customExperience.entrySet().iterator();
|
|
+ // CraftBukkit end
|
|
|
|
Entry entry;
|
|
|
|
do {
|
|
if (!iterator.hasNext()) {
|
|
- return 0.0F;
|
|
+ // CraftBukkit start - fall back to vanilla recipes
|
|
+ if (!vanilla && !this.experience.isEmpty()) {
|
|
+ iterator = this.experience.entrySet().iterator();
|
|
+ vanilla = true;
|
|
+ } else {
|
|
+ return 0.0F;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
entry = (Entry) iterator.next();
|