--- a/net/minecraft/server/CraftingManager.java +++ b/net/minecraft/server/CraftingManager.java @@ -26,7 +26,7 @@ private static final Logger LOGGER = LogManager.getLogger(); public static final int a = "recipes/".length(); public static final int b = ".json".length(); - public Map, Map>> recipes = (Map) SystemUtils.a((Object) Maps.newHashMap(), CraftingManager::initializeRecipeMap); + public Map, it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>> recipes = SystemUtils.a(Maps.newHashMap(), CraftingManager::initializeRecipeMap); // CraftBukkit private boolean e; public CraftingManager() {} @@ -88,19 +88,23 @@ } public void addRecipe(IRecipe irecipe) { - Map> map = (Map) this.recipes.get(irecipe.g()); + it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap> map = this.recipes.get(irecipe.g()); // CraftBukkit if (map.containsKey(irecipe.getKey())) { throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getKey()); } else { - map.put(irecipe.getKey(), irecipe); + map.putAndMoveToFirst(irecipe.getKey(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority } } public > Optional craft(Recipes recipes, C c0, World world) { - return this.a(recipes).values().stream().flatMap((irecipe) -> { + // CraftBukkit start + Optional recipe = this.a(recipes).values().stream().flatMap((irecipe) -> { return SystemUtils.a(recipes.a(irecipe, world, c0)); }).findFirst(); + c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found + // CraftBukkit end + return recipe; } public > List b(Recipes recipes, C c0, World world) { @@ -112,7 +116,7 @@ } private > Map> a(Recipes recipes) { - return (Map) this.recipes.getOrDefault(recipes, Maps.newHashMap()); + return (Map) this.recipes.getOrDefault(recipes, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit } public > NonNullList c(Recipes recipes, C c0, World world) { @@ -133,7 +137,7 @@ public Optional> a(MinecraftKey minecraftkey) { return this.recipes.values().stream().map((map) -> { - return (IRecipe) map.get(minecraftkey); + return map.get(minecraftkey); // CraftBukkit - decompile error }).filter(Objects::nonNull).findFirst(); } @@ -157,14 +161,14 @@ })).a(minecraftkey, jsonobject); } - public static void initializeRecipeMap(Map, Map>> map) { + public static void initializeRecipeMap(Map, it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap>> map) { // CraftBukkit map.clear(); Iterator iterator = IRegistry.RECIPE_TYPE.iterator(); while (iterator.hasNext()) { Recipes recipes = (Recipes) iterator.next(); - map.put(recipes, Maps.newHashMap()); + map.put(recipes, new it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit } }