From e2a8d0a0cf23277ea6964e53ca3c8d609602bea7 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Tue, 14 Mar 2023 20:09:54 +0100 Subject: [PATCH] recipes: armor trip recipes, decorated pot, fix network error (1.19.4) --- .../minosoft/recipes/RecipeFactories.kt | 13 +++--- .../minosoft/recipes/crafting/ShapedRecipe.kt | 1 + .../smithing/AbstractSmithingRecipe.kt | 24 +++++++++++ .../recipes/{ => smithing}/SmithingRecipe.kt | 13 +++--- .../smithing/SmithingTransformRecipe.kt | 43 +++++++++++++++++++ .../recipes/smithing/SmithingTrimRecipe.kt | 42 ++++++++++++++++++ .../recipes/special/DecoratedPotRecipe.kt | 30 +++++++++++++ 7 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 src/main/java/de/bixilon/minosoft/recipes/smithing/AbstractSmithingRecipe.kt rename src/main/java/de/bixilon/minosoft/recipes/{ => smithing}/SmithingRecipe.kt (81%) create mode 100644 src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTransformRecipe.kt create mode 100644 src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTrimRecipe.kt create mode 100644 src/main/java/de/bixilon/minosoft/recipes/special/DecoratedPotRecipe.kt diff --git a/src/main/java/de/bixilon/minosoft/recipes/RecipeFactories.kt b/src/main/java/de/bixilon/minosoft/recipes/RecipeFactories.kt index 562ed2241..f4f57a316 100644 --- a/src/main/java/de/bixilon/minosoft/recipes/RecipeFactories.kt +++ b/src/main/java/de/bixilon/minosoft/recipes/RecipeFactories.kt @@ -1,6 +1,6 @@ /* * Minosoft - * Copyright (C) 2020-2022 Moritz Zwerger + * Copyright (C) 2020-2023 Moritz Zwerger * * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * @@ -20,10 +20,10 @@ import de.bixilon.minosoft.recipes.heat.BlastingRecipe import de.bixilon.minosoft.recipes.heat.CampfireRecipe import de.bixilon.minosoft.recipes.heat.SmeltingRecipe import de.bixilon.minosoft.recipes.heat.SmokingRecipe -import de.bixilon.minosoft.recipes.special.BookCloningRecipe -import de.bixilon.minosoft.recipes.special.RepairItemRecipe -import de.bixilon.minosoft.recipes.special.SuspiciousStewRecipe -import de.bixilon.minosoft.recipes.special.TippedArrowRecipe +import de.bixilon.minosoft.recipes.smithing.SmithingRecipe +import de.bixilon.minosoft.recipes.smithing.SmithingTransformRecipe +import de.bixilon.minosoft.recipes.smithing.SmithingTrimRecipe +import de.bixilon.minosoft.recipes.special.* import de.bixilon.minosoft.recipes.special.banner.BannerDuplicateRecipe import de.bixilon.minosoft.recipes.special.banner.ShieldDecorationRecipe import de.bixilon.minosoft.recipes.special.color.ArmorDyeRecipe @@ -51,6 +51,7 @@ object RecipeFactories : DefaultFactory>( ShulkerBoxColoringRecipe, SuspiciousStewRecipe, RepairItemRecipe, + DecoratedPotRecipe, SmeltingRecipe, BlastingRecipe, @@ -58,5 +59,5 @@ object RecipeFactories : DefaultFactory>( CampfireRecipe, StoneCuttingRecipe, - SmithingRecipe, + SmithingRecipe, SmithingTransformRecipe, SmithingTrimRecipe, ) diff --git a/src/main/java/de/bixilon/minosoft/recipes/crafting/ShapedRecipe.kt b/src/main/java/de/bixilon/minosoft/recipes/crafting/ShapedRecipe.kt index 19184ecae..1703dc6dc 100644 --- a/src/main/java/de/bixilon/minosoft/recipes/crafting/ShapedRecipe.kt +++ b/src/main/java/de/bixilon/minosoft/recipes/crafting/ShapedRecipe.kt @@ -41,6 +41,7 @@ class ShapedRecipe( val category = if (buffer.versionId >= ProtocolVersions.V_22W42A) RecipeCategories[buffer.readVarInt()] else null val ingredients = buffer.readArray(width * height) { buffer.readIngredient() } val result = buffer.readItemStack() + val notification = if (buffer.versionId >= ProtocolVersions.V_1_19_4) buffer.readBoolean() else true // TODO: unknown version return ShapedRecipe( width = width, height = height, diff --git a/src/main/java/de/bixilon/minosoft/recipes/smithing/AbstractSmithingRecipe.kt b/src/main/java/de/bixilon/minosoft/recipes/smithing/AbstractSmithingRecipe.kt new file mode 100644 index 000000000..dd375dee6 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/recipes/smithing/AbstractSmithingRecipe.kt @@ -0,0 +1,24 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.recipes.smithing + +import de.bixilon.minosoft.data.container.stack.ItemStack +import de.bixilon.minosoft.recipes.Ingredient +import de.bixilon.minosoft.recipes.Recipe + +interface AbstractSmithingRecipe : Recipe { + val base: Ingredient + val ingredient: Ingredient + val result: ItemStack? +} diff --git a/src/main/java/de/bixilon/minosoft/recipes/SmithingRecipe.kt b/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingRecipe.kt similarity index 81% rename from src/main/java/de/bixilon/minosoft/recipes/SmithingRecipe.kt rename to src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingRecipe.kt index a5ad09a35..cacac5ae4 100644 --- a/src/main/java/de/bixilon/minosoft/recipes/SmithingRecipe.kt +++ b/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingRecipe.kt @@ -11,17 +11,20 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.recipes +package de.bixilon.minosoft.recipes.smithing import de.bixilon.minosoft.data.container.stack.ItemStack import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer +import de.bixilon.minosoft.recipes.Ingredient +import de.bixilon.minosoft.recipes.RecipeCategories +import de.bixilon.minosoft.recipes.RecipeFactory import de.bixilon.minosoft.util.KUtil.toResourceLocation class SmithingRecipe( - val base: Ingredient, - val ingredient: Ingredient, - val result: ItemStack?, -) : Recipe { + override val base: Ingredient, + override val ingredient: Ingredient, + override val result: ItemStack?, +) : AbstractSmithingRecipe { override val category: RecipeCategories? get() = null companion object : RecipeFactory { diff --git a/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTransformRecipe.kt b/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTransformRecipe.kt new file mode 100644 index 000000000..8741630b6 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTransformRecipe.kt @@ -0,0 +1,43 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.recipes.smithing + +import de.bixilon.minosoft.data.container.stack.ItemStack +import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft +import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer +import de.bixilon.minosoft.recipes.Ingredient +import de.bixilon.minosoft.recipes.RecipeCategories +import de.bixilon.minosoft.recipes.RecipeFactory + +class SmithingTransformRecipe( + val template: Ingredient, + override val base: Ingredient, + override val ingredient: Ingredient, + override val result: ItemStack?, +) : AbstractSmithingRecipe { + override val category: RecipeCategories? get() = null + + companion object : RecipeFactory { + override val identifier = minecraft("smithing_transform") + + override fun build(buffer: PlayInByteBuffer): SmithingTransformRecipe { + return SmithingTransformRecipe( + template = buffer.readIngredient(), + base = buffer.readIngredient(), + ingredient = buffer.readIngredient(), + result = buffer.readItemStack(), + ) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTrimRecipe.kt b/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTrimRecipe.kt new file mode 100644 index 000000000..8f903bbb4 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/recipes/smithing/SmithingTrimRecipe.kt @@ -0,0 +1,42 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.recipes.smithing + +import de.bixilon.minosoft.data.container.stack.ItemStack +import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft +import de.bixilon.minosoft.protocol.protocol.buffers.play.PlayInByteBuffer +import de.bixilon.minosoft.recipes.Ingredient +import de.bixilon.minosoft.recipes.RecipeCategories +import de.bixilon.minosoft.recipes.RecipeFactory + +class SmithingTrimRecipe( + val template: Ingredient, + override val base: Ingredient, + override val ingredient: Ingredient, +) : AbstractSmithingRecipe { + override val result: ItemStack? get() = null // TODO + override val category: RecipeCategories? get() = null + + companion object : RecipeFactory { + override val identifier = minecraft("smithing_trim") + + override fun build(buffer: PlayInByteBuffer): SmithingTrimRecipe { + return SmithingTrimRecipe( + template = buffer.readIngredient(), + base = buffer.readIngredient(), + ingredient = buffer.readIngredient(), + ) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/recipes/special/DecoratedPotRecipe.kt b/src/main/java/de/bixilon/minosoft/recipes/special/DecoratedPotRecipe.kt new file mode 100644 index 000000000..64e5dd2de --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/recipes/special/DecoratedPotRecipe.kt @@ -0,0 +1,30 @@ +/* + * Minosoft + * Copyright (C) 2020-2023 Moritz Zwerger + * + * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with this program. If not, see . + * + * This software is not affiliated with Mojang AB, the original developer of Minecraft. + */ + +package de.bixilon.minosoft.recipes.special + +import de.bixilon.minosoft.data.registries.identified.Namespaces.minecraft +import de.bixilon.minosoft.recipes.RecipeCategories + +class DecoratedPotRecipe( + override val category: RecipeCategories?, +) : SpecialRecipe { + + companion object : SpecialRecipeFactory { + override val identifier = minecraft("crafting_decorated_pot") + + override fun build(category: RecipeCategories?): DecoratedPotRecipe { + return DecoratedPotRecipe(category) + } + } +}