3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-24 15:20:11 +01:00
Paper/nms-patches/RecipesFurnace.patch

79 Zeilen
2.7 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/RecipesFurnace.java
+++ b/net/minecraft/server/RecipesFurnace.java
2016-02-29 22:32:46 +01:00
@@ -9,7 +9,9 @@
private static final RecipesFurnace a = new RecipesFurnace();
public Map<ItemStack, ItemStack> recipes = Maps.newHashMap();
2016-02-29 22:32:46 +01:00
- private Map<ItemStack, Float> c = Maps.newHashMap();
+ private Map<ItemStack, Float> c = Maps.newHashMap(); // PAIL: rename
+ public Map customRecipes = Maps.newHashMap(); // CraftBukkit - add field
2016-02-29 22:32:46 +01:00
+ public Map customExperience = Maps.newHashMap(); // CraftBukkit - add field
public static RecipesFurnace getInstance() {
return RecipesFurnace.a;
2016-02-29 22:32:46 +01:00
@@ -54,6 +56,12 @@
this.registerRecipe(Blocks.QUARTZ_ORE, new ItemStack(Items.QUARTZ), 0.2F);
}
2015-02-26 23:41:06 +01:00
+ // CraftBukkit start - add method
2016-02-29 22:32:46 +01:00
+ public void registerRecipe(ItemStack itemstack, ItemStack itemstack1, float f) {
+ this.customRecipes.put(itemstack, itemstack1);
+ }
+ // CraftBukkit end
2015-02-26 23:41:06 +01:00
+
public void registerRecipe(Block block, ItemStack itemstack, float f) {
this.a(Item.getItemOf(block), itemstack, f);
2015-02-26 23:41:06 +01:00
}
2016-02-29 22:32:46 +01:00
@@ -68,13 +76,23 @@
}
public ItemStack getResult(ItemStack itemstack) {
- Iterator iterator = this.recipes.entrySet().iterator();
+ // CraftBukkit start - initialize to customRecipes
+ boolean vanilla = false;
+ Iterator iterator = this.customRecipes.entrySet().iterator();
+ // CraftBukkit end
Entry entry;
do {
if (!iterator.hasNext()) {
- return null;
+ // CraftBukkit start - fall back to vanilla recipes
2016-02-29 22:32:46 +01:00
+ if (!vanilla && !this.recipes.isEmpty()) {
+ iterator = this.recipes.entrySet().iterator();
+ vanilla = true;
+ } else {
+ return null;
+ }
+ // CraftBukkit end
}
2016-02-29 22:32:46 +01:00
entry = (Entry) iterator.next();
@@ -92,13 +110,23 @@
}
public float b(ItemStack itemstack) {
- Iterator iterator = this.c.entrySet().iterator();
+ // CraftBukkit start - initialize to customRecipes
+ boolean vanilla = false;
+ Iterator iterator = this.customRecipes.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();