mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 20:22:05 -07:00
net.minecraft.world.item.crafting
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/crafting/BlastingRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/BlastingRecipe.java
|
||||
@@ -31,4 +_,17 @@
|
||||
case FOOD, MISC -> RecipeBookCategories.BLAST_FURNACE_MISC;
|
||||
};
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftBlastingRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftBlastingRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/crafting/CampfireCookingRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/CampfireCookingRecipe.java
|
||||
@@ -28,4 +_,17 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.CAMPFIRE;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftCampfireRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftCampfireRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/world/item/crafting/CustomRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/CustomRecipe.java
|
||||
@@ -30,6 +_,19 @@
|
||||
@Override
|
||||
public abstract RecipeSerializer<? extends CustomRecipe> getSerializer();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(net.minecraft.world.item.ItemStack.EMPTY);
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftComplexRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftComplexRecipe(id, result, this);
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static class Serializer<T extends CraftingRecipe> implements RecipeSerializer<T> {
|
||||
private final MapCodec<T> codec;
|
||||
private final StreamCodec<RegistryFriendlyByteBuf, T> streamCodec;
|
@@ -0,0 +1,55 @@
|
||||
--- a/net/minecraft/world/item/crafting/Ingredient.java
|
||||
+++ b/net/minecraft/world/item/crafting/Ingredient.java
|
||||
@@ -33,6 +_,25 @@
|
||||
public static final Codec<Ingredient> CODEC = ExtraCodecs.nonEmptyHolderSet(NON_AIR_HOLDER_SET_CODEC)
|
||||
.xmap(Ingredient::new, ingredient -> ingredient.values);
|
||||
private final HolderSet<Item> values;
|
||||
+ // CraftBukkit start
|
||||
+ @javax.annotation.Nullable
|
||||
+ private java.util.List<ItemStack> itemStacks;
|
||||
+
|
||||
+ public boolean isExact() {
|
||||
+ return this.itemStacks != null;
|
||||
+ }
|
||||
+
|
||||
+ @javax.annotation.Nullable
|
||||
+ public java.util.List<ItemStack> itemStacks() {
|
||||
+ return this.itemStacks;
|
||||
+ }
|
||||
+
|
||||
+ public static Ingredient ofStacks(java.util.List<ItemStack> stacks) {
|
||||
+ Ingredient recipe = Ingredient.of(stacks.stream().map(ItemStack::getItem));
|
||||
+ recipe.itemStacks = stacks;
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
private Ingredient(HolderSet<Item> values) {
|
||||
values.unwrap().ifRight(list -> {
|
||||
@@ -60,6 +_,17 @@
|
||||
|
||||
@Override
|
||||
public boolean test(ItemStack stack) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this.isExact()) {
|
||||
+ for (ItemStack itemstack1 : this.itemStacks()) {
|
||||
+ if (itemstack1.getItem() == stack.getItem() && ItemStack.isSameItemSameComponents(stack, itemstack1)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return stack.is(this.values);
|
||||
}
|
||||
|
||||
@@ -70,7 +_,7 @@
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
- return other instanceof Ingredient ingredient && Objects.equals(this.values, ingredient.values);
|
||||
+ return other instanceof Ingredient ingredient && Objects.equals(this.values, ingredient.values) && Objects.equals(this.itemStacks, ingredient.itemStacks); // CraftBukkit
|
||||
}
|
||||
|
||||
public static Ingredient of(ItemLike item) {
|
@@ -0,0 +1,9 @@
|
||||
--- a/net/minecraft/world/item/crafting/Recipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/Recipe.java
|
||||
@@ -44,4 +_,6 @@
|
||||
}
|
||||
|
||||
RecipeBookCategory recipeBookCategory();
|
||||
+
|
||||
+ org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id); // CraftBukkit
|
||||
}
|
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeHolder.java
|
||||
@@ -10,6 +_,12 @@
|
||||
ResourceKey.streamCodec(Registries.RECIPE), RecipeHolder::id, Recipe.STREAM_CODEC, RecipeHolder::value, RecipeHolder::new
|
||||
);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public final org.bukkit.inventory.Recipe toBukkitRecipe() {
|
||||
+ return this.value.toBukkitRecipe(org.bukkit.craftbukkit.util.CraftNamespacedKey.fromMinecraft(this.id.location()));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
return this == other || other instanceof RecipeHolder<?> recipeHolder && this.id == recipeHolder.id;
|
@@ -0,0 +1,64 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeManager.java
|
||||
@@ -87,7 +_,26 @@
|
||||
LOGGER.info("Loaded {} recipes", object.values().size());
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public void addRecipe(RecipeHolder<?> irecipe) {
|
||||
+ org.spigotmc.AsyncCatcher.catchOp("Recipe Add"); // Spigot
|
||||
+ this.recipes.addRecipe(irecipe);
|
||||
+ this.finalizeRecipeLoading();
|
||||
+ }
|
||||
+
|
||||
+ private FeatureFlagSet featureflagset;
|
||||
+
|
||||
+ public void finalizeRecipeLoading() {
|
||||
+ if (this.featureflagset != null) {
|
||||
+ this.finalizeRecipeLoading(this.featureflagset);
|
||||
+
|
||||
+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().reloadRecipes();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
public void finalizeRecipeLoading(FeatureFlagSet enabledFeatures) {
|
||||
+ this.featureflagset = enabledFeatures;
|
||||
+ // CraftBukkit end
|
||||
List<SelectableRecipe.SingleInputEntry<StonecutterRecipe>> list = new ArrayList<>();
|
||||
List<RecipeManager.IngredientCollector> list1 = RECIPE_PROPERTY_SETS.entrySet()
|
||||
.stream()
|
||||
@@ -147,7 +_,10 @@
|
||||
}
|
||||
|
||||
public <I extends RecipeInput, T extends Recipe<I>> Optional<RecipeHolder<T>> getRecipeFor(RecipeType<T> recipeType, I input, Level level) {
|
||||
- return this.recipes.getRecipesFor(recipeType, input, level).findFirst();
|
||||
+ // CraftBukkit start
|
||||
+ List<RecipeHolder<T>> list = this.recipes.getRecipesFor(recipeType, input, level).toList();
|
||||
+ return (list.isEmpty()) ? Optional.empty() : Optional.of(list.getLast()); // CraftBukkit - SPIGOT-4638: last recipe gets priority
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public Optional<RecipeHolder<?>> byKey(ResourceKey<Recipe<?>> key) {
|
||||
@@ -199,6 +_,22 @@
|
||||
Recipe<?> recipe1 = Recipe.CODEC.parse(registries.createSerializationContext(JsonOps.INSTANCE), json).getOrThrow(JsonParseException::new);
|
||||
return new RecipeHolder<>(recipe, recipe1);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ public boolean removeRecipe(ResourceKey<Recipe<?>> mcKey) {
|
||||
+ boolean removed = this.recipes.removeRecipe((ResourceKey<Recipe<RecipeInput>>) (ResourceKey) mcKey); // Paper - generic fix
|
||||
+ if (removed) {
|
||||
+ this.finalizeRecipeLoading();
|
||||
+ }
|
||||
+
|
||||
+ return removed;
|
||||
+ }
|
||||
+
|
||||
+ public void clearRecipes() {
|
||||
+ this.recipes = RecipeMap.create(java.util.Collections.emptyList());
|
||||
+ this.finalizeRecipeLoading();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static <I extends RecipeInput, T extends Recipe<I>> RecipeManager.CachedCheck<I, T> createCheck(final RecipeType<T> recipeType) {
|
||||
return new RecipeManager.CachedCheck<I, T>() {
|
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
+++ b/net/minecraft/world/item/crafting/RecipeMap.java
|
||||
@@ -30,8 +_,53 @@
|
||||
builder1.put(recipeHolder.id(), recipeHolder);
|
||||
}
|
||||
|
||||
- return new RecipeMap(builder.build(), builder1.build());
|
||||
- }
|
||||
+ // CraftBukkit start - mutable
|
||||
+ 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());
|
||||
+
|
||||
+ if (this.byKey.containsKey(irecipe.id())) {
|
||||
+ throw new IllegalStateException("Duplicate recipe ignored with ID " + irecipe.id());
|
||||
+ } else {
|
||||
+ map.add(irecipe);
|
||||
+ this.byKey.put(irecipe.id(), irecipe);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ // 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
|
||||
+ final RecipeHolder<Recipe<T>> remove = (RecipeHolder<Recipe<T>>) this.byKey.remove(mcKey);
|
||||
+ if (remove == null) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ final Collection<? extends RecipeHolder<? extends Recipe<T>>> recipes = this.byType(remove.value().getType());
|
||||
+ if (recipes.remove(remove)) {
|
||||
+ return true;
|
||||
+ }
|
||||
+ return false;
|
||||
+ // Paper end - why are you using a loop???
|
||||
+ }
|
||||
+ // Paper end - replace removeRecipe implementation
|
||||
|
||||
public <I extends RecipeInput, T extends Recipe<I>> Collection<RecipeHolder<T>> byType(RecipeType<T> type) {
|
||||
return (Collection)this.byType.get(type);
|
@@ -0,0 +1,71 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapedRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapedRecipe.java
|
||||
@@ -103,6 +_,68 @@
|
||||
);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.ShapedRecipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result);
|
||||
+ org.bukkit.craftbukkit.inventory.CraftShapedRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftShapedRecipe(id, result, this);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ switch (this.pattern.height()) {
|
||||
+ case 1:
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a");
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ recipe.shape("ab");
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ recipe.shape("abc");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b");
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ recipe.shape("ab","cd");
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ recipe.shape("abc","def");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ switch (this.pattern.width()) {
|
||||
+ case 1:
|
||||
+ recipe.shape("a","b","c");
|
||||
+ break;
|
||||
+ case 2:
|
||||
+ recipe.shape("ab","cd","ef");
|
||||
+ break;
|
||||
+ case 3:
|
||||
+ recipe.shape("abc","def","ghi");
|
||||
+ break;
|
||||
+ }
|
||||
+ break;
|
||||
+ }
|
||||
+ char c = 'a';
|
||||
+ for (Optional<Ingredient> list : this.pattern.ingredients()) {
|
||||
+ org.bukkit.inventory.RecipeChoice choice = org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(list);
|
||||
+ if (choice != org.bukkit.inventory.RecipeChoice.empty()) { // Paper
|
||||
+ recipe.setIngredient(c, choice);
|
||||
+ }
|
||||
+
|
||||
+ c++;
|
||||
+ }
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static class Serializer implements RecipeSerializer<ShapedRecipe> {
|
||||
public static final MapCodec<ShapedRecipe> CODEC = RecordCodecBuilder.mapCodec(
|
||||
instance -> instance.group(
|
@@ -0,0 +1,24 @@
|
||||
--- a/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/ShapelessRecipe.java
|
||||
@@ -31,6 +_,21 @@
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.ShapelessRecipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result);
|
||||
+ org.bukkit.craftbukkit.inventory.CraftShapelessRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftShapelessRecipe(id, result, this);
|
||||
+ recipe.setGroup(this.group);
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ for (Ingredient list : this.ingredients) {
|
||||
+ recipe.addIngredient(org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(list));
|
||||
+ }
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<ShapelessRecipe> getSerializer() {
|
||||
return RecipeSerializer.SHAPELESS_RECIPE;
|
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmeltingRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmeltingRecipe.java
|
||||
@@ -32,4 +_,17 @@
|
||||
case MISC -> RecipeBookCategories.FURNACE_MISC;
|
||||
};
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftFurnaceRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTransformRecipe.java
|
||||
@@ -21,8 +_,15 @@
|
||||
final ItemStack result;
|
||||
@Nullable
|
||||
private PlacementInfo placementInfo;
|
||||
+ final boolean copyDataComponents; // Paper - Option to prevent data components copy
|
||||
|
||||
public SmithingTransformRecipe(Optional<Ingredient> template, Optional<Ingredient> base, Optional<Ingredient> addition, ItemStack result) {
|
||||
+ // Paper start - Option to prevent data components copy
|
||||
+ this(template, base, addition, result, true);
|
||||
+ }
|
||||
+ public SmithingTransformRecipe(Optional<Ingredient> template, Optional<Ingredient> base, Optional<Ingredient> addition, ItemStack result, boolean copyDataComponents) {
|
||||
+ this.copyDataComponents = copyDataComponents;
|
||||
+ // Paper end - Option to prevent data components copy
|
||||
this.template = template;
|
||||
this.base = base;
|
||||
this.addition = addition;
|
||||
@@ -32,7 +_,9 @@
|
||||
@Override
|
||||
public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) {
|
||||
ItemStack itemStack = input.base().transmuteCopy(this.result.getItem(), this.result.getCount());
|
||||
+ if (this.copyDataComponents) { // Paper - Option to prevent data components copy
|
||||
itemStack.applyComponents(this.result.getComponentsPatch());
|
||||
+ } // Paper - Option to prevent data components copy
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
@@ -77,6 +_,17 @@
|
||||
)
|
||||
);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result);
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftSmithingTransformRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static class Serializer implements RecipeSerializer<SmithingTransformRecipe> {
|
||||
private static final MapCodec<SmithingTransformRecipe> CODEC = RecordCodecBuilder.mapCodec(
|
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java
|
||||
@@ -27,8 +_,15 @@
|
||||
final Optional<Ingredient> addition;
|
||||
@Nullable
|
||||
private PlacementInfo placementInfo;
|
||||
+ final boolean copyDataComponents; // Paper - Option to prevent data components copy
|
||||
|
||||
public SmithingTrimRecipe(Optional<Ingredient> template, Optional<Ingredient> base, Optional<Ingredient> addition) {
|
||||
+ // Paper start - Option to prevent data components copy
|
||||
+ this(template, base, addition, true);
|
||||
+ }
|
||||
+ public SmithingTrimRecipe(Optional<Ingredient> template, Optional<Ingredient> base, Optional<Ingredient> addition, boolean copyDataComponents) {
|
||||
+ this.copyDataComponents = copyDataComponents;
|
||||
+ // Paper end - Option to prevent data components copy
|
||||
this.template = template;
|
||||
this.base = base;
|
||||
this.addition = addition;
|
||||
@@ -36,10 +_,15 @@
|
||||
|
||||
@Override
|
||||
public ItemStack assemble(SmithingRecipeInput input, HolderLookup.Provider registries) {
|
||||
- return applyTrim(registries, input.base(), input.addition(), input.template());
|
||||
+ return applyTrim(registries, input.base(), input.addition(), input.template(), this.copyDataComponents); // Paper - Option to prevent data components copy
|
||||
}
|
||||
|
||||
public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template) {
|
||||
+ // Paper start - Option to prevent data components copy
|
||||
+ return applyTrim(registries, base, addition, template, true);
|
||||
+ }
|
||||
+ public static ItemStack applyTrim(HolderLookup.Provider registries, ItemStack base, ItemStack addition, ItemStack template, boolean copyDataComponents) {
|
||||
+ // Paper end - Option to prevent data components copy
|
||||
Optional<Holder.Reference<TrimMaterial>> fromIngredient = TrimMaterials.getFromIngredient(registries, addition);
|
||||
Optional<Holder.Reference<TrimPattern>> fromTemplate = TrimPatterns.getFromTemplate(registries, template);
|
||||
if (fromIngredient.isPresent() && fromTemplate.isPresent()) {
|
||||
@@ -47,7 +_,7 @@
|
||||
if (armorTrim != null && armorTrim.hasPatternAndMaterial(fromTemplate.get(), fromIngredient.get())) {
|
||||
return ItemStack.EMPTY;
|
||||
} else {
|
||||
- ItemStack itemStack = base.copyWithCount(1);
|
||||
+ ItemStack itemStack = copyDataComponents ? base.copyWithCount(1) : new ItemStack(base.getItem(), 1); // Paper - Option to prevent data components copy
|
||||
itemStack.set(DataComponents.TRIM, new ArmorTrim(fromIngredient.get(), fromTemplate.get()));
|
||||
return itemStack;
|
||||
}
|
||||
@@ -100,6 +_,13 @@
|
||||
)
|
||||
);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ return new org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe(id, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.template), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.base), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.addition), this.copyDataComponents); // Paper - Option to prevent data components copy
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public static class Serializer implements RecipeSerializer<SmithingTrimRecipe> {
|
||||
private static final MapCodec<SmithingTrimRecipe> CODEC = RecordCodecBuilder.mapCodec(
|
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/world/item/crafting/SmokingRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/SmokingRecipe.java
|
||||
@@ -28,4 +_,17 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.SMOKER_FOOD;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftSmokingRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftSmokingRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()), this.experience(), this.cookingTime());
|
||||
+ recipe.setGroup(this.group());
|
||||
+ recipe.setCategory(org.bukkit.craftbukkit.inventory.CraftRecipe.getCategory(this.category()));
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
--- a/net/minecraft/world/item/crafting/StonecutterRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/StonecutterRecipe.java
|
||||
@@ -35,4 +_,16 @@
|
||||
public RecipeBookCategory recipeBookCategory() {
|
||||
return RecipeBookCategories.STONECUTTER;
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ org.bukkit.craftbukkit.inventory.CraftItemStack result = org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(this.result());
|
||||
+
|
||||
+ org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe recipe = new org.bukkit.craftbukkit.inventory.CraftStonecuttingRecipe(id, result, org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input()));
|
||||
+ recipe.setGroup(this.group());
|
||||
+
|
||||
+ return recipe;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/world/item/crafting/TransmuteRecipe.java
|
||||
+++ b/net/minecraft/world/item/crafting/TransmuteRecipe.java
|
||||
@@ -88,6 +_,13 @@
|
||||
);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.inventory.Recipe toBukkitRecipe(org.bukkit.NamespacedKey id) {
|
||||
+ return new org.bukkit.craftbukkit.inventory.CraftTransmuteRecipe(id, org.bukkit.craftbukkit.inventory.CraftItemType.minecraftToBukkit(this.result.value()), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.input), org.bukkit.craftbukkit.inventory.CraftRecipe.toBukkit(this.material));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public RecipeSerializer<TransmuteRecipe> getSerializer() {
|
||||
return RecipeSerializer.TRANSMUTE;
|
Reference in New Issue
Block a user