More cleanup of var names

This commit is contained in:
Nassim Jahnke
2024-12-21 15:53:00 +01:00
parent fd4c10947f
commit 70ef43b8dd
8 changed files with 30 additions and 49 deletions

View File

@@ -5,9 +5,9 @@
}
+ // CraftBukkit start
+ public void addRecipe(RecipeHolder<?> irecipe) {
+ public void addRecipe(RecipeHolder<?> holder) {
+ org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot
+ this.recipes.addRecipe(irecipe);
+ this.recipes.addRecipe(holder);
+ this.finalizeRecipeLoading();
+ }
+

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/world/item/crafting/RecipeMap.java
+++ b/net/minecraft/world/item/crafting/RecipeMap.java
@@ -30,8 +_,53 @@
@@ -30,8 +_,34 @@
builder1.put(recipeHolder.id(), recipeHolder);
}
@@ -10,34 +10,18 @@
+ return new RecipeMap(com.google.common.collect.LinkedHashMultimap.create(builder.build()), com.google.common.collect.Maps.newHashMap(builder1.build()));
+ }
+
+ public void addRecipe(RecipeHolder<?> irecipe) {
+ Collection<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType());
+ public void addRecipe(RecipeHolder<?> holder) {
+ Collection<RecipeHolder<?>> recipes = this.byType.get(holder.value().getType());
+
+ if (this.byKey.containsKey(irecipe.id())) {
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
+ if (this.byKey.containsKey(holder.id())) {
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + holder.id());
+ } else {
+ map.add(irecipe);
+ this.byKey.put(irecipe.id(), irecipe);
+ recipes.add(holder);
+ this.byKey.put(holder.id(), holder);
+ }
+ }
+
+ // public boolean removeRecipe(ResourceKey<Recipe<?>> mcKey) {
+ // boolean removed = false;
+ // Iterator<RecipeHolder<?>> iter = this.byType.values().iterator();
+ // while (iter.hasNext()) {
+ // RecipeHolder<?> recipe = iter.next();
+ // if (recipe.id().equals(mcKey)) {
+ // iter.remove();
+ // removed = true;
+ // }
+ // }
+ // removed |= this.byKey.remove(mcKey) != null;
+ //
+ // return removed;
+ // }
+ // CraftBukkit end
+
+
+ // Paper start - replace removeRecipe implementation
+ public <T extends RecipeInput> boolean removeRecipe(ResourceKey<Recipe<T>> mcKey) {
+ //noinspection unchecked
@@ -46,10 +30,7 @@
+ return false;
+ }
+ final Collection<? extends RecipeHolder<? extends Recipe<T>>> recipes = this.byType(remove.value().getType());
+ if (recipes.remove(remove)) {
+ return true;
+ }
+ return false;
+ return recipes.remove(remove);
+ // Paper end - why are you using a loop???
+ }
+ // Paper end - replace removeRecipe implementation