Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-19 13:00:06 +01:00
[Bleeding] Handle custom furnace recipes separately. Fixes BUKKIT-1657, BUKKIT-3846
Due to vanilla blanket comparing data values, and the unspecified order of hashmap iterators, we need to run through custom recipes first, and therefore separately, to ensure that they are actually used. By not adding the custom results to the experience table, we do not override the experience gains from vanilla smelting recipes.
Dieser Commit ist enthalten in:
Ursprung
3c209a9884
Commit
1ecc59d4d9
@ -10,6 +10,7 @@ public class RecipesFurnace {
|
|||||||
private static final RecipesFurnace a = new RecipesFurnace();
|
private static final RecipesFurnace a = new RecipesFurnace();
|
||||||
public Map recipes = new HashMap(); // CraftBukkit - private -> public
|
public Map recipes = new HashMap(); // CraftBukkit - private -> public
|
||||||
private Map c = new HashMap();
|
private Map c = new HashMap();
|
||||||
|
public Map customRecipes = new HashMap(); // CraftBukkit
|
||||||
|
|
||||||
public static RecipesFurnace getInstance() {
|
public static RecipesFurnace getInstance() {
|
||||||
return a;
|
return a;
|
||||||
@ -62,15 +63,31 @@ public class RecipesFurnace {
|
|||||||
this.c.put(itemstack1, Float.valueOf(f));
|
this.c.put(itemstack1, Float.valueOf(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
public void registerRecipe(ItemStack itemstack, ItemStack itemstack1) {
|
||||||
|
this.customRecipes.put(itemstack, itemstack1);
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public ItemStack getResult(ItemStack itemstack) {
|
public ItemStack getResult(ItemStack itemstack) {
|
||||||
Iterator iterator = this.recipes.entrySet().iterator();
|
// CraftBukkit start
|
||||||
|
boolean vanilla = false;
|
||||||
|
Iterator iterator = this.customRecipes.entrySet().iterator();
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
Entry entry;
|
Entry entry;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (!iterator.hasNext()) {
|
if (!iterator.hasNext()) {
|
||||||
|
// CraftBukkit start
|
||||||
|
if (!vanilla) {
|
||||||
|
iterator = this.recipes.entrySet().iterator();
|
||||||
|
vanilla = true;
|
||||||
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
}
|
||||||
|
|
||||||
entry = (Entry) iterator.next();
|
entry = (Entry) iterator.next();
|
||||||
} while (!this.a(itemstack, (ItemStack) entry.getKey()));
|
} while (!this.a(itemstack, (ItemStack) entry.getKey()));
|
||||||
|
@ -961,11 +961,13 @@ public final class CraftServer implements Server {
|
|||||||
public void clearRecipes() {
|
public void clearRecipes() {
|
||||||
CraftingManager.getInstance().recipes.clear();
|
CraftingManager.getInstance().recipes.clear();
|
||||||
RecipesFurnace.getInstance().recipes.clear();
|
RecipesFurnace.getInstance().recipes.clear();
|
||||||
|
RecipesFurnace.getInstance().customRecipes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetRecipes() {
|
public void resetRecipes() {
|
||||||
CraftingManager.getInstance().recipes = new CraftingManager().recipes;
|
CraftingManager.getInstance().recipes = new CraftingManager().recipes;
|
||||||
RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes;
|
RecipesFurnace.getInstance().recipes = new RecipesFurnace().recipes;
|
||||||
|
RecipesFurnace.getInstance().customRecipes.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String[]> getCommandAliases() {
|
public Map<String, String[]> getCommandAliases() {
|
||||||
|
@ -22,6 +22,6 @@ public class CraftFurnaceRecipe extends FurnaceRecipe implements CraftRecipe {
|
|||||||
public void addToCraftingManager() {
|
public void addToCraftingManager() {
|
||||||
ItemStack result = this.getResult();
|
ItemStack result = this.getResult();
|
||||||
ItemStack input = this.getInput();
|
ItemStack input = this.getInput();
|
||||||
RecipesFurnace.getInstance().a(CraftMagicNumbers.getItem(input.getTypeId()), CraftItemStack.asNMSCopy(result), 0.1f);
|
RecipesFurnace.getInstance().registerRecipe(CraftItemStack.asNMSCopy(input), CraftItemStack.asNMSCopy(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren