Paper/nms-patches/RecipesFurnace.patch

79 lines
2.8 KiB
Diff

--- a/net/minecraft/server/RecipesFurnace.java
+++ b/net/minecraft/server/RecipesFurnace.java
@@ -10,7 +10,9 @@
private static final RecipesFurnace a = new RecipesFurnace();
public Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
- private Map<ItemStack, Float> c = Maps.newHashMap();
+ private Map<ItemStack, Float> c = Maps.newHashMap(); // PAIL: rename
+ 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;
@@ -55,6 +57,12 @@
this.registerRecipe(Blocks.QUARTZ_ORE, new ItemStack(Items.QUARTZ), 0.2F);
}
+ // CraftBukkit start - add method
+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1, float f) {
+ this.customRecipes.put(itemstack, itemstack1);
+ }
+ // CraftBukkit end
+
public void registerRecipe(Block block, ItemStack itemstack, float f) {
this.a(Item.getItemOf(block), itemstack, f);
}
@@ -70,13 +78,23 @@
@Nullable
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 null;
+ // CraftBukkit start - fall back to vanilla recipes
+ if (!vanilla && !this.recipes.isEmpty()) {
+ iterator = this.recipes.entrySet().iterator();
+ vanilla = true;
+ } else {
+ return null;
+ }
+ // CraftBukkit end
}
entry = (Entry) iterator.next();
@@ -94,13 +112,23 @@
}
public float b(ItemStack itemstack) {
- Iterator iterator = this.c.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.c.isEmpty()) {
+ iterator = this.c.entrySet().iterator();
+ vanilla = true;
+ } else {
+ return 0.0F;
+ }
+ // CraftBukkit end
}
entry = (Entry) iterator.next();