diff options
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch new file mode 100644 index 0000000000..ef758f8657 --- /dev/null +++ b/patch-remap/mache-vineflower/net/minecraft/world/item/crafting/SmithingTrimRecipe.java.patch @@ -0,0 +1,170 @@ +--- a/net/minecraft/world/item/crafting/SmithingTrimRecipe.java ++++ b/net/minecraft/world/item/crafting/SmithingTrimRecipe.java +@@ -2,7 +2,6 @@ + + import com.mojang.serialization.Codec; + import com.mojang.serialization.codecs.RecordCodecBuilder; +-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance; + import java.util.Optional; + import java.util.stream.Stream; + import net.minecraft.core.Holder; +@@ -18,16 +17,23 @@ + import net.minecraft.world.item.armortrim.TrimPattern; + import net.minecraft.world.item.armortrim.TrimPatterns; + import net.minecraft.world.level.Level; ++// CraftBukkit start ++import org.bukkit.NamespacedKey; ++import org.bukkit.craftbukkit.inventory.CraftRecipe; ++import org.bukkit.craftbukkit.inventory.CraftSmithingTrimRecipe; ++import org.bukkit.inventory.Recipe; ++// CraftBukkit end + + public class SmithingTrimRecipe implements SmithingRecipe { ++ + final Ingredient template; + final Ingredient base; + final Ingredient addition; + +- public SmithingTrimRecipe(Ingredient ingredient, Ingredient ingredient1, Ingredient ingredient2) { +- this.template = ingredient; +- this.base = ingredient1; +- this.addition = ingredient2; ++ public SmithingTrimRecipe(Ingredient recipeitemstack, Ingredient recipeitemstack1, Ingredient recipeitemstack2) { ++ this.template = recipeitemstack; ++ this.base = recipeitemstack1; ++ this.addition = recipeitemstack2; + } + + @Override +@@ -37,21 +43,26 @@ + + @Override + public ItemStack assemble(Container container, RegistryAccess registryAccess) { +- ItemStack item = container.getItem(1); +- if (this.base.test(item)) { +- Optional<Holder.Reference<TrimMaterial>> fromIngredient = TrimMaterials.getFromIngredient(registryAccess, container.getItem(2)); +- Optional<Holder.Reference<TrimPattern>> fromTemplate = TrimPatterns.getFromTemplate(registryAccess, container.getItem(0)); +- if (fromIngredient.isPresent() && fromTemplate.isPresent()) { +- Optional<ArmorTrim> trim = ArmorTrim.getTrim(registryAccess, item, false); +- if (trim.isPresent() && trim.get().hasPatternAndMaterial(fromTemplate.get(), fromIngredient.get())) { ++ ItemStack itemstack = container.getItem(1); ++ ++ if (this.base.test(itemstack)) { ++ Optional<Holder.Reference<TrimMaterial>> optional = TrimMaterials.getFromIngredient(registryAccess, container.getItem(2)); ++ Optional<Holder.Reference<TrimPattern>> optional1 = TrimPatterns.getFromTemplate(registryAccess, container.getItem(0)); ++ ++ if (optional.isPresent() && optional1.isPresent()) { ++ Optional<ArmorTrim> optional2 = ArmorTrim.getTrim(registryAccess, itemstack, false); ++ ++ if (optional2.isPresent() && ((ArmorTrim) optional2.get()).hasPatternAndMaterial((Holder) optional1.get(), (Holder) optional.get())) { + return ItemStack.EMPTY; + } + +- ItemStack itemStack = item.copy(); +- itemStack.setCount(1); +- ArmorTrim armorTrim = new ArmorTrim(fromIngredient.get(), fromTemplate.get()); +- if (ArmorTrim.setTrim(registryAccess, itemStack, armorTrim)) { +- return itemStack; ++ ItemStack itemstack1 = itemstack.copy(); ++ ++ itemstack1.setCount(1); ++ ArmorTrim armortrim = new ArmorTrim((Holder) optional.get(), (Holder) optional1.get()); ++ ++ if (ArmorTrim.setTrim(registryAccess, itemstack1, armortrim)) { ++ return itemstack1; + } + } + } +@@ -61,17 +72,20 @@ + + @Override + public ItemStack getResultItem(RegistryAccess registryAccess) { +- ItemStack itemStack = new ItemStack(Items.IRON_CHESTPLATE); ++ ItemStack itemstack = new ItemStack(Items.IRON_CHESTPLATE); + Optional<Holder.Reference<TrimPattern>> optional = registryAccess.registryOrThrow(Registries.TRIM_PATTERN).holders().findFirst(); ++ + if (optional.isPresent()) { +- Optional<Holder.Reference<TrimMaterial>> holder = registryAccess.registryOrThrow(Registries.TRIM_MATERIAL).getHolder(TrimMaterials.REDSTONE); +- if (holder.isPresent()) { +- ArmorTrim armorTrim = new ArmorTrim(holder.get(), optional.get()); +- ArmorTrim.setTrim(registryAccess, itemStack, armorTrim); ++ Optional<Holder.Reference<TrimMaterial>> optional1 = registryAccess.registryOrThrow(Registries.TRIM_MATERIAL).getHolder(TrimMaterials.REDSTONE); ++ ++ if (optional1.isPresent()) { ++ ArmorTrim armortrim = new ArmorTrim((Holder) optional1.get(), (Holder) optional.get()); ++ ++ ArmorTrim.setTrim(registryAccess, itemstack, armortrim); + } + } + +- return itemStack; ++ return itemstack; + } + + @Override +@@ -99,34 +113,45 @@ + return Stream.of(this.template, this.base, this.addition).anyMatch(Ingredient::isEmpty); + } + +- public static class Serializer implements RecipeSerializer<SmithingTrimRecipe> { +- private static final Codec<SmithingTrimRecipe> CODEC = RecordCodecBuilder.create( +- instance -> instance.group( +- Ingredient.CODEC.fieldOf("template").forGetter(smithingTrimRecipe -> smithingTrimRecipe.template), +- Ingredient.CODEC.fieldOf("base").forGetter(smithingTrimRecipe -> smithingTrimRecipe.base), +- Ingredient.CODEC.fieldOf("addition").forGetter(smithingTrimRecipe -> smithingTrimRecipe.addition) +- ) +- .apply(instance, SmithingTrimRecipe::new) +- ); ++ // CraftBukkit start ++ @Override ++ public Recipe toBukkitRecipe(NamespacedKey id) { ++ return new CraftSmithingTrimRecipe(id, CraftRecipe.toBukkit(this.template), CraftRecipe.toBukkit(this.base), CraftRecipe.toBukkit(this.addition)); ++ } ++ // CraftBukkit end + ++ public static class a implements RecipeSerializer<SmithingTrimRecipe> { ++ ++ private static final Codec<SmithingTrimRecipe> CODEC = RecordCodecBuilder.create((instance) -> { ++ return instance.group(Ingredient.CODEC.fieldOf("template").forGetter((smithingtrimrecipe) -> { ++ return smithingtrimrecipe.template; ++ }), Ingredient.CODEC.fieldOf("base").forGetter((smithingtrimrecipe) -> { ++ return smithingtrimrecipe.base; ++ }), Ingredient.CODEC.fieldOf("addition").forGetter((smithingtrimrecipe) -> { ++ return smithingtrimrecipe.addition; ++ })).apply(instance, SmithingTrimRecipe::new); ++ }); ++ ++ public a() {} ++ + @Override + public Codec<SmithingTrimRecipe> codec() { +- return CODEC; ++ return SmithingTrimRecipe.a.CODEC; + } + + @Override +- public SmithingTrimRecipe fromNetwork(FriendlyByteBuf friendlyByteBuf) { +- Ingredient ingredient = Ingredient.fromNetwork(friendlyByteBuf); +- Ingredient ingredient1 = Ingredient.fromNetwork(friendlyByteBuf); +- Ingredient ingredient2 = Ingredient.fromNetwork(friendlyByteBuf); +- return new SmithingTrimRecipe(ingredient, ingredient1, ingredient2); ++ public SmithingTrimRecipe fromNetwork(FriendlyByteBuf packetdataserializer) { ++ Ingredient recipeitemstack = Ingredient.fromNetwork(packetdataserializer); ++ Ingredient recipeitemstack1 = Ingredient.fromNetwork(packetdataserializer); ++ Ingredient recipeitemstack2 = Ingredient.fromNetwork(packetdataserializer); ++ ++ return new SmithingTrimRecipe(recipeitemstack, recipeitemstack1, recipeitemstack2); + } + +- @Override +- public void toNetwork(FriendlyByteBuf buffer, SmithingTrimRecipe recipe) { +- recipe.template.toNetwork(buffer); +- recipe.base.toNetwork(buffer); +- recipe.addition.toNetwork(buffer); ++ public void toNetwork(FriendlyByteBuf packetdataserializer, SmithingTrimRecipe smithingtrimrecipe) { ++ smithingtrimrecipe.template.toNetwork(packetdataserializer); ++ smithingtrimrecipe.base.toNetwork(packetdataserializer); ++ smithingtrimrecipe.addition.toNetwork(packetdataserializer); + } + } + } |