@@ -1,10 +1,13 @@
|
||||
--- a/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
@@ -37,11 +37,13 @@
|
||||
@@ -34,11 +34,16 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap; // CraftBukkit
|
||||
+// CraftBukkit start
|
||||
+import it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap;
|
||||
+import net.minecraft.core.registries.BuiltInRegistries;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
|
||||
@@ -15,7 +18,7 @@
|
||||
private Map<MinecraftKey, RecipeHolder<?>> byName = ImmutableMap.of();
|
||||
private boolean hasErrors;
|
||||
|
||||
@@ -51,7 +53,12 @@
|
||||
@@ -48,7 +53,12 @@
|
||||
|
||||
protected void apply(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
this.hasErrors = false;
|
||||
@@ -29,7 +32,7 @@
|
||||
Builder<MinecraftKey, RecipeHolder<?>> builder = ImmutableMap.builder();
|
||||
Iterator iterator = map.entrySet().iterator();
|
||||
|
||||
@@ -62,8 +69,10 @@
|
||||
@@ -59,8 +69,10 @@
|
||||
try {
|
||||
RecipeHolder<?> recipeholder = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element"));
|
||||
|
||||
@@ -42,7 +45,7 @@
|
||||
})).put(minecraftkey, recipeholder);
|
||||
builder.put(minecraftkey, recipeholder);
|
||||
} catch (IllegalArgumentException | JsonParseException jsonparseexception) {
|
||||
@@ -72,20 +81,37 @@
|
||||
@@ -69,20 +81,37 @@
|
||||
}
|
||||
|
||||
this.recipes = (Map) map1.entrySet().stream().collect(ImmutableMap.toImmutableMap(Entry::getKey, (entry1) -> {
|
||||
@@ -83,7 +86,7 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<Pair<MinecraftKey, RecipeHolder<T>>> getRecipeFor(Recipes<T> recipes, C c0, World world, @Nullable MinecraftKey minecraftkey) {
|
||||
@@ -119,7 +145,7 @@
|
||||
@@ -116,7 +145,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
@@ -92,7 +95,7 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -166,12 +192,12 @@
|
||||
@@ -159,12 +188,12 @@
|
||||
|
||||
public void replaceRecipes(Iterable<RecipeHolder<?>> iterable) {
|
||||
this.hasErrors = false;
|
||||
@@ -107,14 +110,14 @@
|
||||
});
|
||||
MinecraftKey minecraftkey = recipeholder.id();
|
||||
RecipeHolder<?> recipeholder1 = (RecipeHolder) map1.put(minecraftkey, recipeholder);
|
||||
@@ -182,9 +208,29 @@
|
||||
@@ -175,9 +204,29 @@
|
||||
}
|
||||
});
|
||||
this.recipes = ImmutableMap.copyOf(map);
|
||||
- this.byName = builder.build();
|
||||
+ this.byName = Maps.newHashMap(builder.build()); // CraftBukkit
|
||||
+ }
|
||||
+
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(MinecraftKey mcKey) {
|
||||
+ for (Object2ObjectLinkedOpenHashMap<MinecraftKey, RecipeHolder<?>> recipes : recipes.values()) {
|
||||
@@ -122,8 +125,8 @@
|
||||
+ }
|
||||
+
|
||||
+ return byName.remove(mcKey) != null;
|
||||
}
|
||||
|
||||
+ }
|
||||
+
|
||||
+ public void clearRecipes() {
|
||||
+ this.recipes = Maps.newHashMap();
|
||||
+
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -63,4 +63,6 @@
|
||||
@@ -67,4 +67,6 @@
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -38,6 +38,7 @@
|
||||
@@ -35,6 +35,7 @@
|
||||
public ItemStack[] itemStacks;
|
||||
@Nullable
|
||||
private IntList stackingIds;
|
||||
@@ -8,7 +8,7 @@
|
||||
public static final Codec<RecipeItemStack> CODEC = codec(true);
|
||||
public static final Codec<RecipeItemStack> CODEC_NONEMPTY = codec(false);
|
||||
|
||||
@@ -75,6 +76,15 @@
|
||||
@@ -72,6 +73,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
@@ -18,6 +18,14 @@
|
||||
@@ -10,6 +10,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -14,9 +14,9 @@
|
||||
+
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
final int width;
|
||||
@@ -42,6 +50,68 @@
|
||||
this(s, craftingbookcategory, i, j, nonnulllist, itemstack, true);
|
||||
final ShapedRecipePattern pattern;
|
||||
@@ -30,6 +38,68 @@
|
||||
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -27,9 +27,9 @@
|
||||
+ recipe.setGroup(this.group);
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ switch (this.height) {
|
||||
+ switch (this.pattern.height()) {
|
||||
+ case 1:
|
||||
+ switch (this.width) {
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a");
|
||||
+ break;
|
||||
@@ -42,7 +42,7 @@
|
||||
+ }
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ switch (this.width) {
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b");
|
||||
+ break;
|
||||
@@ -55,7 +55,7 @@
|
||||
+ }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ switch (this.width) {
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b","c");
|
||||
+ break;
|
||||
@@ -69,7 +69,7 @@
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (RecipeItemStack list : this.recipeItems) {
|
||||
+ for (RecipeItemStack list : this.pattern.ingredients()) {
|
||||
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
||||
+ if (choice != null) {
|
||||
+ recipe.setIngredient(c, choice);
|
||||
|
||||
Reference in New Issue
Block a user