@@ -8,17 +8,17 @@
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
|
||||
private static final Gson a = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
- public Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of();
|
||||
+ public Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> recipes = ImmutableMap.of(); // CraftBukkit
|
||||
private boolean d;
|
||||
private boolean hasErrors;
|
||||
|
||||
public CraftingManager() {
|
||||
@@ -47,7 +49,12 @@
|
||||
|
||||
protected void a(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
this.d = false;
|
||||
this.hasErrors = false;
|
||||
- Map<Recipes<?>, Builder<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
|
||||
+ // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable
|
||||
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
|
||||
@@ -29,7 +29,7 @@
|
||||
Iterator iterator = map.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -57,24 +64,42 @@
|
||||
@@ -57,28 +64,46 @@
|
||||
try {
|
||||
IRecipe<?> irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element"));
|
||||
|
||||
@@ -65,6 +65,10 @@
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean a() {
|
||||
return this.hasErrors;
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<T> craft(Recipes<T> recipes, C c0, World world) {
|
||||
- return this.b(recipes).values().stream().flatMap((irecipe) -> {
|
||||
+ // CraftBukkit start
|
||||
@@ -77,7 +81,7 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
|
||||
@@ -92,7 +117,7 @@
|
||||
@@ -96,7 +121,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> b(Recipes<T> recipes) {
|
||||
@@ -86,7 +90,7 @@
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> c(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -113,7 +138,7 @@
|
||||
@@ -117,7 +142,7 @@
|
||||
|
||||
public Optional<? extends IRecipe<?>> getRecipe(MinecraftKey minecraftkey) {
|
||||
return this.recipes.values().stream().map((map) -> {
|
||||
@@ -95,9 +99,23 @@
|
||||
}).filter(Objects::nonNull).findFirst();
|
||||
}
|
||||
|
||||
@@ -136,4 +161,14 @@
|
||||
return new JsonSyntaxException("Invalid or unsupported recipe type '" + s + "'");
|
||||
})).a(minecraftkey, jsonobject);
|
||||
@@ -143,11 +168,11 @@
|
||||
|
||||
public void a(Iterable<IRecipe<?>> iterable) {
|
||||
this.hasErrors = false;
|
||||
- Map<Recipes<?>, Map<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap();
|
||||
+ Map<Recipes<?>, Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>>> map = Maps.newHashMap(); // CraftBukkit
|
||||
|
||||
iterable.forEach((irecipe) -> {
|
||||
Map<MinecraftKey, IRecipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.g(), (recipes) -> {
|
||||
- return Maps.newHashMap();
|
||||
+ return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
|
||||
});
|
||||
IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getKey(), irecipe);
|
||||
|
||||
@@ -157,4 +182,14 @@
|
||||
});
|
||||
this.recipes = ImmutableMap.copyOf(map);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/FurnaceRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/FurnaceRecipe.java
|
||||
@@ -3,6 +3,14 @@
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe;
|
||||
@@ -15,16 +15,16 @@
|
||||
public class FurnaceRecipe extends RecipeCooking {
|
||||
|
||||
public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -13,4 +21,14 @@
|
||||
@@ -19,4 +27,14 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.p;
|
||||
return RecipeSerializer.SMELTING_RECIPE;
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -42,4 +42,6 @@
|
||||
RecipeSerializer<?> getRecipeSerializer();
|
||||
|
||||
Recipes<?> g();
|
||||
@@ -61,4 +61,6 @@
|
||||
return recipeitemstack.a().length == 0;
|
||||
});
|
||||
}
|
||||
+
|
||||
+ org.bukkit.inventory.Recipe toBukkitRecipe(); // CraftBukkit
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
@@ -25,4 +25,11 @@
|
||||
public ItemStack getResult() {
|
||||
return ItemStack.b;
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeBlasting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeBlasting.java
|
||||
@@ -3,6 +3,14 @@
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftBlastingRecipe;
|
||||
@@ -15,9 +15,9 @@
|
||||
public class RecipeBlasting extends RecipeCooking {
|
||||
|
||||
public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -13,4 +21,16 @@
|
||||
@@ -19,4 +27,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.q;
|
||||
return RecipeSerializer.BLASTING_RECIPE;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
@@ -25,7 +25,7 @@
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeCampfire.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeCampfire.java
|
||||
@@ -3,6 +3,14 @@
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftCampfireRecipe;
|
||||
@@ -15,9 +15,9 @@
|
||||
public class RecipeCampfire extends RecipeCooking {
|
||||
|
||||
public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -13,4 +21,16 @@
|
||||
@@ -19,4 +27,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.s;
|
||||
return RecipeSerializer.CAMPFIRE_COOKING_RECIPE;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
@@ -25,7 +25,7 @@
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -35,6 +35,7 @@
|
||||
private final RecipeItemStack.Provider[] b;
|
||||
public ItemStack[] choices;
|
||||
private IntList d;
|
||||
private final RecipeItemStack.Provider[] values;
|
||||
public ItemStack[] itemStacks;
|
||||
private IntList stackingIds;
|
||||
+ public boolean exact; // CraftBukkit
|
||||
|
||||
public RecipeItemStack(Stream<? extends RecipeItemStack.Provider> stream) {
|
||||
this.b = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
|
||||
@@ -67,6 +68,15 @@
|
||||
this.values = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
|
||||
@@ -72,6 +73,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
@@ -21,6 +21,15 @@
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack1.getItem() == itemstack.getItem()) {
|
||||
if (itemstack1.a(itemstack.getItem())) {
|
||||
return true;
|
||||
}
|
||||
@@ -103,7 +113,7 @@
|
||||
|
||||
public void a(PacketDataSerializer packetdataserializer) {
|
||||
this.buildChoices();
|
||||
- packetdataserializer.a((Collection) Arrays.asList(this.itemStacks), PacketDataSerializer::a);
|
||||
+ packetdataserializer.a(Arrays.asList(this.itemStacks), PacketDataSerializer::a); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public JsonElement c() {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeSmithing.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeSmithing.java
|
||||
@@ -10,6 +10,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -12,6 +12,14 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@@ -14,17 +14,17 @@
|
||||
+
|
||||
public class RecipeSmithing implements IRecipe<IInventory> {
|
||||
|
||||
private final RecipeItemStack a;
|
||||
@@ -65,6 +73,17 @@
|
||||
return Recipes.SMITHING;
|
||||
final RecipeItemStack base;
|
||||
@@ -84,6 +92,17 @@
|
||||
});
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.c);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.d), result, CraftRecipe.toBukkit(this.a), CraftRecipe.toBukkit(this.b));
|
||||
+ CraftSmithingRecipe recipe = new CraftSmithingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeSmoking.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeSmoking.java
|
||||
@@ -3,6 +3,14 @@
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@@ -15,9 +15,9 @@
|
||||
public class RecipeSmoking extends RecipeCooking {
|
||||
|
||||
public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -13,4 +21,16 @@
|
||||
@@ -19,4 +27,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
return RecipeSerializer.r;
|
||||
return RecipeSerializer.SMOKING_RECIPE;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
@@ -25,7 +25,7 @@
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
@@ -5,6 +5,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -6,6 +6,14 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@@ -15,9 +15,9 @@
|
||||
public class RecipeStonecutting extends RecipeSingleItem {
|
||||
|
||||
public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
|
||||
@@ -15,4 +23,16 @@
|
||||
public boolean a(IInventory iinventory, World world) {
|
||||
return this.ingredient.test(iinventory.getItem(0));
|
||||
@@ -21,4 +29,16 @@
|
||||
public ItemStack h() {
|
||||
return new ItemStack(Blocks.STONECUTTER);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
@@ -25,7 +25,7 @@
|
||||
+ public Recipe toBukkitRecipe() {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.key), result, CraftRecipe.toBukkit(this.ingredient));
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(CraftNamespacedKey.fromMinecraft(this.id), result, CraftRecipe.toBukkit(this.ingredient));
|
||||
+ recipe.setGroup(this.group);
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipes.java
|
||||
@@ -22,6 +22,13 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -23,6 +23,13 @@
|
||||
import net.minecraft.world.item.Items;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -13,8 +13,8 @@
|
||||
+
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
private final int width;
|
||||
@@ -40,6 +47,66 @@
|
||||
final int width;
|
||||
@@ -41,6 +48,66 @@
|
||||
this.result = itemstack;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (RecipeItemStack list : this.items) {
|
||||
+ for (RecipeItemStack list : this.recipeItems) {
|
||||
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
||||
+ if (choice != null) {
|
||||
+ recipe.setIngredient(c, choice);
|
||||
@@ -80,4 +80,4 @@
|
||||
+
|
||||
@Override
|
||||
public MinecraftKey getKey() {
|
||||
return this.key;
|
||||
return this.id;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
+
|
||||
public class ShapelessRecipes implements RecipeCrafting {
|
||||
|
||||
private final MinecraftKey key;
|
||||
private final MinecraftKey id;
|
||||
@@ -28,6 +34,20 @@
|
||||
this.ingredients = nonnulllist;
|
||||
}
|
||||
@@ -33,4 +33,4 @@
|
||||
+
|
||||
@Override
|
||||
public MinecraftKey getKey() {
|
||||
return this.key;
|
||||
return this.id;
|
||||
|
||||
Reference in New Issue
Block a user