@@ -17,7 +17,7 @@
|
||||
public CraftingManager() {
|
||||
@@ -47,7 +49,12 @@
|
||||
|
||||
protected void a(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
protected void apply(Map<MinecraftKey, JsonElement> map, IResourceManager iresourcemanager, GameProfilerFiller gameprofilerfiller) {
|
||||
this.hasErrors = false;
|
||||
- Map<Recipes<?>, Builder<MinecraftKey, IRecipe<?>>> map1 = Maps.newHashMap();
|
||||
+ // CraftBukkit start - SPIGOT-5667 make sure all types are populated and mutable
|
||||
@@ -31,12 +31,12 @@
|
||||
while (iterator.hasNext()) {
|
||||
@@ -57,8 +64,10 @@
|
||||
try {
|
||||
IRecipe<?> irecipe = a(minecraftkey, ChatDeserializer.m((JsonElement) entry.getValue(), "top element"));
|
||||
IRecipe<?> irecipe = fromJson(minecraftkey, ChatDeserializer.convertToJsonObject((JsonElement) entry.getValue(), "top element"));
|
||||
|
||||
- ((Builder) map1.computeIfAbsent(irecipe.g(), (recipes) -> {
|
||||
- ((Builder) map1.computeIfAbsent(irecipe.getType(), (recipes) -> {
|
||||
- return ImmutableMap.builder();
|
||||
+ // CraftBukkit start
|
||||
+ (map1.computeIfAbsent(irecipe.g(), (recipes) -> {
|
||||
+ (map1.computeIfAbsent(irecipe.getType(), (recipes) -> {
|
||||
+ return new Object2ObjectLinkedOpenHashMap<>();
|
||||
+ // CraftBukkit end
|
||||
})).put(minecraftkey, irecipe);
|
||||
@@ -54,44 +54,44 @@
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addRecipe(IRecipe<?> irecipe) {
|
||||
+ Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.g()); // CraftBukkit
|
||||
+ Object2ObjectLinkedOpenHashMap<MinecraftKey, IRecipe<?>> map = this.recipes.get(irecipe.getType()); // CraftBukkit
|
||||
+
|
||||
+ if (map.containsKey(irecipe.getKey())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getKey());
|
||||
+ if (map.containsKey(irecipe.getId())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.getId());
|
||||
+ } else {
|
||||
+ map.putAndMoveToFirst(irecipe.getKey(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ map.putAndMoveToFirst(irecipe.getId(), irecipe); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean a() {
|
||||
public boolean hadErrorsLoading() {
|
||||
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) -> {
|
||||
public <C extends IInventory, T extends IRecipe<C>> Optional<T> getRecipeFor(Recipes<T> recipes, C c0, World world) {
|
||||
- return this.byType(recipes).values().stream().flatMap((irecipe) -> {
|
||||
+ // CraftBukkit start
|
||||
+ Optional<T> recipe = this.b(recipes).values().stream().flatMap((irecipe) -> {
|
||||
return SystemUtils.a(recipes.a(irecipe, world, c0));
|
||||
+ Optional<T> recipe = this.byType(recipes).values().stream().flatMap((irecipe) -> {
|
||||
return SystemUtils.toStream(recipes.tryMatch(irecipe, world, c0));
|
||||
}).findFirst();
|
||||
+ c0.setCurrentRecipe(recipe.orElse(null)); // CraftBukkit - Clear recipe when no recipe is found
|
||||
+ // CraftBukkit end
|
||||
+ return recipe;
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<T> a(Recipes<T> recipes) {
|
||||
public <C extends IInventory, T extends IRecipe<C>> List<T> getAllRecipesFor(Recipes<T> recipes) {
|
||||
@@ -96,7 +121,7 @@
|
||||
}
|
||||
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> b(Recipes<T> recipes) {
|
||||
private <C extends IInventory, T extends IRecipe<C>> Map<MinecraftKey, IRecipe<C>> byType(Recipes<T> recipes) {
|
||||
- return (Map) this.recipes.getOrDefault(recipes, Collections.emptyMap());
|
||||
+ return (Map) this.recipes.getOrDefault(recipes, new Object2ObjectLinkedOpenHashMap<>()); // CraftBukkit
|
||||
}
|
||||
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> c(Recipes<T> recipes, C c0, World world) {
|
||||
public <C extends IInventory, T extends IRecipe<C>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, C c0, World world) {
|
||||
@@ -117,7 +142,7 @@
|
||||
|
||||
public Optional<? extends IRecipe<?>> getRecipe(MinecraftKey minecraftkey) {
|
||||
public Optional<? extends IRecipe<?>> byKey(MinecraftKey minecraftkey) {
|
||||
return this.recipes.values().stream().map((map) -> {
|
||||
- return (IRecipe) map.get(minecraftkey);
|
||||
+ return map.get(minecraftkey); // CraftBukkit - decompile error
|
||||
@@ -100,17 +100,17 @@
|
||||
|
||||
@@ -143,11 +168,11 @@
|
||||
|
||||
public void a(Iterable<IRecipe<?>> iterable) {
|
||||
public void replaceRecipes(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) -> {
|
||||
Map<MinecraftKey, IRecipe<?>> map1 = (Map) map.computeIfAbsent(irecipe.getType(), (recipes) -> {
|
||||
- return Maps.newHashMap();
|
||||
+ return new Object2ObjectLinkedOpenHashMap<>(); // CraftBukkit
|
||||
});
|
||||
IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getKey(), irecipe);
|
||||
IRecipe<?> irecipe1 = (IRecipe) map1.put(irecipe.getId(), irecipe);
|
||||
|
||||
@@ -157,4 +182,14 @@
|
||||
});
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
public FurnaceRecipe(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -19,4 +27,14 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.SMELTING_RECIPE;
|
||||
}
|
||||
+
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -61,4 +61,6 @@
|
||||
return recipeitemstack.a().length == 0;
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
}
|
||||
+
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
@@ -25,4 +25,11 @@
|
||||
public ItemStack getResult() {
|
||||
public ItemStack getResultItem() {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
+
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
public RecipeBlasting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -19,4 +27,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.BLASTING_RECIPE;
|
||||
}
|
||||
+
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
public RecipeCampfire(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -19,4 +27,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.CAMPFIRE_COOKING_RECIPE;
|
||||
}
|
||||
+
|
||||
|
||||
@@ -1,35 +1,26 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -35,6 +35,7 @@
|
||||
private final RecipeItemStack.Provider[] values;
|
||||
@@ -37,6 +37,7 @@
|
||||
public ItemStack[] itemStacks;
|
||||
@Nullable
|
||||
private IntList stackingIds;
|
||||
+ public boolean exact; // CraftBukkit
|
||||
|
||||
public RecipeItemStack(Stream<? extends RecipeItemStack.Provider> stream) {
|
||||
this.values = (RecipeItemStack.Provider[]) stream.toArray((i) -> {
|
||||
@@ -72,6 +73,15 @@
|
||||
@@ -74,6 +75,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (exact) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.equals(itemstack, itemstack1)) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.tagMatches(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack1.a(itemstack.getItem())) {
|
||||
if (itemstack1.is(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,6 +1,6 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeSmithing.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeSmithing.java
|
||||
@@ -12,6 +12,14 @@
|
||||
@@ -11,6 +11,14 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
public class RecipeSmithing implements IRecipe<IInventory> {
|
||||
|
||||
final RecipeItemStack base;
|
||||
@@ -84,6 +92,17 @@
|
||||
@@ -83,6 +91,17 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
public RecipeSmoking(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -19,4 +27,16 @@
|
||||
public RecipeSerializer<?> getRecipeSerializer() {
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.SMOKING_RECIPE;
|
||||
}
|
||||
+
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
public RecipeStonecutting(MinecraftKey minecraftkey, String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
|
||||
@@ -21,4 +29,16 @@
|
||||
public ItemStack h() {
|
||||
public ItemStack getToastSymbol() {
|
||||
return new ItemStack(Blocks.STONECUTTER);
|
||||
}
|
||||
+
|
||||
|
||||
@@ -79,5 +79,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public MinecraftKey getKey() {
|
||||
public MinecraftKey getId() {
|
||||
return this.id;
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public MinecraftKey getKey() {
|
||||
public MinecraftKey getId() {
|
||||
return this.id;
|
||||
|
||||
Reference in New Issue
Block a user