From c7a225121f3ce377f21af376ec6a3105ccad5826 Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Mon, 11 Sep 2023 20:35:01 +0200 Subject: [PATCH] Added custom compacting recipes, changed recipes that used the tag to use the custom recipe, closes #150 --- .github/workflows/publish.yaml | 2 +- CHANGELOG.md | 3 +- .../03e4de26f1265135874f8cdcaebc09d9c08eb42b | 5 +- .../75bcd4dba6ca7d365462b0ec45e291d1056349c4 | 4 +- .../b3b48c10570c424437115253c982ed89e6bd5ccb | 8 + .../recipes/custom_compacting/amethyst.json | 11 ++ .../recipes/custom_compacting/blue_ice.json | 11 ++ .../recipes/custom_compacting/clay.json | 11 ++ .../recipes/custom_compacting/glowstone.json | 11 ++ .../recipes/custom_compacting/ice.json | 11 ++ .../recipes/custom_compacting/melon.json | 11 ++ .../recipes/custom_compacting/quartz.json | 11 ++ .../functionalstorage/tags/items/drawer.json | 20 +-- .../tags/items/ignore_crafting_check.json | 17 --- .../minecraft/tags/blocks/mineable/axe.json | 20 +-- .../functionalstorage/FunctionalStorage.java | 137 ++++-------------- .../FunctionalStorageItemTagsProvider.java | 9 -- .../FunctionalStorageRecipesProvider.java | 126 ++++++++++++++++ .../recipe/CustomCompactingRecipe.java | 70 +++++++++ .../util/CompactingUtil.java | 21 ++- 20 files changed, 358 insertions(+), 161 deletions(-) create mode 100644 src/generated/resources/.cache/b3b48c10570c424437115253c982ed89e6bd5ccb create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/amethyst.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/blue_ice.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/clay.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/glowstone.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/ice.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/melon.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/custom_compacting/quartz.json delete mode 100644 src/generated/resources/data/functionalstorage/tags/items/ignore_crafting_check.json create mode 100644 src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageRecipesProvider.java create mode 100644 src/main/java/com/buuz135/functionalstorage/recipe/CustomCompactingRecipe.java diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f2f2f3fc..b008ea33 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -35,6 +35,6 @@ jobs: game-versions: 1.19.2 java: 17 name: "" - changelog: "https://github.com/Buuz135/FunctionalStorage/commits/1.19/CHANGELOG.md" + changelog: "https://github.com/Buuz135/FunctionalStorage/blob/1.19/CHANGELOG.md" dependencies: | titanium | depends \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 35413d52..5a91d757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,4 +14,5 @@ * Prevent infinite loop when drawers check for their parent stuff, closes #73 * Now having the configuration tool in the offhand it will toggle the selected action when placing a drawer, closes #156 * Fixed pushing upgrade only pushing to the first slot, closes #164 -* Added Framed Simple Compacting Drawer, closes #179 \ No newline at end of file +* Added Framed Simple Compacting Drawer, closes #179 +* Added custom compacting recipes, changed recipes that used the tag to use the custom recipe, closes #150 \ No newline at end of file diff --git a/src/generated/resources/.cache/03e4de26f1265135874f8cdcaebc09d9c08eb42b b/src/generated/resources/.cache/03e4de26f1265135874f8cdcaebc09d9c08eb42b index 1af2e443..12c6d8d6 100644 --- a/src/generated/resources/.cache/03e4de26f1265135874f8cdcaebc09d9c08eb42b +++ b/src/generated/resources/.cache/03e4de26f1265135874f8cdcaebc09d9c08eb42b @@ -1,3 +1,2 @@ -// 1.19.2 2023-09-11T16:28:07.8459027 Tags for minecraft:item -8250c4dc87ee6f6c2f21c530c8a1f2bb203c32ba data/functionalstorage/tags/items/drawer.json -a6cf5364934bad4e060980a3c7f3c091ad90a585 data/functionalstorage/tags/items/ignore_crafting_check.json +// 1.19.2 2023-09-11T20:18:35.3526175 Tags for minecraft:item +89ea5373901359c91347ffd870336f8dd4f2cc52 data/functionalstorage/tags/items/drawer.json diff --git a/src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 b/src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 index 6792de63..5dd08bc3 100644 --- a/src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 +++ b/src/generated/resources/.cache/75bcd4dba6ca7d365462b0ec45e291d1056349c4 @@ -1,3 +1,3 @@ -// 1.19.2 2023-09-11T16:28:07.8439024 Tags for minecraft:block -8250c4dc87ee6f6c2f21c530c8a1f2bb203c32ba data/minecraft/tags/blocks/mineable/axe.json +// 1.19.2 2023-09-11T20:18:35.3566154 Tags for minecraft:block +89ea5373901359c91347ffd870336f8dd4f2cc52 data/minecraft/tags/blocks/mineable/axe.json 4b6fc75faca16170a17220f0e301b16866f4bc5c data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/generated/resources/.cache/b3b48c10570c424437115253c982ed89e6bd5ccb b/src/generated/resources/.cache/b3b48c10570c424437115253c982ed89e6bd5ccb new file mode 100644 index 00000000..41762b55 --- /dev/null +++ b/src/generated/resources/.cache/b3b48c10570c424437115253c982ed89e6bd5ccb @@ -0,0 +1,8 @@ +// 1.19.2 2023-09-11T20:18:35.3561145 Titanium Serializable (functionalstorage) +a7466344fe302df75a569e4712ed02cb443c359a data/functionalstorage/recipes/custom_compacting/amethyst.json +e47b9a1342f38c4e36482fe0fe0a0bada0f875ff data/functionalstorage/recipes/custom_compacting/blue_ice.json +d24028ec840b0e7b4d100b43144e7a3f5a70283c data/functionalstorage/recipes/custom_compacting/clay.json +b3d11532f966981fbe0349b89e09cc691e8f68e4 data/functionalstorage/recipes/custom_compacting/glowstone.json +ea40f46d6a88b93ad35f6ce57cd2a391cd195abb data/functionalstorage/recipes/custom_compacting/ice.json +266466efff4179eae51a2ce4c4541d65ebd9bb60 data/functionalstorage/recipes/custom_compacting/melon.json +4d0c7b7ed927a92cef2cdb9814ca086287a363ac data/functionalstorage/recipes/custom_compacting/quartz.json diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/amethyst.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/amethyst.json new file mode 100644 index 00000000..5acbabd7 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/amethyst.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:amethyst_block" + }, + "lower_input": { + "count": 9, + "item": "minecraft:amethyst_shard" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/blue_ice.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/blue_ice.json new file mode 100644 index 00000000..a2daed5f --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/blue_ice.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:packed_ice" + }, + "lower_input": { + "count": 9, + "item": "minecraft:blue_ice" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/clay.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/clay.json new file mode 100644 index 00000000..892ee345 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/clay.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:clay" + }, + "lower_input": { + "count": 4, + "item": "minecraft:clay_ball" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/glowstone.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/glowstone.json new file mode 100644 index 00000000..ad792d87 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/glowstone.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:glowstone" + }, + "lower_input": { + "count": 4, + "item": "minecraft:glowstone_dust" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/ice.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/ice.json new file mode 100644 index 00000000..3e2907ba --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/ice.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:blue_ice" + }, + "lower_input": { + "count": 9, + "item": "minecraft:ice" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/melon.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/melon.json new file mode 100644 index 00000000..71eb8163 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/melon.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:melon" + }, + "lower_input": { + "count": 9, + "item": "minecraft:melon_slice" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/custom_compacting/quartz.json b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/quartz.json new file mode 100644 index 00000000..a2057b77 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/custom_compacting/quartz.json @@ -0,0 +1,11 @@ +{ + "type": "functionalstorage:custom_compacting", + "higher_input": { + "count": 1, + "item": "minecraft:quartz_block" + }, + "lower_input": { + "count": 4, + "item": "minecraft:quartz" + } +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/tags/items/drawer.json b/src/generated/resources/data/functionalstorage/tags/items/drawer.json index 1da82a58..79a7c5a6 100644 --- a/src/generated/resources/data/functionalstorage/tags/items/drawer.json +++ b/src/generated/resources/data/functionalstorage/tags/items/drawer.json @@ -1,15 +1,5 @@ { "values": [ - "functionalstorage:oak_1", - "functionalstorage:spruce_1", - "functionalstorage:birch_1", - "functionalstorage:jungle_1", - "functionalstorage:acacia_1", - "functionalstorage:dark_oak_1", - "functionalstorage:crimson_1", - "functionalstorage:warped_1", - "functionalstorage:framed_1", - "functionalstorage:mangrove_1", "functionalstorage:oak_2", "functionalstorage:spruce_2", "functionalstorage:birch_2", @@ -20,6 +10,16 @@ "functionalstorage:warped_2", "functionalstorage:framed_2", "functionalstorage:mangrove_2", + "functionalstorage:oak_1", + "functionalstorage:spruce_1", + "functionalstorage:birch_1", + "functionalstorage:jungle_1", + "functionalstorage:acacia_1", + "functionalstorage:dark_oak_1", + "functionalstorage:crimson_1", + "functionalstorage:warped_1", + "functionalstorage:framed_1", + "functionalstorage:mangrove_1", "functionalstorage:oak_4", "functionalstorage:spruce_4", "functionalstorage:birch_4", diff --git a/src/generated/resources/data/functionalstorage/tags/items/ignore_crafting_check.json b/src/generated/resources/data/functionalstorage/tags/items/ignore_crafting_check.json deleted file mode 100644 index 649c1763..00000000 --- a/src/generated/resources/data/functionalstorage/tags/items/ignore_crafting_check.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "values": [ - "minecraft:clay", - "minecraft:clay_ball", - "minecraft:glowstone", - "minecraft:glowstone_dust", - "minecraft:melon", - "minecraft:melon_slice", - "minecraft:quartz", - "minecraft:quartz_block", - "minecraft:ice", - "minecraft:blue_ice", - "minecraft:packed_ice", - "minecraft:amethyst_block", - "minecraft:amethyst_shard" - ] -} \ No newline at end of file diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json index 1da82a58..79a7c5a6 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -1,15 +1,5 @@ { "values": [ - "functionalstorage:oak_1", - "functionalstorage:spruce_1", - "functionalstorage:birch_1", - "functionalstorage:jungle_1", - "functionalstorage:acacia_1", - "functionalstorage:dark_oak_1", - "functionalstorage:crimson_1", - "functionalstorage:warped_1", - "functionalstorage:framed_1", - "functionalstorage:mangrove_1", "functionalstorage:oak_2", "functionalstorage:spruce_2", "functionalstorage:birch_2", @@ -20,6 +10,16 @@ "functionalstorage:warped_2", "functionalstorage:framed_2", "functionalstorage:mangrove_2", + "functionalstorage:oak_1", + "functionalstorage:spruce_1", + "functionalstorage:birch_1", + "functionalstorage:jungle_1", + "functionalstorage:acacia_1", + "functionalstorage:dark_oak_1", + "functionalstorage:crimson_1", + "functionalstorage:warped_1", + "functionalstorage:framed_1", + "functionalstorage:mangrove_1", "functionalstorage:oak_4", "functionalstorage:spruce_4", "functionalstorage:birch_4", diff --git a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java index 5ffa8721..c73a04b6 100644 --- a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java +++ b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java @@ -4,10 +4,7 @@ import com.buuz135.functionalstorage.block.tile.*; import com.buuz135.functionalstorage.client.*; import com.buuz135.functionalstorage.client.loader.FramedModel; -import com.buuz135.functionalstorage.data.FunctionalStorageBlockTagsProvider; -import com.buuz135.functionalstorage.data.FunctionalStorageBlockstateProvider; -import com.buuz135.functionalstorage.data.FunctionalStorageItemTagsProvider; -import com.buuz135.functionalstorage.data.FunctionalStorageLangProvider; +import com.buuz135.functionalstorage.data.*; import com.buuz135.functionalstorage.inventory.BigInventoryHandler; import com.buuz135.functionalstorage.inventory.item.CompactingStackItemHandler; import com.buuz135.functionalstorage.inventory.item.DrawerStackItemHandler; @@ -16,32 +13,35 @@ import com.buuz135.functionalstorage.item.StorageUpgradeItem; import com.buuz135.functionalstorage.item.UpgradeItem; import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage; +import com.buuz135.functionalstorage.recipe.CustomCompactingRecipe; import com.buuz135.functionalstorage.recipe.DrawerlessWoodIngredient; import com.buuz135.functionalstorage.recipe.FramedDrawerRecipe; -import com.buuz135.functionalstorage.util.*; -import com.hrznstudio.titanium.block.BasicBlock; +import com.buuz135.functionalstorage.util.DrawerWoodType; +import com.buuz135.functionalstorage.util.IWoodType; +import com.buuz135.functionalstorage.util.NumberUtils; +import com.buuz135.functionalstorage.util.TooltipUtil; import com.hrznstudio.titanium.datagenerator.loot.TitaniumLootTableProvider; import com.hrznstudio.titanium.datagenerator.model.BlockItemModelGeneratorProvider; import com.hrznstudio.titanium.event.handler.EventManager; import com.hrznstudio.titanium.module.ModuleController; import com.hrznstudio.titanium.nbthandler.NBTManager; import com.hrznstudio.titanium.network.NetworkHandler; -import com.hrznstudio.titanium.recipe.generator.TitaniumRecipeProvider; -import com.hrznstudio.titanium.recipe.generator.TitaniumShapedRecipeBuilder; +import com.hrznstudio.titanium.recipe.generator.IJSONGenerator; +import com.hrznstudio.titanium.recipe.generator.IJsonFile; +import com.hrznstudio.titanium.recipe.generator.TitaniumSerializableProvider; +import com.hrznstudio.titanium.recipe.serializer.GenericSerializer; import com.hrznstudio.titanium.tab.AdvancedTitaniumTab; import net.minecraft.client.renderer.ItemBlockRenderTypes; import net.minecraft.client.renderer.RenderType; -import net.minecraft.data.recipes.FinishedRecipe; -import net.minecraft.data.recipes.UpgradeRecipeBuilder; import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; -import net.minecraft.tags.ItemTags; import net.minecraft.world.inventory.InventoryMenu; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.item.crafting.RecipeSerializer; +import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.entity.BlockEntityType; @@ -52,7 +52,6 @@ import net.minecraftforge.client.model.generators.BlockModelProvider; import net.minecraftforge.client.model.generators.ItemModelProvider; import net.minecraftforge.common.ForgeMod; -import net.minecraftforge.common.Tags; import net.minecraftforge.common.capabilities.ForgeCapabilities; import net.minecraftforge.common.crafting.CraftingHelper; import net.minecraftforge.common.util.NonNullLazy; @@ -71,7 +70,6 @@ import java.awt.*; import java.util.List; import java.util.*; -import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -117,6 +115,9 @@ public class FunctionalStorage extends ModuleController { public static RegistryObject REDSTONE_UPGRADE; public static RegistryObject CREATIVE_UPGRADE; + public static RegistryObject> CUSTOM_COMPACTING_RECIPE_SERIALIZER; + public static RegistryObject> CUSTOM_COMPACTING_RECIPE_TYPE; + public static AdvancedTitaniumTab TAB = new AdvancedTitaniumTab("functionalstorage", true); public FunctionalStorage() { @@ -229,6 +230,10 @@ public boolean isFoil(ItemStack p_41453_) { FRAMED_CONTROLLER_EXTENSION = getRegistries().registerBlockWithTile("framed_controller_extension", FramedControllerExtensionBlock::new); getRegistries().registerGeneric(ForgeRegistries.RECIPE_SERIALIZERS.getRegistryKey(), "framed_recipe", () -> FramedDrawerRecipe.SERIALIZER); + + CUSTOM_COMPACTING_RECIPE_TYPE = getRegistries().registerGeneric(ForgeRegistries.RECIPE_TYPES.getRegistryKey(), "custom_compacting", () -> RecipeType.simple(new ResourceLocation(MOD_ID, "custom_compacting"))); + + CUSTOM_COMPACTING_RECIPE_SERIALIZER = getRegistries().registerGeneric(ForgeRegistries.RECIPE_SERIALIZERS.getRegistryKey(), "custom_compacting", () -> new GenericSerializer((RecipeType) CUSTOM_COMPACTING_RECIPE_TYPE.get(), CustomCompactingRecipe.class)); } public enum DrawerType { @@ -442,99 +447,19 @@ protected void registerModels() { } }); } - event.getGenerator().addProvider(true, new TitaniumRecipeProvider(event.getGenerator()) { + event.getGenerator().addProvider(true, new FunctionalStorageRecipesProvider(event.getGenerator(), blocksToProcess)); + event.getGenerator().addProvider(true, new TitaniumSerializableProvider(event.getGenerator(), MOD_ID) { @Override - public void register(Consumer consumer) { - blocksToProcess.get().stream().map(block -> (BasicBlock) block).forEach(basicBlock -> basicBlock.registerRecipe(consumer)); - TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.IRON).get()) - .pattern("III").pattern("IDI").pattern("III") - .define('I', Tags.Items.INGOTS_IRON) - .define('D', StorageTags.DRAWER) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(VOID_UPGRADE.get()) - .pattern("III").pattern("IDI").pattern("III") - .define('I', Tags.Items.OBSIDIAN) - .define('D', StorageTags.DRAWER) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(CONFIGURATION_TOOL.get()) - .pattern("PPG").pattern("PDG").pattern("PEP") - .define('P', Items.PAPER) - .define('G', Tags.Items.INGOTS_GOLD) - .define('D', StorageTags.DRAWER) - .define('E', Items.EMERALD) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(LINKING_TOOL.get()) - .pattern("PPG").pattern("PDG").pattern("PEP") - .define('P', Items.PAPER) - .define('G', Tags.Items.INGOTS_GOLD) - .define('D', StorageTags.DRAWER) - .define('E', Items.DIAMOND) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.COPPER).get()) - .pattern("IBI").pattern("CDC").pattern("IBI") - .define('I', Items.COPPER_INGOT) - .define('B', Items.COPPER_BLOCK) - .define('C', Tags.Items.CHESTS_WOODEN) - .define('D', StorageTags.DRAWER) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.GOLD).get()) - .pattern("IBI").pattern("CDC").pattern("BIB") - .define('I', Tags.Items.INGOTS_GOLD) - .define('B', Tags.Items.STORAGE_BLOCKS_GOLD) - .define('C', Tags.Items.CHESTS_WOODEN) - .define('D', STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.COPPER).get()) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()) - .pattern("IBI").pattern("CDC").pattern("IBI") - .define('I', Tags.Items.GEMS_DIAMOND) - .define('B', Tags.Items.STORAGE_BLOCKS_DIAMOND) - .define('C', Tags.Items.CHESTS_WOODEN) - .define('D', STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.GOLD).get()) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(REDSTONE_UPGRADE.get()) - .pattern("IBI").pattern("CDC").pattern("IBI") - .define('I', Items.REDSTONE) - .define('B', Items.REDSTONE_BLOCK) - .define('C', Items.COMPARATOR) - .define('D', StorageTags.DRAWER) - .save(consumer); - UpgradeRecipeBuilder.smithing(Ingredient.of(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()), Ingredient.of(Items.NETHERITE_INGOT), STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get()) - .unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT)) - .save(consumer, ForgeRegistries.ITEMS.getKey(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get())); - TitaniumShapedRecipeBuilder.shapedRecipe(ARMORY_CABINET.getLeft().get()) - .pattern("ICI").pattern("CDC").pattern("IBI") - .define('I', Tags.Items.STONE) - .define('B', Tags.Items.INGOTS_NETHERITE) - .define('C', StorageTags.DRAWER) - .define('D', Items.COMPARATOR) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(PULLING_UPGRADE.get()) - .pattern("ICI").pattern("IDI").pattern("IBI") - .define('I', Tags.Items.STONE) - .define('B', Tags.Items.DUSTS_REDSTONE) - .define('C', Items.HOPPER) - .define('D', StorageTags.DRAWER) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(PUSHING_UPGRADE.get()) - .pattern("IBI").pattern("IDI").pattern("IRI") - .define('I', Tags.Items.STONE) - .define('B', Tags.Items.DUSTS_REDSTONE) - .define('R', Items.HOPPER) - .define('D', StorageTags.DRAWER) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(COLLECTOR_UPGRADE.get()) - .pattern("IBI").pattern("RDR").pattern("IBI") - .define('I', Tags.Items.STONE) - .define('B', Items.HOPPER) - .define('R', Tags.Items.DUSTS_REDSTONE) - .define('D', StorageTags.DRAWER) - .save(consumer); - TitaniumShapedRecipeBuilder.shapedRecipe(ENDER_DRAWER.getLeft().get()) - .pattern("PPP").pattern("LCL").pattern("PPP") - .define('P', ItemTags.PLANKS) - .define('C', Tags.Items.CHESTS_ENDER) - .define('L', StorageTags.DRAWER) - .save(consumer); + public void add(Map serializables) { + new CustomCompactingRecipe(new ResourceLocation("clay"), new ItemStack(Items.CLAY_BALL, 4), new ItemStack(Items.CLAY)); + new CustomCompactingRecipe(new ResourceLocation("glowstone"), new ItemStack(Items.GLOWSTONE_DUST, 4), new ItemStack(Items.GLOWSTONE)); + new CustomCompactingRecipe(new ResourceLocation("melon"), new ItemStack(Items.MELON_SLICE, 9), new ItemStack(Items.MELON)); + new CustomCompactingRecipe(new ResourceLocation("quartz"), new ItemStack(Items.QUARTZ, 4), new ItemStack(Items.QUARTZ_BLOCK)); + new CustomCompactingRecipe(new ResourceLocation("ice"), new ItemStack(Items.ICE, 9), new ItemStack(Items.BLUE_ICE)); + new CustomCompactingRecipe(new ResourceLocation("blue_ice"), new ItemStack(Items.BLUE_ICE, 9), new ItemStack(Items.PACKED_ICE)); + new CustomCompactingRecipe(new ResourceLocation("amethyst"), new ItemStack(Items.AMETHYST_SHARD, 9), new ItemStack(Items.AMETHYST_BLOCK)); + + CustomCompactingRecipe.RECIPES.forEach(customCompactingRecipe -> serializables.put(customCompactingRecipe, customCompactingRecipe)); } }); } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java index 5c238239..5e68ad60 100644 --- a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageItemTagsProvider.java @@ -7,7 +7,6 @@ import net.minecraft.data.tags.ItemTagsProvider; import net.minecraft.data.tags.TagsProvider; import net.minecraft.world.item.Item; -import net.minecraft.world.item.Items; import net.minecraft.world.level.block.Block; import net.minecraftforge.common.data.ExistingFileHelper; import net.minecraftforge.registries.RegistryObject; @@ -30,13 +29,5 @@ protected void addTags() { tTagAppender.add(blockRegistryObject.get().asItem()); } } - this.tag(StorageTags.IGNORE_CRAFTING_CHECK) - .add(Items.CLAY, Items.CLAY_BALL) - .add(Items.GLOWSTONE, Items.GLOWSTONE_DUST) - .add(Items.MELON, Items.MELON_SLICE) - .add(Items.QUARTZ, Items.QUARTZ_BLOCK) - .add(Items.ICE, Items.BLUE_ICE, Items.PACKED_ICE) - .add(Items.AMETHYST_BLOCK, Items.AMETHYST_SHARD) - ; } } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageRecipesProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageRecipesProvider.java new file mode 100644 index 00000000..0cc17aec --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageRecipesProvider.java @@ -0,0 +1,126 @@ +package com.buuz135.functionalstorage.data; + +import com.buuz135.functionalstorage.item.StorageUpgradeItem; +import com.buuz135.functionalstorage.util.StorageTags; +import com.hrznstudio.titanium.block.BasicBlock; +import com.hrznstudio.titanium.recipe.generator.TitaniumRecipeProvider; +import com.hrznstudio.titanium.recipe.generator.TitaniumShapedRecipeBuilder; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.recipes.UpgradeRecipeBuilder; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Items; +import net.minecraft.world.item.crafting.Ingredient; +import net.minecraft.world.level.block.Block; +import net.minecraftforge.common.Tags; +import net.minecraftforge.common.util.NonNullLazy; +import net.minecraftforge.registries.ForgeRegistries; + +import java.util.List; +import java.util.function.Consumer; + +import static com.buuz135.functionalstorage.FunctionalStorage.*; + +public class FunctionalStorageRecipesProvider extends TitaniumRecipeProvider { + + private NonNullLazy> blocksToProcess; + + public FunctionalStorageRecipesProvider(DataGenerator generator, NonNullLazy> blocksToProcess) { + super(generator); + this.blocksToProcess = blocksToProcess; + } + + @Override + public void register(Consumer consumer) { + blocksToProcess.get().stream().map(block -> (BasicBlock) block).forEach(basicBlock -> basicBlock.registerRecipe(consumer)); + TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.IRON).get()) + .pattern("III").pattern("IDI").pattern("III") + .define('I', Tags.Items.INGOTS_IRON) + .define('D', StorageTags.DRAWER) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(VOID_UPGRADE.get()) + .pattern("III").pattern("IDI").pattern("III") + .define('I', Tags.Items.OBSIDIAN) + .define('D', StorageTags.DRAWER) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(CONFIGURATION_TOOL.get()) + .pattern("PPG").pattern("PDG").pattern("PEP") + .define('P', Items.PAPER) + .define('G', Tags.Items.INGOTS_GOLD) + .define('D', StorageTags.DRAWER) + .define('E', Items.EMERALD) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(LINKING_TOOL.get()) + .pattern("PPG").pattern("PDG").pattern("PEP") + .define('P', Items.PAPER) + .define('G', Tags.Items.INGOTS_GOLD) + .define('D', StorageTags.DRAWER) + .define('E', Items.DIAMOND) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.COPPER).get()) + .pattern("IBI").pattern("CDC").pattern("IBI") + .define('I', Items.COPPER_INGOT) + .define('B', Items.COPPER_BLOCK) + .define('C', Tags.Items.CHESTS_WOODEN) + .define('D', StorageTags.DRAWER) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.GOLD).get()) + .pattern("IBI").pattern("CDC").pattern("BIB") + .define('I', Tags.Items.INGOTS_GOLD) + .define('B', Tags.Items.STORAGE_BLOCKS_GOLD) + .define('C', Tags.Items.CHESTS_WOODEN) + .define('D', STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.COPPER).get()) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()) + .pattern("IBI").pattern("CDC").pattern("IBI") + .define('I', Tags.Items.GEMS_DIAMOND) + .define('B', Tags.Items.STORAGE_BLOCKS_DIAMOND) + .define('C', Tags.Items.CHESTS_WOODEN) + .define('D', STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.GOLD).get()) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(REDSTONE_UPGRADE.get()) + .pattern("IBI").pattern("CDC").pattern("IBI") + .define('I', Items.REDSTONE) + .define('B', Items.REDSTONE_BLOCK) + .define('C', Items.COMPARATOR) + .define('D', StorageTags.DRAWER) + .save(consumer); + UpgradeRecipeBuilder.smithing(Ingredient.of(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()), Ingredient.of(Items.NETHERITE_INGOT), STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get()) + .unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT)) + .save(consumer, ForgeRegistries.ITEMS.getKey(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get())); + TitaniumShapedRecipeBuilder.shapedRecipe(ARMORY_CABINET.getLeft().get()) + .pattern("ICI").pattern("CDC").pattern("IBI") + .define('I', Tags.Items.STONE) + .define('B', Tags.Items.INGOTS_NETHERITE) + .define('C', StorageTags.DRAWER) + .define('D', Items.COMPARATOR) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(PULLING_UPGRADE.get()) + .pattern("ICI").pattern("IDI").pattern("IBI") + .define('I', Tags.Items.STONE) + .define('B', Tags.Items.DUSTS_REDSTONE) + .define('C', Items.HOPPER) + .define('D', StorageTags.DRAWER) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(PUSHING_UPGRADE.get()) + .pattern("IBI").pattern("IDI").pattern("IRI") + .define('I', Tags.Items.STONE) + .define('B', Tags.Items.DUSTS_REDSTONE) + .define('R', Items.HOPPER) + .define('D', StorageTags.DRAWER) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(COLLECTOR_UPGRADE.get()) + .pattern("IBI").pattern("RDR").pattern("IBI") + .define('I', Tags.Items.STONE) + .define('B', Items.HOPPER) + .define('R', Tags.Items.DUSTS_REDSTONE) + .define('D', StorageTags.DRAWER) + .save(consumer); + TitaniumShapedRecipeBuilder.shapedRecipe(ENDER_DRAWER.getLeft().get()) + .pattern("PPP").pattern("LCL").pattern("PPP") + .define('P', ItemTags.PLANKS) + .define('C', Tags.Items.CHESTS_ENDER) + .define('L', StorageTags.DRAWER) + .save(consumer); + } +} diff --git a/src/main/java/com/buuz135/functionalstorage/recipe/CustomCompactingRecipe.java b/src/main/java/com/buuz135/functionalstorage/recipe/CustomCompactingRecipe.java new file mode 100644 index 00000000..49506fad --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/recipe/CustomCompactingRecipe.java @@ -0,0 +1,70 @@ +package com.buuz135.functionalstorage.recipe; + +import com.buuz135.functionalstorage.FunctionalStorage; +import com.hrznstudio.titanium.recipe.serializer.GenericSerializer; +import com.hrznstudio.titanium.recipe.serializer.SerializableRecipe; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.Container; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.RecipeType; +import net.minecraft.world.level.Level; + +import java.util.ArrayList; +import java.util.List; + +public class CustomCompactingRecipe extends SerializableRecipe { + + public static List RECIPES = new ArrayList<>(); + + public ItemStack lower_input = ItemStack.EMPTY; + public ItemStack higher_input = ItemStack.EMPTY; + + public CustomCompactingRecipe(ResourceLocation resourceLocation) { + super(resourceLocation); + } + + public CustomCompactingRecipe(ResourceLocation resourceLocation, ItemStack lower_input, ItemStack higher_input) { + super(resourceLocation); + this.lower_input = lower_input; + this.higher_input = higher_input; + RECIPES.add(this); + } + + @Override + public boolean matches(Container inv, Level worldIn) { + return false; + } + + @Override + public ItemStack assemble(Container inv) { + return ItemStack.EMPTY; + } + + @Override + public boolean canCraftInDimensions(int width, int height) { + return false; + } + + @Override + public ItemStack getResultItem() { + return ItemStack.EMPTY; + } + + @Override + public GenericSerializer getSerializer() { + return (GenericSerializer) FunctionalStorage.CUSTOM_COMPACTING_RECIPE_SERIALIZER.get(); + } + + @Override + public RecipeType getType() { + return FunctionalStorage.CUSTOM_COMPACTING_RECIPE_TYPE.get(); + } + + public ItemStack getLower_input() { + return lower_input; + } + + public ItemStack getHigher_input() { + return higher_input; + } +} diff --git a/src/main/java/com/buuz135/functionalstorage/util/CompactingUtil.java b/src/main/java/com/buuz135/functionalstorage/util/CompactingUtil.java index 6cf7d92d..9d9c1933 100644 --- a/src/main/java/com/buuz135/functionalstorage/util/CompactingUtil.java +++ b/src/main/java/com/buuz135/functionalstorage/util/CompactingUtil.java @@ -1,5 +1,8 @@ package com.buuz135.functionalstorage.util; +import com.buuz135.functionalstorage.FunctionalStorage; +import com.buuz135.functionalstorage.recipe.CustomCompactingRecipe; +import com.hrznstudio.titanium.util.RecipeUtil; import net.minecraft.core.NonNullList; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.player.Player; @@ -10,6 +13,7 @@ import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.RecipeType; import net.minecraft.world.level.Level; +import net.minecraftforge.items.ItemHandlerHelper; import net.minecraftforge.registries.ForgeRegistries; import java.util.*; @@ -27,11 +31,13 @@ public class CompactingUtil { private final Level level; private List results; private final int resultAmount; + private final List recipes; public CompactingUtil(Level level, int resultAmount) { this.level = level; this.resultAmount = resultAmount; this.results = new ArrayList<>(); + this.recipes = (List) RecipeUtil.getRecipes(level, FunctionalStorage.CUSTOM_COMPACTING_RECIPE_TYPE.get()); } public void setup(ItemStack stack){ @@ -71,6 +77,11 @@ public List getResults() { } private Result findUpperTier(ItemStack stack){ + for (CustomCompactingRecipe recipe : this.recipes) { + if (ItemStack.isSame(recipe.lower_input, stack)) { + return new Result(ItemHandlerHelper.copyStackWithSize(recipe.higher_input, 1), recipe.lower_input.getCount()); + } + } //Checking 3x3 int sizeCheck = 9; CraftingContainer container = createContainerAndFill(3, stack); @@ -108,6 +119,11 @@ private Result findUpperTier(ItemStack stack){ } private Result findLowerTier(ItemStack stack){ + for (CustomCompactingRecipe recipe : this.recipes) { + if (ItemStack.isSame(recipe.higher_input, stack)) { + return new Result(ItemHandlerHelper.copyStackWithSize(recipe.lower_input, 1), recipe.lower_input.getCount()); + } + } List candidates = new ArrayList<>(); Map candidatesRate = new HashMap<>(); for (CraftingRecipe craftingRecipe : level.getRecipeManager().getAllRecipesFor(RecipeType.CRAFTING)) { @@ -131,12 +147,13 @@ private Result findLowerTier(ItemStack stack){ } } } + ItemStack similar = findSimilar(stack, candidates); if (!similar.isEmpty()){ return new Result(similar, candidatesRate.get(similar)); } - if (candidates.size() > 0){ - return new Result(candidates.get(0), candidatesRate.get(candidates.get(0))); + if (!candidates.isEmpty()) { + return new Result(candidates.get(0).copy(), candidatesRate.get(candidates.get(0))); } return new Result(ItemStack.EMPTY, 0); }