@@ -1,108 +1,87 @@
|
||||
--- a/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/CraftingManager.java
|
||||
@@ -34,6 +34,11 @@
|
||||
@@ -38,6 +38,10 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.collect.LinkedHashMultimap;
|
||||
+import com.google.common.collect.Maps;
|
||||
+import java.util.Collections;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class CraftingManager extends ResourceDataJson {
|
||||
public class CraftingManager extends ResourceDataAbstract<RecipeMap> implements RecipeAccess {
|
||||
|
||||
private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().disableHtmlEscaping().create();
|
||||
@@ -70,11 +75,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
- this.byType = builder.build();
|
||||
- this.byName = com_google_common_collect_immutablemap_builder.build();
|
||||
+ // CraftBukkit start - mutable
|
||||
+ this.byType = LinkedHashMultimap.create(builder.build());
|
||||
+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit end
|
||||
CraftingManager.LOGGER.info("Loaded {} recipes", this.byType.size());
|
||||
private static final Logger LOGGER = LogUtils.getLogger();
|
||||
@@ -109,7 +113,23 @@
|
||||
CraftingManager.LOGGER.info("Loaded {} recipes", recipemap.values().size());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addRecipe(RecipeHolder<?> irecipe) {
|
||||
+ Collection<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType()); // CraftBukkit
|
||||
+ this.recipes.addRecipe(irecipe);
|
||||
+ finalizeRecipeLoading();
|
||||
+ }
|
||||
+
|
||||
+ if (byName.containsKey(irecipe.id())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
|
||||
+ } else {
|
||||
+ map.add(irecipe);
|
||||
+ byName.put(irecipe.id(), irecipe);
|
||||
+ private FeatureFlagSet featureflagset;
|
||||
+
|
||||
+ public void finalizeRecipeLoading() {
|
||||
+ if (featureflagset != null) {
|
||||
+ finalizeRecipeLoading(featureflagset);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public boolean hadErrorsLoading() {
|
||||
return this.hasErrors;
|
||||
}
|
||||
@@ -90,9 +110,13 @@
|
||||
public void finalizeRecipeLoading(FeatureFlagSet featureflagset) {
|
||||
+ this.featureflagset = featureflagset;
|
||||
+ // CraftBukkit end
|
||||
List<SelectableRecipe.a<RecipeStonecutting>> list = new ArrayList();
|
||||
List<CraftingManager.b> list1 = CraftingManager.RECIPE_PROPERTY_SETS.entrySet().stream().map((entry) -> {
|
||||
return new CraftingManager.b((ResourceKey) entry.getKey(), (CraftingManager.c) entry.getValue());
|
||||
@@ -128,7 +148,7 @@
|
||||
RecipeStonecutting recipestonecutting = (RecipeStonecutting) irecipe;
|
||||
|
||||
if (isIngredientEnabled(featureflagset, recipestonecutting.input()) && recipestonecutting.resultDisplay().isEnabled(featureflagset)) {
|
||||
- list.add(new SelectableRecipe.a<>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of(recipeholder))));
|
||||
+ list.add(new SelectableRecipe.a<RecipeStonecutting>(recipestonecutting.input(), new SelectableRecipe<>(recipestonecutting.resultDisplay(), Optional.of((RecipeHolder<RecipeStonecutting>) recipeholder)))); // CraftBukkit - decompile error
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +190,10 @@
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, I i0, World world, @Nullable RecipeHolder<T> recipeholder) {
|
||||
- return i0.isEmpty() ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Optional<RecipeHolder<T>> getRecipeFor(Recipes<T> recipes, I i0, World world) {
|
||||
- return this.recipes.getRecipesFor(recipes, i0, world).findFirst();
|
||||
+ // CraftBukkit start
|
||||
+ List<RecipeHolder<T>> list = this.byType(recipes).stream().filter((recipeholder1) -> {
|
||||
return recipeholder1.value().matches(i0, world);
|
||||
- }).findFirst());
|
||||
+ }).toList();
|
||||
+ Optional<RecipeHolder<T>> recipe = (list.isEmpty() || i0.isEmpty()) ? Optional.empty() : (recipeholder != null && recipeholder.value().matches(i0, world) ? Optional.of(recipeholder) : Optional.of(list.getLast())); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ return recipe;
|
||||
+ List<RecipeHolder<T>> list = this.recipes.getRecipesFor(recipes, i0, world).toList();
|
||||
+ return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> List<RecipeHolder<T>> getAllRecipesFor(Recipes<T> recipes) {
|
||||
@@ -108,7 +132,7 @@
|
||||
}
|
||||
|
||||
private <I extends RecipeInput, T extends IRecipe<I>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return this.byType.get(recipes);
|
||||
+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> NonNullList<ItemStack> getRemainingItemsFor(Recipes<T> recipes, I i0, World world) {
|
||||
@@ -135,7 +159,7 @@
|
||||
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, MinecraftKey minecraftkey) {
|
||||
RecipeHolder<?> recipeholder = (RecipeHolder) this.byName.get(minecraftkey);
|
||||
public Optional<RecipeHolder<?>> byKey(ResourceKey<IRecipe<?>> resourcekey) {
|
||||
@@ -181,7 +204,7 @@
|
||||
private <T extends IRecipe<?>> RecipeHolder<T> byKeyTyped(Recipes<T> recipes, ResourceKey<IRecipe<?>> resourcekey) {
|
||||
RecipeHolder<?> recipeholder = this.recipes.byKey(resourcekey);
|
||||
|
||||
- return recipeholder != null && recipeholder.value().getType().equals(recipes) ? recipeholder : null;
|
||||
+ return recipeholder != null && recipeholder.value().getType().equals(recipes) ? (RecipeHolder) recipeholder : null; // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public Collection<RecipeHolder<?>> getOrderedRecipes() {
|
||||
@@ -171,10 +195,31 @@
|
||||
com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder);
|
||||
}
|
||||
|
||||
- this.byType = builder.build();
|
||||
- this.byName = com_google_common_collect_immutablemap_builder.build();
|
||||
+ // CraftBukkit start - mutable
|
||||
+ this.byType = LinkedHashMultimap.create(builder.build());
|
||||
+ this.byName = Maps.newHashMap(com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(MinecraftKey mcKey) {
|
||||
+ Iterator<RecipeHolder<?>> iter = byType.values().iterator();
|
||||
+ while (iter.hasNext()) {
|
||||
+ RecipeHolder<?> recipe = iter.next();
|
||||
+ if (recipe.id().equals(mcKey)) {
|
||||
+ iter.remove();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return byName.remove(mcKey) != null;
|
||||
public Map<ResourceKey<RecipePropertySet>, RecipePropertySet> getSynchronizedItemProperties() {
|
||||
@@ -229,6 +252,22 @@
|
||||
return new RecipeHolder<>(resourcekey, irecipe);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(ResourceKey<IRecipe<?>> mcKey) {
|
||||
+ boolean removed = this.recipes.removeRecipe(mcKey);
|
||||
+ if (removed) {
|
||||
+ finalizeRecipeLoading();
|
||||
+ }
|
||||
+
|
||||
+ return removed;
|
||||
+ }
|
||||
+
|
||||
+ public void clearRecipes() {
|
||||
+ this.byType = LinkedHashMultimap.create();
|
||||
+ this.byName = Maps.newHashMap();
|
||||
+ this.recipes = RecipeMap.create(Collections.emptyList());
|
||||
+ finalizeRecipeLoading();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/FurnaceRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/FurnaceRecipe.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class FurnaceRecipe extends RecipeCooking {
|
||||
|
||||
public FurnaceRecipe(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.SMELTING_RECIPE;
|
||||
@@ -45,4 +53,17 @@
|
||||
|
||||
return recipebookcategory;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftFurnaceRecipe recipe = new CraftFurnaceRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipe.java
|
||||
@@ -71,4 +71,6 @@
|
||||
return recipeitemstack.getItems().length == 0;
|
||||
});
|
||||
@@ -44,4 +44,6 @@
|
||||
}
|
||||
|
||||
RecipeBookCategory recipeBookCategory();
|
||||
+
|
||||
+ org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id); // CraftBukkit
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
--- a/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
+++ b/net/minecraft/world/item/crafting/IRecipeComplex.java
|
||||
@@ -3,6 +3,15 @@
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -8,6 +8,15 @@
|
||||
import net.minecraft.network.RegistryFriendlyByteBuf;
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import net.minecraft.core.IRegistryCustom;
|
||||
+import net.minecraft.world.item.ItemStack;
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftComplexRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
@@ -16,21 +16,39 @@
|
||||
public abstract class IRecipeComplex implements RecipeCrafting {
|
||||
|
||||
private final CraftingBookCategory category;
|
||||
@@ -25,4 +34,17 @@
|
||||
public CraftingBookCategory category() {
|
||||
return this.category;
|
||||
}
|
||||
+
|
||||
@@ -34,6 +43,19 @@
|
||||
@Override
|
||||
public abstract RecipeSerializer<? extends IRecipeComplex> getSerializer();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(getResultItem(IRegistryCustom.EMPTY));
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(ItemStack.EMPTY);
|
||||
+
|
||||
+ CraftComplexRecipe recipe = new CraftComplexRecipe(id, result, this);
|
||||
+ recipe.setGroup(this.getGroup());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
+
|
||||
public static class Serializer<T extends RecipeCrafting> implements RecipeSerializer<T> {
|
||||
|
||||
private final MapCodec<T> codec;
|
||||
@@ -41,13 +63,13 @@
|
||||
|
||||
public Serializer(IRecipeComplex.Serializer.Factory<T> irecipecomplex_serializer_factory) {
|
||||
this.codec = RecordCodecBuilder.mapCodec((instance) -> {
|
||||
- P1 p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category));
|
||||
+ P1<RecordCodecBuilder.Mu<T>, CraftingBookCategory> p1 = instance.group(CraftingBookCategory.CODEC.fieldOf("category").orElse(CraftingBookCategory.MISC).forGetter(RecipeCrafting::category)); // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(irecipecomplex_serializer_factory);
|
||||
return p1.apply(instance, irecipecomplex_serializer_factory::create);
|
||||
});
|
||||
StreamCodec streamcodec = CraftingBookCategory.STREAM_CODEC;
|
||||
- Function function = RecipeCrafting::category;
|
||||
+ Function<RecipeCrafting, CraftingBookCategory> function = RecipeCrafting::category; // CraftBukkit - decompile error
|
||||
|
||||
Objects.requireNonNull(irecipecomplex_serializer_factory);
|
||||
this.streamCodec = StreamCodec.composite(streamcodec, function, irecipecomplex_serializer_factory::create);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeBlasting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeBlasting.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeBlasting extends RecipeCooking {
|
||||
|
||||
public RecipeBlasting(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.BLASTING_RECIPE;
|
||||
@@ -43,4 +51,17 @@
|
||||
|
||||
return recipebookcategory;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftBlastingRecipe recipe = new CraftBlastingRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ 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 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeCampfire extends RecipeCooking {
|
||||
|
||||
public RecipeCampfire(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.CAMPFIRE_COOKING_RECIPE;
|
||||
@@ -29,4 +37,17 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.CAMPFIRE;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftCampfireRecipe recipe = new CraftCampfireRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
@@ -4,8 +4,19 @@
|
||||
@@ -5,8 +5,19 @@
|
||||
import net.minecraft.network.codec.StreamCodec;
|
||||
import net.minecraft.resources.MinecraftKey;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public record RecipeHolder<T extends IRecipe<?>>(MinecraftKey id, T value) {
|
||||
public record RecipeHolder<T extends IRecipe<?>>(ResourceKey<IRecipe<?>> id, T value) {
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final Recipe toBukkitRecipe() {
|
||||
+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id));
|
||||
+ return this.value.toBukkitRecipe(CraftNamespacedKey.fromMinecraft(this.id.location()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, RecipeHolder<?>> STREAM_CODEC = StreamCodec.composite(MinecraftKey.STREAM_CODEC, RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new);
|
||||
public static final StreamCodec<RegistryFriendlyByteBuf, RecipeHolder<?>> STREAM_CODEC = StreamCodec.composite(ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, IRecipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new);
|
||||
|
||||
public boolean equals(Object object) {
|
||||
|
||||
@@ -1,26 +1,52 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeItemStack.java
|
||||
@@ -40,6 +40,7 @@
|
||||
public ItemStack[] itemStacks;
|
||||
@@ -42,6 +42,24 @@
|
||||
private final HolderSet<Item> values;
|
||||
@Nullable
|
||||
private IntList stackingIds;
|
||||
+ public boolean exact; // CraftBukkit
|
||||
public static final Codec<RecipeItemStack> CODEC = codec(true);
|
||||
public static final Codec<RecipeItemStack> CODEC_NONEMPTY = codec(false);
|
||||
|
||||
@@ -77,6 +78,15 @@
|
||||
for (int j = 0; j < i; ++j) {
|
||||
ItemStack itemstack1 = aitemstack[j];
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (exact) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
private List<Holder<Item>> items;
|
||||
+ // CraftBukkit start
|
||||
+ @Nullable
|
||||
+ private List<ItemStack> itemStacks;
|
||||
+
|
||||
+ continue;
|
||||
+ public boolean isExact() {
|
||||
+ return this.itemStacks != null;
|
||||
+ }
|
||||
+
|
||||
+ public List<ItemStack> itemStacks() {
|
||||
+ return this.itemStacks;
|
||||
+ }
|
||||
+
|
||||
+ public static RecipeItemStack ofStacks(Stream<ItemStack> stacks) {
|
||||
+ RecipeItemStack recipe = RecipeItemStack.of(stacks.map(ItemStack::getItem));
|
||||
+ recipe.itemStacks = stacks.toList();
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
private RecipeItemStack(HolderSet<Item> holderset) {
|
||||
holderset.unwrap().ifRight((list) -> {
|
||||
@@ -72,6 +90,15 @@
|
||||
}
|
||||
|
||||
public boolean test(ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isExact()) {
|
||||
+ for (ItemStack itemstack1 : this.itemStacks()) {
|
||||
+ if (itemstack1.getItem() == itemstack.getItem() && ItemStack.isSameItemSameComponents(itemstack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (itemstack1.is(itemstack.getItem())) {
|
||||
return true;
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
List<Holder<Item>> list = this.items();
|
||||
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
@@ -85,7 +112,7 @@
|
||||
|
||||
public boolean equals(Object object) {
|
||||
if (object instanceof RecipeItemStack recipeitemstack) {
|
||||
- return Objects.equals(this.values, recipeitemstack.values);
|
||||
+ return Objects.equals(this.values, recipeitemstack.values) && Objects.equals(this.itemStacks, recipeitemstack.itemStacks); // CraftBukkit
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
@@ -12,6 +12,11 @@
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import com.google.common.collect.LinkedHashMultimap;
|
||||
+import com.google.common.collect.Maps;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class RecipeMap {
|
||||
|
||||
public static final RecipeMap EMPTY = new RecipeMap(ImmutableMultimap.of(), Map.of());
|
||||
@@ -35,11 +40,39 @@
|
||||
com_google_common_collect_immutablemap_builder.put(recipeholder.id(), recipeholder);
|
||||
}
|
||||
|
||||
- return new RecipeMap(builder.build(), com_google_common_collect_immutablemap_builder.build());
|
||||
+ // CraftBukkit start - mutable
|
||||
+ return new RecipeMap(LinkedHashMultimap.create(builder.build()), Maps.newHashMap(com_google_common_collect_immutablemap_builder.build()));
|
||||
+ }
|
||||
+
|
||||
+ public void addRecipe(RecipeHolder<?> irecipe) {
|
||||
+ Collection<RecipeHolder<?>> map = this.byType.get(irecipe.value().getType());
|
||||
+
|
||||
+ if (byKey.containsKey(irecipe.id())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
|
||||
+ } else {
|
||||
+ map.add(irecipe);
|
||||
+ byKey.put(irecipe.id(), irecipe);
|
||||
+ }
|
||||
}
|
||||
|
||||
+ public boolean removeRecipe(ResourceKey<IRecipe<?>> mcKey) {
|
||||
+ boolean removed = false;
|
||||
+ Iterator<RecipeHolder<?>> iter = byType.values().iterator();
|
||||
+ while (iter.hasNext()) {
|
||||
+ RecipeHolder<?> recipe = iter.next();
|
||||
+ if (recipe.id().equals(mcKey)) {
|
||||
+ iter.remove();
|
||||
+ removed = true;
|
||||
+ }
|
||||
+ }
|
||||
+ removed |= byKey.remove(mcKey) != null;
|
||||
+
|
||||
+ return removed;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public <I extends RecipeInput, T extends IRecipe<I>> Collection<RecipeHolder<T>> byType(Recipes<T> recipes) {
|
||||
- return this.byType.get(recipes);
|
||||
+ return (Collection) this.byType.get(recipes); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public Collection<RecipeHolder<?>> values() {
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeSmoking.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeSmoking.java
|
||||
@@ -3,6 +3,14 @@
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.item.Items;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeSmoking extends RecipeCooking {
|
||||
|
||||
public RecipeSmoking(String s, CookingBookCategory cookingbookcategory, RecipeItemStack recipeitemstack, ItemStack itemstack, float f, int i) {
|
||||
@@ -18,4 +26,17 @@
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
return RecipeSerializer.SMOKING_RECIPE;
|
||||
@@ -29,4 +37,17 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.SMOKER_FOOD;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient), this.experience, this.cookingTime);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftSmokingRecipe recipe = new CraftSmokingRecipe(id, result, CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeStonecutting.java
|
||||
@@ -4,6 +4,14 @@
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
@@ -7,6 +7,14 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.item.crafting.display.StonecutterRecipeDisplay;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -15,18 +15,18 @@
|
||||
public class RecipeStonecutting extends RecipeSingleItem {
|
||||
|
||||
public RecipeStonecutting(String s, RecipeItemStack recipeitemstack, ItemStack itemstack) {
|
||||
@@ -18,4 +26,16 @@
|
||||
public ItemStack getToastSymbol() {
|
||||
return new ItemStack(Blocks.STONECUTTER);
|
||||
@@ -36,4 +44,16 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.STONECUTTER;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result);
|
||||
+ CraftItemStack result = CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.ingredient));
|
||||
+ recipe.setGroup(this.group);
|
||||
+ CraftStonecuttingRecipe recipe = new CraftStonecuttingRecipe(id, result, CraftRecipe.toBukkit(this.input()));
|
||||
+ 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
|
||||
@@ -10,6 +10,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -17,6 +17,14 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -15,7 +15,7 @@
|
||||
public class ShapedRecipes implements RecipeCrafting {
|
||||
|
||||
final ShapedRecipePattern pattern;
|
||||
@@ -30,6 +38,68 @@
|
||||
@@ -39,6 +47,68 @@
|
||||
this(s, craftingbookcategory, shapedrecipepattern, itemstack, true);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (RecipeItemStack list : this.pattern.ingredients()) {
|
||||
+ for (Optional<RecipeItemStack> list : this.pattern.ingredients()) {
|
||||
+ RecipeChoice choice = CraftRecipe.toBukkit(list);
|
||||
+ if (choice != null) {
|
||||
+ recipe.setIngredient(c, choice);
|
||||
@@ -82,5 +82,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<? extends ShapedRecipes> getSerializer() {
|
||||
return RecipeSerializer.SHAPED_RECIPE;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapelessRecipes.java
|
||||
@@ -13,6 +13,13 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -17,6 +17,13 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
@@ -14,8 +14,8 @@
|
||||
public class ShapelessRecipes implements RecipeCrafting {
|
||||
|
||||
final String group;
|
||||
@@ -27,6 +34,22 @@
|
||||
this.ingredients = nonnulllist;
|
||||
@@ -33,6 +40,22 @@
|
||||
this.ingredients = list;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
@@ -35,5 +35,5 @@
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<?> getSerializer() {
|
||||
public RecipeSerializer<ShapelessRecipes> getSerializer() {
|
||||
return RecipeSerializer.SHAPELESS_RECIPE;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
@@ -9,6 +9,14 @@
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
@@ -14,6 +14,14 @@
|
||||
import net.minecraft.world.item.crafting.display.SlotDisplay;
|
||||
import net.minecraft.world.item.crafting.display.SmithingRecipeDisplay;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -14,9 +14,9 @@
|
||||
+
|
||||
public class SmithingTransformRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
@@ -64,6 +72,17 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
final Optional<RecipeItemStack> template;
|
||||
@@ -71,6 +79,17 @@
|
||||
return List.of(new SmithingRecipeDisplay(RecipeItemStack.optionalIngredientToDisplay(this.template), RecipeItemStack.optionalIngredientToDisplay(this.base), RecipeItemStack.optionalIngredientToDisplay(this.addition), new SlotDisplay.f(this.result), new SlotDisplay.d(Items.SMITHING_TABLE)));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
@@ -19,6 +19,13 @@
|
||||
import net.minecraft.world.item.armortrim.TrimPatterns;
|
||||
import net.minecraft.world.level.World;
|
||||
@@ -21,6 +21,13 @@
|
||||
import net.minecraft.world.item.equipment.trim.TrimPattern;
|
||||
import net.minecraft.world.item.equipment.trim.TrimPatterns;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
@@ -13,9 +13,9 @@
|
||||
+
|
||||
public class SmithingTrimRecipe implements SmithingRecipe {
|
||||
|
||||
final RecipeItemStack template;
|
||||
final Optional<RecipeItemStack> template;
|
||||
@@ -97,6 +104,13 @@
|
||||
return Stream.of(this.template, this.base, this.addition).anyMatch(RecipeItemStack::isEmpty);
|
||||
return List.of(new SmithingRecipeDisplay(slotdisplay2, slotdisplay, slotdisplay1, new SlotDisplay.g(slotdisplay, slotdisplay1, slotdisplay2), new SlotDisplay.d(Items.SMITHING_TABLE)));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/world/item/crafting/TransmuteRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java
|
||||
@@ -20,6 +20,14 @@
|
||||
import net.minecraft.world.level.IMaterial;
|
||||
import net.minecraft.world.level.World;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.NamespacedKey;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemType;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftRecipe;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe;
|
||||
+import org.bukkit.inventory.Recipe;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TransmuteRecipe implements RecipeCrafting {
|
||||
|
||||
final String group;
|
||||
@@ -84,6 +92,13 @@
|
||||
return List.of(new ShapelessCraftingRecipeDisplay(List.of(this.input.display(), this.material.display()), new SlotDisplay.d(this.result), new SlotDisplay.d(Items.CRAFTING_TABLE)));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public Recipe toBukkitRecipe(NamespacedKey id) {
|
||||
+ return new CraftTransmuteRecipe(id, CraftItemType.minecraftToBukkit(this.result.value()), CraftRecipe.toBukkit(this.input), CraftRecipe.toBukkit(this.material));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<TransmuteRecipe> getSerializer() {
|
||||
return RecipeSerializer.TRANSMUTE;
|
||||
Reference in New Issue
Block a user