diff --git a/docker b/docker index aea36d6a1..38cb74777 160000 --- a/docker +++ b/docker @@ -1 +1 @@ -Subproject commit aea36d6a1c40625e6147202d6964e27c50d277cc +Subproject commit 38cb74777a16eaab089773e024f00065f6ad25e6 diff --git a/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_PlayerManager.java b/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_PlayerManager.java deleted file mode 100644 index ed492fc2a..000000000 --- a/src/main/java/one/oktw/galaxy/mixin/recipe/MixinCustomRecipe_PlayerManager.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.mixin.recipe; - -import net.minecraft.recipe.RecipeEntry; -import net.minecraft.recipe.RecipeManager; -import net.minecraft.server.PlayerManager; -import one.oktw.galaxy.mixin.interfaces.CustomRecipeManager; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import java.util.Collection; - -@Mixin(PlayerManager.class) -public class MixinCustomRecipe_PlayerManager { - // TODO Client mod - - @Redirect(method = "onPlayerConnect", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeManager;values()Ljava/util/Collection;")) - private Collection> skipSendRecipe(RecipeManager recipeManager) { - Collection> recipes = recipeManager.values(); - recipes.removeAll(CustomRecipeManager.customRecipes.values().stream().flatMap(i -> i.values().stream()).toList()); - return recipes; - } - - @Redirect(method = "onDataPacksReloaded", at = @At(value = "INVOKE", target = "Lnet/minecraft/recipe/RecipeManager;values()Ljava/util/Collection;")) - private Collection> skipSyncRecipe(RecipeManager recipeManager) { - Collection> recipes = recipeManager.values(); - recipes.removeAll(CustomRecipeManager.customRecipes.values().stream().flatMap(i -> i.values().stream()).toList()); - return recipes; - } -} diff --git a/src/main/java/one/oktw/galaxy/mixin/tweak/MixinGlobalDataPack_VanillaDataPackProvider.java b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinGlobalDataPack_VanillaDataPackProvider.java new file mode 100644 index 000000000..4f195a4d3 --- /dev/null +++ b/src/main/java/one/oktw/galaxy/mixin/tweak/MixinGlobalDataPack_VanillaDataPackProvider.java @@ -0,0 +1,34 @@ +/* + * OKTW Galaxy Project + * Copyright (C) 2018-2024 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published + * by the Free Software Foundation, either version 3 of the License, or + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package one.oktw.galaxy.mixin.tweak; + +import net.minecraft.resource.VanillaDataPackProvider; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyArg; + +import java.nio.file.Path; + +@Mixin(VanillaDataPackProvider.class) +public class MixinGlobalDataPack_VanillaDataPackProvider { + @ModifyArg(method = "createManager(Lnet/minecraft/world/level/storage/LevelStorage$Session;)Lnet/minecraft/resource/ResourcePackManager;", at = @At(value = "INVOKE", target = "Lnet/minecraft/resource/VanillaDataPackProvider;createManager(Ljava/nio/file/Path;Lnet/minecraft/util/path/SymlinkFinder;)Lnet/minecraft/resource/ResourcePackManager;"), index = 0) + private static Path moveDataPackPath(Path dataPacksPath) { + return Path.of("datapacks"); + } +} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt b/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt index 553276610..f3d99aeb9 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/RecipeRegistry.kt @@ -25,7 +25,6 @@ import one.oktw.galaxy.recipe.blocks.Elevator import one.oktw.galaxy.recipe.blocks.HTCraftingTable import one.oktw.galaxy.recipe.blocks.Harvest import one.oktw.galaxy.recipe.blocks.Trashcan -import one.oktw.galaxy.recipe.easyRecipe.* import one.oktw.galaxy.recipe.materials.CeramicPlate import one.oktw.galaxy.recipe.tools.Crowbar import one.oktw.galaxy.recipe.tools.Wrench @@ -40,26 +39,5 @@ object RecipeRegistry { CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "block/harvest"), Harvest()) CustomRecipeManager.addRecipe(RecipeType.SMELTING, Identifier("galaxy", "material/ceramic_plate"), CeramicPlate()) CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "block/trashcan"), Trashcan()) - // Easy Recipe - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/ladder"), Ladder()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/chest"), Chest()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/hopper"), Hopper()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/redstone_lamp"), RedStoneLamp()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/dispenser"), Dispenser()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/dispenser_with_bow"), DispenserWithBow()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/redstone_repeater"), RedStoneRepeater()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/trapped_chest"), TrappedChest()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/carrot_on_a_stick"), CarrotOnAStick()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/warped_fungus_on_a_stick"), WarpedFungusOnAStick()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/writable_book"), BookAndQuill()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/minecart"), Minecart()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/stick"), Stick()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/glass"), Glass()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/glass_pane"), GlassPane()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/glass_pane_restore"), GlassPaneRestore()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/stained_glass_restore"), StainedGlassRestore()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/stained_glass_pane_restore"), StainedGlassPaneRestore()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/wood_slab"), WoodenSlab()) - CustomRecipeManager.addRecipe(RecipeType.CRAFTING, Identifier("galaxy", "easy_recipe/slab_restore"), SlabRestore()) } } diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt index 73ccb96c3..4bd05b828 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Elevator.kt @@ -18,38 +18,16 @@ package one.oktw.galaxy.recipe.blocks -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.Ingredient +import net.minecraft.recipe.ShapelessRecipe import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World +import net.minecraft.util.collection.DefaultedList import one.oktw.galaxy.item.CustomBlockItem -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils -class Elevator : CraftingRecipe { - private val item = CustomBlockItem.ELEVATOR.createItemStack() - private val list = - listOf(Ingredient(items = listOf(Items.ENDER_PEARL)), Ingredient(items = listOf(Items.IRON_BLOCK))) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapelessMatches(inv, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} +class Elevator : ShapelessRecipe( + "", + CraftingRecipeCategory.EQUIPMENT, + CustomBlockItem.ELEVATOR.createItemStack(), + DefaultedList.copyOf(Ingredient.EMPTY, Ingredient.ofItems(Items.ENDER_PEARL), Ingredient.ofItems(Items.IRON_BLOCK)) +) diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt index d166420d0..cfb645ed6 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/HTCraftingTable.kt @@ -18,48 +18,28 @@ package one.oktw.galaxy.recipe.blocks -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.Ingredient +import net.minecraft.recipe.RawShapedRecipe +import net.minecraft.recipe.ShapedRecipe import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World import one.oktw.galaxy.item.CustomBlockItem -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils -class HTCraftingTable : CraftingRecipe { - private val item = CustomBlockItem.HT_CRAFTING_TABLE.createItemStack() - - private val redStone = Ingredient(items = listOf(Items.REDSTONE)) - private val diamond = Ingredient(items = listOf(Items.DIAMOND)) - private val lapisLazuli = Ingredient(items = listOf(Items.LAPIS_LAZULI)) - private val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT)) - private val obsidian = Ingredient(items = listOf(Items.OBSIDIAN)) - private val craftingTable = Ingredient(items = listOf(Items.CRAFTING_TABLE)) - private val list = listOf( - redStone, diamond, lapisLazuli, - ironIngot, craftingTable, ironIngot, - lapisLazuli, obsidian, redStone - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inventory: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} +class HTCraftingTable : ShapedRecipe( + "", + CraftingRecipeCategory.BUILDING, + RawShapedRecipe.create( + mapOf( + Character.valueOf('r') to Ingredient.ofItems(Items.REDSTONE), + Character.valueOf('d') to Ingredient.ofItems(Items.DIAMOND), + Character.valueOf('l') to Ingredient.ofItems(Items.LAPIS_LAZULI), + Character.valueOf('i') to Ingredient.ofItems(Items.IRON_INGOT), + Character.valueOf('c') to Ingredient.ofItems(Items.CRAFTING_TABLE), + Character.valueOf('o') to Ingredient.ofItems(Items.OBSIDIAN), + ), + "rdl", + "ici", + "lor" + ), + CustomBlockItem.HT_CRAFTING_TABLE.createItemStack() +) diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt index 843e800e9..d1d1aec3a 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Harvest.kt @@ -18,46 +18,25 @@ package one.oktw.galaxy.recipe.blocks -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.Ingredient.ofItems +import net.minecraft.recipe.RawShapedRecipe +import net.minecraft.recipe.ShapedRecipe import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World import one.oktw.galaxy.item.CustomBlockItem -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils -class Harvest : CraftingRecipe { - private val item = CustomBlockItem.HARVEST.createItemStack() - - private val copper = Ingredient(items = listOf(Items.COPPER_INGOT)) - private val observer = Ingredient(items = listOf(Items.OBSERVER)) - private val dispenser = Ingredient(items = listOf(Items.DISPENSER)) - private val list = listOf( - copper, copper, copper, - copper, dispenser, observer, - copper, copper, copper - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inventory: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not implemented client mod") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} +class Harvest : ShapedRecipe( + "", + CraftingRecipeCategory.BUILDING, + RawShapedRecipe.create( + mapOf( + Character.valueOf('c') to ofItems(Items.COPPER_INGOT), + Character.valueOf('o') to ofItems(Items.OBSERVER), + Character.valueOf('d') to ofItems(Items.DISPENSER), + ), + "ccc", + "cdo", + "ccc" + ), + CustomBlockItem.HARVEST.createItemStack() +) diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt index 6e7f693d4..2204f2215 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/blocks/Trashcan.kt @@ -18,46 +18,26 @@ package one.oktw.galaxy.recipe.blocks -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.Ingredient.ofItems +import net.minecraft.recipe.RawShapedRecipe +import net.minecraft.recipe.ShapedRecipe import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World import one.oktw.galaxy.item.CustomBlockItem -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils -class Trashcan : CraftingRecipe { - private val item = CustomBlockItem.TRASHCAN.createItemStack() - - private val glass = Ingredient(items = listOf(Items.GLASS)) - private val cactus = Ingredient(items = listOf(Items.CACTUS)) - private val terracotta = Ingredient(items = listOf(Items.TERRACOTTA)) - private val sand = Ingredient(items = listOf(Items.SAND, Items.RED_SAND)) - private val list = listOf( - glass, glass, glass, - glass, cactus, glass, - terracotta, sand, terracotta - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inventory: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.MISC -} +class Trashcan : ShapedRecipe( + "", + CraftingRecipeCategory.BUILDING, + RawShapedRecipe.create( + mapOf( + Character.valueOf('g') to ofItems(Items.GLASS), + Character.valueOf('c') to ofItems(Items.CACTUS), + Character.valueOf('t') to ofItems(Items.TERRACOTTA), + Character.valueOf('s') to ofItems(Items.SAND, Items.RED_SAND) + ), + "ggg", + "gcg", + "tst" + ), + CustomBlockItem.TRASHCAN.createItemStack() +) diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/BookAndQuill.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/BookAndQuill.kt deleted file mode 100644 index d6bca9365..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/BookAndQuill.kt +++ /dev/null @@ -1,58 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class BookAndQuill : CraftingRecipe { - private val item = Items.WRITABLE_BOOK.defaultStack - - private val paper = Ingredient(items = listOf(Items.PAPER)) - private val leather = Ingredient(items = listOf(Items.LEATHER)) - private val feather = Ingredient(items = listOf(Items.FEATHER)) - private val inkSac = Ingredient(items = listOf(Items.INK_SAC)) - private val list = listOf(paper, paper, paper, leather, feather, inkSac) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapelessMatches(inv, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/CarrotOnAStick.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/CarrotOnAStick.kt deleted file mode 100644 index d134967ce..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/CarrotOnAStick.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class CarrotOnAStick : CraftingRecipe { - private val item = Items.CARROT_ON_A_STICK.defaultStack!! - - private val air = Ingredient(items = listOf(Items.AIR)) - private val stick = Ingredient(items = listOf(Items.STICK)) - private val strings = Ingredient(items = listOf(Items.STRING)) - private val carrot = Ingredient(items = listOf(Items.CARROT)) - private val listLeft = listOf( - stick, air, air, - strings, stick, air, - strings, carrot, stick - ) - private val listRight = listOf( - air, air, stick, - air, stick, strings, - stick, carrot, strings - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = - (RecipeUtils.isItemShapedMatches(inv, 3, 3, listLeft) || RecipeUtils.isItemShapedMatches(inv, 3, 3, listRight)) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.MISC -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Chest.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Chest.kt deleted file mode 100644 index 07ccf48a9..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Chest.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.registry.tag.ItemTags -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Chest : CraftingRecipe { - private val item = Items.CHEST.defaultStack.apply { this.count = 4 } - - private val logs = Ingredient(tag = ItemTags.LOGS) - private val air = Ingredient(items = listOf(Items.AIR)) - private val list = listOf( - logs, logs, logs, - logs, air, logs, - logs, logs, logs - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Dispenser.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Dispenser.kt deleted file mode 100644 index 3a94b80e6..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Dispenser.kt +++ /dev/null @@ -1,54 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Dispenser : CraftingRecipe { - private val item = Items.DISPENSER.defaultStack - private val list = - listOf(Ingredient(items = listOf(Items.BOW)), Ingredient(items = listOf(Items.DROPPER))) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapelessMatches(inv, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/DispenserWithBow.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/DispenserWithBow.kt deleted file mode 100644 index b7b7cd4b6..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/DispenserWithBow.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class DispenserWithBow : CraftingRecipe { - private val item = Items.DISPENSER.defaultStack - - private val air = Ingredient(items = listOf(Items.AIR)) - private val stick = Ingredient(items = listOf(Items.STICK)) - private val strings = Ingredient(items = listOf(Items.STRING)) - private val dropper = Ingredient(items = listOf(Items.DROPPER)) - private val listLeft = listOf( - air, stick, strings, - stick, dropper, strings, - air, stick, strings - ) - private val listRight = listOf( - strings, stick, air, - strings, dropper, stick, - strings, stick, air - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = - (RecipeUtils.isItemShapedMatches(inv, 3, 3, listLeft) || RecipeUtils.isItemShapedMatches(inv, 3, 3, listRight)) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Glass.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Glass.kt deleted file mode 100644 index aae805dae..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Glass.kt +++ /dev/null @@ -1,121 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Glass : CraftingRecipe { - private val dyes = hashMapOf( - Items.RED_DYE to Items.RED_STAINED_GLASS, - Items.GREEN_DYE to Items.GREEN_STAINED_GLASS, - Items.PURPLE_DYE to Items.PURPLE_STAINED_GLASS, - Items.CYAN_DYE to Items.CYAN_STAINED_GLASS, - Items.LIGHT_GRAY_DYE to Items.LIGHT_GRAY_STAINED_GLASS, - Items.GRAY_DYE to Items.GRAY_STAINED_GLASS, - Items.PINK_DYE to Items.PINK_STAINED_GLASS, - Items.LIME_DYE to Items.LIME_STAINED_GLASS, - Items.YELLOW_DYE to Items.YELLOW_STAINED_GLASS, - Items.LIGHT_BLUE_DYE to Items.LIGHT_BLUE_STAINED_GLASS, - Items.MAGENTA_DYE to Items.MAGENTA_STAINED_GLASS, - Items.ORANGE_DYE to Items.ORANGE_STAINED_GLASS, - Items.BLACK_DYE to Items.BLACK_STAINED_GLASS, - Items.BROWN_DYE to Items.BROWN_STAINED_GLASS, - Items.BLUE_DYE to Items.BLUE_STAINED_GLASS, - Items.WHITE_DYE to Items.WHITE_STAINED_GLASS - ) - - private val stainedGlass = listOf( - Items.WHITE_STAINED_GLASS, - Items.ORANGE_STAINED_GLASS, - Items.MAGENTA_STAINED_GLASS, - Items.LIGHT_BLUE_STAINED_GLASS, - Items.YELLOW_STAINED_GLASS, - Items.LIME_STAINED_GLASS, - Items.PINK_STAINED_GLASS, - Items.GRAY_STAINED_GLASS, - Items.LIGHT_GRAY_STAINED_GLASS, - Items.CYAN_STAINED_GLASS, - Items.PURPLE_STAINED_GLASS, - Items.BLUE_STAINED_GLASS, - Items.BROWN_STAINED_GLASS, - Items.GREEN_STAINED_GLASS, - Items.RED_STAINED_GLASS, - Items.BLACK_STAINED_GLASS - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - dyes.forEach { (recipeItem, _) -> - val stainedGlass = Ingredient(items = stainedGlass) - val dye = Ingredient(items = listOf(recipeItem)) - val list = listOf( - stainedGlass, stainedGlass, stainedGlass, - stainedGlass, dye, stainedGlass, - stainedGlass, stainedGlass, stainedGlass, - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 3, list)) { - match = true - return@forEach - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - dyes.forEach { (recipeItem, result) -> - val stainedGlass = Ingredient(items = stainedGlass) - val dye = Ingredient(items = listOf(recipeItem)) - val list = listOf( - stainedGlass, stainedGlass, stainedGlass, - stainedGlass, dye, stainedGlass, - stainedGlass, stainedGlass, stainedGlass, - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 3, list)) { - item = result.defaultStack.apply { this.count = 8 } - return@forEach - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.GLASS.defaultStack.apply { this.count = 8 } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/GlassPane.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/GlassPane.kt deleted file mode 100644 index 7bcefba54..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/GlassPane.kt +++ /dev/null @@ -1,121 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class GlassPane : CraftingRecipe { - private val dyes = hashMapOf( - Items.RED_DYE to Items.RED_STAINED_GLASS_PANE, - Items.GREEN_DYE to Items.GREEN_STAINED_GLASS_PANE, - Items.PURPLE_DYE to Items.PURPLE_STAINED_GLASS_PANE, - Items.CYAN_DYE to Items.CYAN_STAINED_GLASS_PANE, - Items.LIGHT_GRAY_DYE to Items.LIGHT_GRAY_STAINED_GLASS_PANE, - Items.GRAY_DYE to Items.GRAY_STAINED_GLASS_PANE, - Items.PINK_DYE to Items.PINK_STAINED_GLASS_PANE, - Items.LIME_DYE to Items.LIME_STAINED_GLASS_PANE, - Items.YELLOW_DYE to Items.YELLOW_STAINED_GLASS_PANE, - Items.LIGHT_BLUE_DYE to Items.LIGHT_BLUE_STAINED_GLASS_PANE, - Items.MAGENTA_DYE to Items.MAGENTA_STAINED_GLASS_PANE, - Items.ORANGE_DYE to Items.ORANGE_STAINED_GLASS_PANE, - Items.BLACK_DYE to Items.BLACK_STAINED_GLASS_PANE, - Items.BROWN_DYE to Items.BROWN_STAINED_GLASS_PANE, - Items.BLUE_DYE to Items.BLUE_STAINED_GLASS_PANE, - Items.WHITE_DYE to Items.WHITE_STAINED_GLASS_PANE - ) - - private val stainedGlassPane = listOf( - Items.WHITE_STAINED_GLASS_PANE, - Items.ORANGE_STAINED_GLASS_PANE, - Items.MAGENTA_STAINED_GLASS_PANE, - Items.LIGHT_BLUE_STAINED_GLASS_PANE, - Items.YELLOW_STAINED_GLASS_PANE, - Items.LIME_STAINED_GLASS_PANE, - Items.PINK_STAINED_GLASS_PANE, - Items.GRAY_STAINED_GLASS_PANE, - Items.LIGHT_GRAY_STAINED_GLASS_PANE, - Items.CYAN_STAINED_GLASS_PANE, - Items.PURPLE_STAINED_GLASS_PANE, - Items.BLUE_STAINED_GLASS_PANE, - Items.BROWN_STAINED_GLASS_PANE, - Items.GREEN_STAINED_GLASS_PANE, - Items.RED_STAINED_GLASS_PANE, - Items.BLACK_STAINED_GLASS_PANE - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - dyes.forEach { (recipeItem, _) -> - val glassPane = Ingredient(items = stainedGlassPane) - val dye = Ingredient(items = listOf(recipeItem)) - val list = listOf( - glassPane, glassPane, glassPane, - glassPane, dye, glassPane, - glassPane, glassPane, glassPane, - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 3, list)) { - match = true - return@forEach - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - dyes.forEach { (recipeItem, result) -> - val glassPane = Ingredient(items = stainedGlassPane) - val dye = Ingredient(items = listOf(recipeItem)) - val list = listOf( - glassPane, glassPane, glassPane, - glassPane, dye, glassPane, - glassPane, glassPane, glassPane, - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 3, list)) { - item = result.defaultStack.apply { this.count = 8 } - return@forEach - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.GLASS_PANE.defaultStack.apply { this.count = 8 } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/GlassPaneRestore.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/GlassPaneRestore.kt deleted file mode 100644 index 56ce0c563..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/GlassPaneRestore.kt +++ /dev/null @@ -1,101 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class GlassPaneRestore : CraftingRecipe { - private val glassPane = hashMapOf( - Items.GLASS_PANE to Items.GLASS, - Items.RED_STAINED_GLASS_PANE to Items.RED_STAINED_GLASS, - Items.GREEN_STAINED_GLASS_PANE to Items.GREEN_STAINED_GLASS, - Items.PURPLE_STAINED_GLASS_PANE to Items.PURPLE_STAINED_GLASS, - Items.CYAN_STAINED_GLASS_PANE to Items.CYAN_STAINED_GLASS, - Items.LIGHT_GRAY_STAINED_GLASS_PANE to Items.LIGHT_GRAY_STAINED_GLASS, - Items.GRAY_STAINED_GLASS_PANE to Items.GRAY_STAINED_GLASS, - Items.PINK_STAINED_GLASS_PANE to Items.PINK_STAINED_GLASS, - Items.LIME_STAINED_GLASS_PANE to Items.LIME_STAINED_GLASS, - Items.YELLOW_STAINED_GLASS_PANE to Items.YELLOW_STAINED_GLASS, - Items.LIGHT_BLUE_STAINED_GLASS_PANE to Items.LIGHT_BLUE_STAINED_GLASS, - Items.MAGENTA_STAINED_GLASS_PANE to Items.MAGENTA_STAINED_GLASS, - Items.ORANGE_STAINED_GLASS_PANE to Items.ORANGE_STAINED_GLASS, - Items.BLACK_STAINED_GLASS_PANE to Items.BLACK_STAINED_GLASS, - Items.BROWN_STAINED_GLASS_PANE to Items.BROWN_STAINED_GLASS, - Items.BLUE_STAINED_GLASS_PANE to Items.BLUE_STAINED_GLASS, - Items.WHITE_STAINED_GLASS_PANE to Items.WHITE_STAINED_GLASS - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - glassPane.forEach { (recipeItem, _) -> - val glassPane = Ingredient(items = listOf(recipeItem)) - val list = listOf( - glassPane, glassPane, - glassPane, glassPane, glassPane, - glassPane, glassPane, glassPane, - ) - if (RecipeUtils.isItemShapelessMatches(inv, list)) { - match = true - return@forEach - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - glassPane.forEach { (recipeItem, result) -> - val glassPane = Ingredient(items = listOf(recipeItem)) - val list = listOf( - glassPane, glassPane, - glassPane, glassPane, glassPane, - glassPane, glassPane, glassPane, - ) - if (RecipeUtils.isItemShapelessMatches(inv, list)) { - item = result.defaultStack.apply { this.count = 3 } - return@forEach - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.GLASS_PANE.defaultStack.apply { this.count = 3 } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Hopper.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Hopper.kt deleted file mode 100644 index b907193db..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Hopper.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.registry.tag.ItemTags -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Hopper : CraftingRecipe { - private val item = Items.HOPPER.defaultStack - - private val air = Ingredient(items = listOf(Items.AIR)) - private val logs = Ingredient(tag = ItemTags.LOGS) - private val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT)) - private val list = listOf( - ironIngot, logs, ironIngot, - ironIngot, logs, ironIngot, - air, ironIngot, air - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Ladder.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Ladder.kt deleted file mode 100644 index 233e27640..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Ladder.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.registry.tag.ItemTags -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Ladder : CraftingRecipe { - private val item = Items.LADDER.defaultStack.apply { this.count = 24 } - - private val air = Ingredient(items = listOf(Items.AIR)) - private val logs = Ingredient(tag = ItemTags.LOGS) - private val list = listOf( - logs, air, logs, - logs, logs, logs, - logs, air, logs - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.MISC -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Minecart.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Minecart.kt deleted file mode 100644 index e7919744d..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Minecart.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Minecart : CraftingRecipe { - private val minecartType = hashMapOf( - Items.CHEST to Items.CHEST_MINECART, - Items.FURNACE to Items.FURNACE_MINECART, - Items.HOPPER to Items.HOPPER_MINECART, - Items.TNT to Items.TNT_MINECART - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - minecartType.forEach { (recipeItem, _) -> - val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT)) - val type = Ingredient(items = listOf(recipeItem)) - val list = listOf( - ironIngot, type, ironIngot, - ironIngot, ironIngot, ironIngot - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 2, list)) { - match = true - return@forEach - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - minecartType.forEach { (recipeItem, result) -> - val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT)) - val type = Ingredient(items = listOf(recipeItem)) - val list = listOf( - ironIngot, type, ironIngot, - ironIngot, ironIngot, ironIngot - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 2, list)) { - item = result.defaultStack - return@forEach - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.MINECART.defaultStack - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.MISC -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/RedStoneLamp.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/RedStoneLamp.kt deleted file mode 100644 index 6e6140250..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/RedStoneLamp.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class RedStoneLamp : CraftingRecipe { - private val item = Items.REDSTONE_LAMP.defaultStack - - private val air = Ingredient(items = listOf(Items.AIR)) - private val redStone = Ingredient(items = listOf(Items.REDSTONE)) - private val glowStoneDust = Ingredient(items = listOf(Items.GLOWSTONE_DUST)) - private val list = listOf( - redStone, glowStoneDust, redStone, - glowStoneDust, air, glowStoneDust, - redStone, glowStoneDust, redStone - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/RedStoneRepeater.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/RedStoneRepeater.kt deleted file mode 100644 index 8e1c91273..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/RedStoneRepeater.kt +++ /dev/null @@ -1,79 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class RedStoneRepeater : CraftingRecipe { - private val item = Items.REPEATER.defaultStack - - private val air = Ingredient(items = listOf(Items.AIR)) - private val redStone = Ingredient(items = listOf(Items.REDSTONE)) - private val redStoneTorch = Ingredient(items = listOf(Items.REDSTONE_TORCH)) - private val stick = Ingredient(items = listOf(Items.STICK)) - private val stone = Ingredient(items = listOf(Items.STONE)) - private val noTorch = listOf( - redStone, air, redStone, - stick, redStone, stick, - stone, stone, stone - ) - private val oneTorchLeft = listOf( - air, air, redStone, - redStoneTorch, redStone, stick, - stone, stone, stone - ) - private val oneTorchRight = listOf( - redStone, air, air, - stick, redStone, redStoneTorch, - stone, stone, stone - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = - (RecipeUtils.isItemShapedMatches(inv, 3, 3, noTorch) || RecipeUtils.isItemShapedMatches(inv, 3, 3, oneTorchLeft) || RecipeUtils.isItemShapedMatches( - inv, - 3, - 3, - oneTorchRight - )) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/SlabRestore.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/SlabRestore.kt deleted file mode 100644 index 759f2db16..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/SlabRestore.kt +++ /dev/null @@ -1,129 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class SlabRestore : CraftingRecipe { - private val slabs = hashMapOf( - Items.CUT_COPPER_SLAB to Items.CUT_COPPER, - Items.EXPOSED_CUT_COPPER_SLAB to Items.EXPOSED_CUT_COPPER, - Items.WEATHERED_CUT_COPPER_SLAB to Items.WEATHERED_CUT_COPPER, - Items.OXIDIZED_CUT_COPPER_SLAB to Items.OXIDIZED_CUT_COPPER, - Items.WAXED_CUT_COPPER_SLAB to Items.WAXED_CUT_COPPER, - Items.WAXED_EXPOSED_CUT_COPPER_SLAB to Items.WAXED_EXPOSED_CUT_COPPER, - Items.WAXED_WEATHERED_CUT_COPPER_SLAB to Items.WAXED_WEATHERED_COPPER, - Items.WAXED_OXIDIZED_CUT_COPPER_SLAB to Items.WAXED_OXIDIZED_CUT_COPPER, - Items.OAK_SLAB to Items.OAK_PLANKS, - Items.SPRUCE_SLAB to Items.SPRUCE_PLANKS, - Items.BIRCH_SLAB to Items.BIRCH_PLANKS, - Items.JUNGLE_SLAB to Items.JUNGLE_PLANKS, - Items.ACACIA_SLAB to Items.ACACIA_PLANKS, - Items.DARK_OAK_SLAB to Items.DARK_OAK_PLANKS, - Items.CRIMSON_SLAB to Items.CRIMSON_PLANKS, - Items.WARPED_SLAB to Items.WARPED_PLANKS, - Items.STONE_SLAB to Items.STONE, - Items.SMOOTH_STONE_SLAB to Items.SMOOTH_STONE, - Items.SANDSTONE_SLAB to Items.SANDSTONE, - Items.CUT_SANDSTONE_SLAB to Items.CUT_SANDSTONE, - Items.COBBLESTONE_SLAB to Items.COBBLESTONE, - Items.BRICK_SLAB to Items.BRICKS, - Items.STONE_BRICK_SLAB to Items.STONE_BRICKS, - Items.NETHER_BRICK_SLAB to Items.NETHER_BRICKS, - Items.QUARTZ_SLAB to Items.QUARTZ_BLOCK, - Items.RED_SANDSTONE_SLAB to Items.RED_SANDSTONE, - Items.CUT_RED_SANDSTONE_SLAB to Items.CUT_RED_SANDSTONE, - Items.PURPUR_SLAB to Items.PURPUR_BLOCK, - Items.PRISMARINE_SLAB to Items.PRISMARINE, - Items.PRISMARINE_BRICK_SLAB to Items.PRISMARINE_BRICKS, - Items.DARK_PRISMARINE_SLAB to Items.DARK_PRISMARINE, - Items.POLISHED_GRANITE_SLAB to Items.POLISHED_GRANITE, - Items.SMOOTH_RED_SANDSTONE_SLAB to Items.SMOOTH_RED_SANDSTONE, - Items.MOSSY_STONE_BRICK_SLAB to Items.MOSSY_STONE_BRICKS, - Items.POLISHED_DIORITE_SLAB to Items.POLISHED_DIORITE, - Items.MOSSY_COBBLESTONE_SLAB to Items.MOSSY_COBBLESTONE, - Items.END_STONE_BRICK_SLAB to Items.END_STONE_BRICKS, - Items.SMOOTH_SANDSTONE_SLAB to Items.SMOOTH_SANDSTONE, - Items.SMOOTH_QUARTZ_SLAB to Items.SMOOTH_QUARTZ, - Items.GRANITE_SLAB to Items.GRANITE, - Items.ANDESITE_SLAB to Items.ANDESITE, - Items.RED_NETHER_BRICK_SLAB to Items.RED_NETHER_BRICKS, - Items.POLISHED_ANDESITE_SLAB to Items.POLISHED_ANDESITE, - Items.DIORITE_SLAB to Items.DIORITE, - Items.COBBLED_DEEPSLATE_SLAB to Items.COBBLED_DEEPSLATE, - Items.POLISHED_DEEPSLATE_SLAB to Items.POLISHED_DEEPSLATE, - Items.DEEPSLATE_BRICK_SLAB to Items.DEEPSLATE_BRICKS, - Items.DEEPSLATE_TILE_SLAB to Items.DEEPSLATE_TILES, - Items.BLACKSTONE_SLAB to Items.BLACKSTONE, - Items.POLISHED_BLACKSTONE_SLAB to Items.POLISHED_BLACKSTONE, - Items.POLISHED_BLACKSTONE_BRICK_SLAB to Items.POLISHED_BLACKSTONE_BRICKS - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - slabs.forEach { (recipeItem, _) -> - val list = listOf( - Ingredient(items = listOf(recipeItem)), Ingredient(items = listOf(recipeItem)) - ) - if (RecipeUtils.isItemShapedMatches(inv, 2, 1, list)) { - match = true - return@forEach - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - slabs.forEach { (recipeItem, result) -> - val list = listOf( - Ingredient(items = listOf(recipeItem)), Ingredient(items = listOf(recipeItem)) - ) - if (RecipeUtils.isItemShapedMatches(inv, 2, 1, list)) { - item = result.defaultStack - return@forEach - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.OAK_PLANKS.defaultStack - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/StainedGlassPaneRestore.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/StainedGlassPaneRestore.kt deleted file mode 100644 index 569e8cbc1..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/StainedGlassPaneRestore.kt +++ /dev/null @@ -1,110 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class StainedGlassPaneRestore : CraftingRecipe { - private val stainedGlassPane = listOf( - Items.WHITE_STAINED_GLASS_PANE, - Items.ORANGE_STAINED_GLASS_PANE, - Items.MAGENTA_STAINED_GLASS_PANE, - Items.LIGHT_BLUE_STAINED_GLASS_PANE, - Items.YELLOW_STAINED_GLASS_PANE, - Items.LIME_STAINED_GLASS_PANE, - Items.PINK_STAINED_GLASS_PANE, - Items.GRAY_STAINED_GLASS_PANE, - Items.LIGHT_GRAY_STAINED_GLASS_PANE, - Items.CYAN_STAINED_GLASS_PANE, - Items.PURPLE_STAINED_GLASS_PANE, - Items.BLUE_STAINED_GLASS_PANE, - Items.BROWN_STAINED_GLASS_PANE, - Items.GREEN_STAINED_GLASS_PANE, - Items.RED_STAINED_GLASS_PANE, - Items.BLACK_STAINED_GLASS_PANE - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - val stainedGlassPane = Ingredient(items = stainedGlassPane) - val waterBucket = Ingredient(items = listOf(Items.WATER_BUCKET)) - - val list = listOf(waterBucket) - - for (count in 1..8) { - val countedList = list.toMutableList() - - for (addCount in 1..count) { - countedList.add(stainedGlassPane) - } - - if (RecipeUtils.isItemShapelessMatches(inv, countedList)) { - match = true - break - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - val stainedGlassPane = Ingredient(items = stainedGlassPane) - val waterBucket = Ingredient(items = listOf(Items.WATER_BUCKET)) - - val list = listOf(waterBucket) - - for (count in 1..8) { - val countedList = list.toMutableList() - - for (addCount in 1..count) { - countedList.add(stainedGlassPane) - } - - if (RecipeUtils.isItemShapelessMatches(inv, countedList)) { - item = Items.GLASS_PANE.defaultStack.apply { this.count = count } - break - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.GLASS_PANE.defaultStack.apply { this.count = 1 } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/StainedGlassRestore.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/StainedGlassRestore.kt deleted file mode 100644 index a69640dc1..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/StainedGlassRestore.kt +++ /dev/null @@ -1,111 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class StainedGlassRestore : CraftingRecipe { - private val stainedGlass = listOf( - Items.WHITE_STAINED_GLASS, - Items.ORANGE_STAINED_GLASS, - Items.MAGENTA_STAINED_GLASS, - Items.LIGHT_BLUE_STAINED_GLASS, - Items.YELLOW_STAINED_GLASS, - Items.LIME_STAINED_GLASS, - Items.PINK_STAINED_GLASS, - Items.GRAY_STAINED_GLASS, - Items.LIGHT_GRAY_STAINED_GLASS, - Items.CYAN_STAINED_GLASS, - Items.PURPLE_STAINED_GLASS, - Items.BLUE_STAINED_GLASS, - Items.BROWN_STAINED_GLASS, - Items.GREEN_STAINED_GLASS, - Items.RED_STAINED_GLASS, - Items.BLACK_STAINED_GLASS - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - val stainedGlass = Ingredient(items = stainedGlass) - val waterBucket = Ingredient(items = listOf(Items.WATER_BUCKET)) - - val list = listOf(waterBucket) - - for (count in 1..8) { - val countedList = list.toMutableList() - - for (addCount in 1..count) { - countedList.add(stainedGlass) - } - - if (RecipeUtils.isItemShapelessMatches(inv, countedList)) { - match = true - break - } - } - - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - val stainedGlass = Ingredient(items = stainedGlass) - val waterBucket = Ingredient(items = listOf(Items.WATER_BUCKET)) - - val list = listOf(waterBucket) - - for (count in 1..8) { - val countedList = list.toMutableList() - - for (addCount in 1..count) { - countedList.add(stainedGlass) - } - - if (RecipeUtils.isItemShapelessMatches(inv, countedList)) { - item = Items.GLASS.defaultStack.apply { this.count = count } - break - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.GLASS.defaultStack.apply { this.count = 1 } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Stick.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Stick.kt deleted file mode 100644 index bbdc3e88a..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/Stick.kt +++ /dev/null @@ -1,57 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.registry.tag.ItemTags -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Stick : CraftingRecipe { - private val item = Items.STICK.defaultStack.apply { this.count = 16 } - private val list = listOf( - Ingredient(tag = ItemTags.LOGS), - Ingredient(tag = ItemTags.LOGS) - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 1, 2, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.MISC -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/TrappedChest.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/TrappedChest.kt deleted file mode 100644 index 4170cc00f..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/TrappedChest.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.registry.tag.ItemTags -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class TrappedChest : CraftingRecipe { - private val item = Items.TRAPPED_CHEST.defaultStack - - private val planks = Ingredient(tag = ItemTags.PLANKS) - private val tripWireHook = Ingredient(items = listOf(Items.TRIPWIRE_HOOK)) - private val list = listOf( - planks, planks, planks, - planks, tripWireHook, planks, - planks, planks, planks - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/WarpedFungusOnAStick.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/WarpedFungusOnAStick.kt deleted file mode 100644 index 00dc4ce27..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/WarpedFungusOnAStick.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class WarpedFungusOnAStick : CraftingRecipe { - private val item = Items.WARPED_FUNGUS_ON_A_STICK.defaultStack - - private val air = Ingredient(items = listOf(Items.AIR)) - private val stick = Ingredient(items = listOf(Items.STICK)) - private val strings = Ingredient(items = listOf(Items.STRING)) - private val warpedFungus = Ingredient(items = listOf(Items.WARPED_FUNGUS)) - private val listLeft = listOf( - stick, air, air, - strings, stick, air, - strings, warpedFungus, stick - ) - private val listRight = listOf( - air, air, stick, - air, stick, strings, - stick, warpedFungus, strings - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = - (RecipeUtils.isItemShapedMatches(inv, 3, 3, listLeft) || RecipeUtils.isItemShapedMatches(inv, 3, 3, listRight)) - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = item.copy() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/WoodenSlab.kt b/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/WoodenSlab.kt deleted file mode 100644 index 7503a346e..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/easyRecipe/WoodenSlab.kt +++ /dev/null @@ -1,87 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.easyRecipe - -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer -import net.minecraft.recipe.book.CraftingRecipeCategory -import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.registry.tag.ItemTags -import net.minecraft.world.World -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class WoodenSlab : CraftingRecipe { - private val slabs = hashMapOf( - ItemTags.OAK_LOGS to Items.OAK_SLAB, - ItemTags.SPRUCE_LOGS to Items.SPRUCE_SLAB, - ItemTags.BIRCH_LOGS to Items.BIRCH_SLAB, - ItemTags.JUNGLE_LOGS to Items.JUNGLE_SLAB, - ItemTags.ACACIA_LOGS to Items.ACACIA_SLAB, - ItemTags.DARK_OAK_LOGS to Items.DARK_OAK_SLAB, - ItemTags.CRIMSON_STEMS to Items.CRIMSON_SLAB, - ItemTags.WARPED_STEMS to Items.WARPED_SLAB - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean { - var match = false - slabs.forEach { (tag, _) -> - val list = listOf( - Ingredient(tag = tag), Ingredient(tag = tag), Ingredient(tag = tag) - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 1, list)) { - match = true - return@forEach - } - } - return match - } - - override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager): ItemStack { - var item = ItemStack.EMPTY - slabs.forEach { (tag, result) -> - val list = listOf( - Ingredient(tag = tag), Ingredient(tag = tag), Ingredient(tag = tag) - ) - if (RecipeUtils.isItemShapedMatches(inv, 3, 1, list)) { - item = result.defaultStack.apply { this.count = 24 } - return@forEach - } - } - return item - } - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = Items.OAK_SLAB.defaultStack.apply { this.count = 24 } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.BUILDING -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt b/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt index 8c23c78b9..8cacc8cd1 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/materials/CeramicPlate.kt @@ -20,29 +20,22 @@ package one.oktw.galaxy.recipe.materials import net.minecraft.inventory.Inventory import net.minecraft.recipe.Ingredient -import net.minecraft.recipe.RecipeSerializer import net.minecraft.recipe.SmeltingRecipe import net.minecraft.recipe.book.CookingRecipeCategory import net.minecraft.world.World import one.oktw.galaxy.item.CustomItemHelper import one.oktw.galaxy.item.Material -class CeramicPlate : - SmeltingRecipe( - "", - CookingRecipeCategory.MISC, - Ingredient.ofStacks(Material.RAW_BASE_PLATE.createItemStack()), - Material.BASE_PLATE.createItemStack(), - 5.0F, - 200 - ) { - - override fun matches(inventory: Inventory?, world: World?): Boolean { - val input = inventory?.getStack(0) ?: return super.matches(inventory, world) +class CeramicPlate : SmeltingRecipe( + "", + CookingRecipeCategory.MISC, + Ingredient.ofStacks(Material.RAW_BASE_PLATE.createItemStack()), + Material.BASE_PLATE.createItemStack(), + 0.1F, + 200 +) { + override fun matches(inventory: Inventory, world: World): Boolean { + val input = inventory.getStack(0) ?: return false return CustomItemHelper.getItem(input) == Material.RAW_BASE_PLATE } - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } } diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt b/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt index dc1582e3c..cf1099d37 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/tools/Crowbar.kt @@ -18,44 +18,24 @@ package one.oktw.galaxy.recipe.tools -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment import net.minecraft.inventory.RecipeInputInventory import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.RawShapedRecipe +import net.minecraft.recipe.ShapedRecipe import net.minecraft.recipe.book.CraftingRecipeCategory import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World import one.oktw.galaxy.item.Tool -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Crowbar : CraftingRecipe { - private val item = Tool.CROWBAR.createItemStack() - - private val air = Ingredient(items = listOf(Items.AIR)) - private val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT)) - private val list = listOf( - ironIngot, ironIngot, - air, ironIngot, - air, ironIngot, - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 2, 3, list = list) +class Crowbar : ShapedRecipe( + "", + CraftingRecipeCategory.EQUIPMENT, + RawShapedRecipe.create( + mapOf(Character.valueOf('i') to net.minecraft.recipe.Ingredient.ofItems(Items.IRON_INGOT)), + "ii", + " i", + " i" + ), + Tool.CROWBAR.createItemStack() +) { override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = Tool.CROWBAR.createItemStack() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented") - } - - override fun getCategory() = CraftingRecipeCategory.EQUIPMENT } diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt b/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt index 89614bd8d..f6f152955 100644 --- a/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt +++ b/src/main/kotlin/one/oktw/galaxy/recipe/tools/Wrench.kt @@ -18,45 +18,25 @@ package one.oktw.galaxy.recipe.tools -import net.fabricmc.api.EnvType -import net.fabricmc.api.Environment import net.minecraft.inventory.RecipeInputInventory import net.minecraft.item.Items -import net.minecraft.recipe.CraftingRecipe -import net.minecraft.recipe.RecipeSerializer +import net.minecraft.recipe.Ingredient +import net.minecraft.recipe.RawShapedRecipe +import net.minecraft.recipe.ShapedRecipe import net.minecraft.recipe.book.CraftingRecipeCategory import net.minecraft.registry.DynamicRegistryManager -import net.minecraft.world.World import one.oktw.galaxy.item.Tool -import one.oktw.galaxy.recipe.utils.Ingredient -import one.oktw.galaxy.recipe.utils.RecipeUtils - -class Wrench : CraftingRecipe { - private val item = Tool.WRENCH.createItemStack() - - private val air = Ingredient(items = listOf(Items.AIR)) - private val ironIngot = Ingredient(items = listOf(Items.IRON_INGOT)) - private val stick = Ingredient(items = listOf(Items.STICK)) - private val list = listOf( - ironIngot, air, ironIngot, - air, stick, air, - air, ironIngot, air - ) - - override fun matches(inv: RecipeInputInventory, world: World): Boolean = RecipeUtils.isItemShapedMatches(inv, 3, 3, list = list) +class Wrench : ShapedRecipe( + "", + CraftingRecipeCategory.EQUIPMENT, + RawShapedRecipe.create( + mapOf(Character.valueOf('i') to Ingredient.ofItems(Items.IRON_INGOT), Character.valueOf('s') to Ingredient.ofItems(Items.STICK)), + "i i", + " s ", + " i " + ), + Tool.WRENCH.createItemStack() +) { override fun craft(inv: RecipeInputInventory, registryManager: DynamicRegistryManager) = Tool.WRENCH.createItemStack() - - @Environment(EnvType.CLIENT) - override fun fits(width: Int, height: Int): Boolean { - throw NotImplementedError() - } - - override fun getResult(registryManager: DynamicRegistryManager) = item - - override fun getSerializer(): RecipeSerializer<*> { - TODO("Not yet implemented, support client mod.") - } - - override fun getCategory() = CraftingRecipeCategory.EQUIPMENT } diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/utils/Ingredient.kt b/src/main/kotlin/one/oktw/galaxy/recipe/utils/Ingredient.kt deleted file mode 100644 index 53a764594..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/utils/Ingredient.kt +++ /dev/null @@ -1,41 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.utils - -import net.minecraft.item.Item -import net.minecraft.item.ItemStack -import net.minecraft.registry.tag.TagKey - -class Ingredient( - private val tag: TagKey? = null, - private val items: List? = null -) { - init { - if (tag == null && items == null) throw IllegalArgumentException("No input provided.") - if (tag != null && items != null) throw IllegalArgumentException("Only one input is allowed.") - } - - fun matches(input: ItemStack): Boolean { - return when { - tag != null -> input.isIn(tag) - items != null -> items.contains(input.item) - else -> false - } - } -} diff --git a/src/main/kotlin/one/oktw/galaxy/recipe/utils/RecipeUtils.kt b/src/main/kotlin/one/oktw/galaxy/recipe/utils/RecipeUtils.kt deleted file mode 100644 index 8e0b26ed0..000000000 --- a/src/main/kotlin/one/oktw/galaxy/recipe/utils/RecipeUtils.kt +++ /dev/null @@ -1,83 +0,0 @@ -/* - * OKTW Galaxy Project - * Copyright (C) 2018-2023 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, or - * 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package one.oktw.galaxy.recipe.utils - -import net.minecraft.inventory.RecipeInputInventory -import net.minecraft.item.ItemStack -import net.minecraft.item.Items - -object RecipeUtils { - fun isItemShapedMatches(inv: RecipeInputInventory, width: Int, height: Int, list: List): Boolean { - for (x in 0..(inv.width - width)) { - for (y in 0..(inv.height - height)) { - if (shapeMatchesSmall(inv, width, height, x, y, true, list)) return true - if (shapeMatchesSmall(inv, width, height, x, y, false, list)) return true - } - } - - return false - } - - private fun shapeMatchesSmall( - inv: RecipeInputInventory, - width: Int, - height: Int, - offsetX: Int, - offsetY: Int, - widthFromLast: Boolean, - list: List - ): Boolean { - for (x in 0 until inv.width) { - for (y in 0 until inv.height) { - val i = x - offsetX - val j = y - offsetY - var input = Ingredient(items = listOf(Items.AIR)) - if (i >= 0 && j >= 0 && i < width && j < height) { - input = if (widthFromLast) { - list[width - i - 1 + j * width] - } else { - list[i + j * width] - } - } - if (!input.matches(inv.getStack(x + y * inv.width))) return false - } - } - return true - } - - fun isItemShapelessMatches(inv: RecipeInputInventory, list: List): Boolean { - val inputItems = mutableListOf() - - for (i in 0 until inv.size()) { - val invItem = inv.getStack(i) - if (!invItem.isEmpty) { - inputItems += invItem - } - } - - if (inputItems.count() != list.count()) return false - list.forEach { ingredient -> - val predicate = inputItems.firstOrNull { ingredient.matches(it) } - if (predicate != null) { - inputItems.remove(predicate) - } - } - return inputItems.isEmpty() - } -} diff --git a/src/main/resources/recipe.mixin.json b/src/main/resources/recipe.mixin.json index adba931e5..be86022fa 100644 --- a/src/main/resources/recipe.mixin.json +++ b/src/main/resources/recipe.mixin.json @@ -4,7 +4,6 @@ "compatibilityLevel": "JAVA_16", "mixins": [ "MixinCustomRecipe_CraftingResultSlot", - "MixinCustomRecipe_PlayerManager", "MixinCustomRecipe_RecipeManager" ], "client": [], diff --git a/src/main/resources/tweak.mixin.json b/src/main/resources/tweak.mixin.json index 8bde79761..b8c7f8b37 100644 --- a/src/main/resources/tweak.mixin.json +++ b/src/main/resources/tweak.mixin.json @@ -13,6 +13,7 @@ "MixinCustomBlockEntity_BarrierBlock", "MixinCustomBlockEntity_Structure", "MixinFixBeacon_BeaconBlockEntity", + "MixinGlobalDataPack_VanillaDataPackProvider", "MixinItemStackEqualAllowNull_ItemStack", "MixinMapExistingChunk_FilledMapItem", "MixinOneSpawnChunk_MinecraftServer",