From 67d059b3d064197e4a90c3877383226616cfda6a Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sun, 19 Dec 2021 18:59:54 +0100 Subject: [PATCH] Added recipes for the compacting drawer --- src/generated/resources/.cache/cache | 2 + .../recipes/compacting_drawer.json | 43 +++++++++++++++++++ .../functionalstorage/tags/items/drawer.json | 29 +++++++++++++ .../functionalstorage/FunctionalStorage.java | 3 ++ .../block/CompactingDrawerBlock.java | 16 +++++++ .../data/FunctionalStorageTagsProvider.java | 33 ++++++++++++++ .../functionalstorage/util/StorageTags.java | 13 ++++++ 7 files changed, 139 insertions(+) create mode 100644 src/generated/resources/data/functionalstorage/recipes/compacting_drawer.json create mode 100644 src/generated/resources/data/functionalstorage/tags/items/drawer.json create mode 100644 src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageTagsProvider.java create mode 100644 src/main/java/com/buuz135/functionalstorage/util/StorageTags.java diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index 223fbd2..496436d 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -54,6 +54,7 @@ e3138f15dbdc49225d5c66d2313cb4c6f1372ec3 data/functionalstorage/recipes/acacia_2 60434750145755324af7e86952e2905efc616f5e data/functionalstorage/recipes/birch_1.json b1e0180179e45d5dcce15a0d9e4c7240b32a0f0a data/functionalstorage/recipes/birch_2.json 1bb8f4e3018ec26c7ee8179198d114f5f8a5dcd5 data/functionalstorage/recipes/birch_4.json +2f055e6a11a6e3ccb23545268552792af4b8a4a4 data/functionalstorage/recipes/compacting_drawer.json b03ea02d6ccf84af8bf9482b2b0ddfa0284a5520 data/functionalstorage/recipes/crimson_1.json ea3bf44b8e70ee71f488c62cc674839ede650a04 data/functionalstorage/recipes/crimson_2.json 4a2c846cccedc425748130054972d7e0f2757276 data/functionalstorage/recipes/crimson_4.json @@ -72,3 +73,4 @@ ff234dac4f0b0b4f83ffa92f2d2fb1074c68df43 data/functionalstorage/recipes/spruce_4 bcb281904eac23183c45786e3d703d24bba92be6 data/functionalstorage/recipes/warped_1.json 8fc3f76a2c57eb4d80ce86947fabebe48fa6f692 data/functionalstorage/recipes/warped_2.json 7510a8ca1f1e3bb63f4c4f4add0bb6b713feaa0b data/functionalstorage/recipes/warped_4.json +f37e620a26ceb158507c607cee6ba3b51f14c6d6 data/functionalstorage/tags/items/drawer.json diff --git a/src/generated/resources/data/functionalstorage/recipes/compacting_drawer.json b/src/generated/resources/data/functionalstorage/recipes/compacting_drawer.json new file mode 100644 index 0000000..89f355b --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/compacting_drawer.json @@ -0,0 +1,43 @@ +{ + "type": "forge:conditional", + "recipes": [ + { + "conditions": [ + { + "values": [ + { + "item": "functionalstorage:compacting_drawer", + "type": "forge:item_exists" + } + ], + "type": "forge:and" + } + ], + "recipe": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "SSS", + "PDP", + "SIS" + ], + "key": { + "S": { + "item": "minecraft:stone" + }, + "P": { + "item": "minecraft:piston" + }, + "D": { + "tag": "functionalstorage:drawer" + }, + "I": { + "tag": "forge:ingots/iron" + } + }, + "result": { + "item": "functionalstorage:compacting_drawer" + } + } + } + ] +} \ 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 new file mode 100644 index 0000000..dd31495 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/tags/items/drawer.json @@ -0,0 +1,29 @@ +{ + "replace": false, + "values": [ + "functionalstorage:oak_2", + "functionalstorage:spruce_2", + "functionalstorage:birch_2", + "functionalstorage:jungle_2", + "functionalstorage:acacia_2", + "functionalstorage:dark_oak_2", + "functionalstorage:crimson_2", + "functionalstorage:warped_2", + "functionalstorage:oak_4", + "functionalstorage:spruce_4", + "functionalstorage:birch_4", + "functionalstorage:jungle_4", + "functionalstorage:acacia_4", + "functionalstorage:dark_oak_4", + "functionalstorage:crimson_4", + "functionalstorage:warped_4", + "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" + ] +} \ No newline at end of file diff --git a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java index baa7e34..264b067 100644 --- a/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java +++ b/src/main/java/com/buuz135/functionalstorage/FunctionalStorage.java @@ -5,6 +5,7 @@ import com.buuz135.functionalstorage.block.DrawerBlock; import com.buuz135.functionalstorage.client.CompactingDrawerRenderer; import com.buuz135.functionalstorage.client.DrawerRenderer; import com.buuz135.functionalstorage.data.FunctionalStorageBlockstateProvider; +import com.buuz135.functionalstorage.data.FunctionalStorageTagsProvider; import com.buuz135.functionalstorage.util.DrawerWoodType; import com.buuz135.functionalstorage.util.IWoodType; import com.hrznstudio.titanium.block.BasicBlock; @@ -16,6 +17,7 @@ import com.hrznstudio.titanium.module.ModuleController; import com.hrznstudio.titanium.recipe.generator.TitaniumRecipeProvider; import com.hrznstudio.titanium.tab.AdvancedTitaniumTab; import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.Block; @@ -123,5 +125,6 @@ public class FunctionalStorage extends ModuleController { blocksToProcess.get().stream().map(block -> (BasicBlock) block).forEach(basicBlock -> basicBlock.registerRecipe(consumer)); } }); + event.getGenerator().addProvider(new FunctionalStorageTagsProvider(event.getGenerator(),new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper())); } } diff --git a/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java index c6098e3..2698930 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/CompactingDrawerBlock.java @@ -3,16 +3,20 @@ package com.buuz135.functionalstorage.block; import com.buuz135.functionalstorage.FunctionalStorage; import com.buuz135.functionalstorage.block.tile.CompactingDrawerTile; import com.buuz135.functionalstorage.block.tile.DrawerTile; +import com.buuz135.functionalstorage.util.StorageTags; import com.google.common.collect.Multimap; import com.google.common.collect.MultimapBuilder; import com.hrznstudio.titanium.block.RotatableBlock; import com.hrznstudio.titanium.datagenerator.loot.block.BasicBlockLootTables; import com.hrznstudio.titanium.module.DeferredRegistryHelper; +import com.hrznstudio.titanium.recipe.generator.TitaniumShapedRecipeBuilder; import com.hrznstudio.titanium.util.RayTraceUtils; import com.hrznstudio.titanium.util.TileUtil; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.core.NonNullList; +import net.minecraft.data.recipes.FinishedRecipe; +import net.minecraft.tags.ItemTags; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.entity.player.Player; @@ -32,12 +36,14 @@ import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; +import net.minecraftforge.common.Tags; import org.jetbrains.annotations.NotNull; import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.function.Consumer; public class CompactingDrawerBlock extends RotatableBlock { @@ -149,4 +155,14 @@ public class CompactingDrawerBlock extends RotatableBlock return NonNullList.create(); } + @Override + public void registerRecipe(Consumer consumer) { + TitaniumShapedRecipeBuilder.shapedRecipe(this) + .pattern("SSS").pattern("PDP").pattern("SIS") + .define('S', Blocks.STONE) + .define('P', Blocks.PISTON) + .define('D', StorageTags.DRAWER) + .define('I', Tags.Items.INGOTS_IRON) + .save(consumer); + } } diff --git a/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageTagsProvider.java b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageTagsProvider.java new file mode 100644 index 0000000..a152cd1 --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/data/FunctionalStorageTagsProvider.java @@ -0,0 +1,33 @@ +package com.buuz135.functionalstorage.data; + +import com.buuz135.functionalstorage.FunctionalStorage; +import com.buuz135.functionalstorage.util.StorageTags; +import net.minecraft.data.DataGenerator; +import net.minecraft.data.tags.BlockTagsProvider; +import net.minecraft.data.tags.ItemTagsProvider; +import net.minecraft.data.tags.TagsProvider; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraftforge.common.data.ExistingFileHelper; +import net.minecraftforge.registries.RegistryObject; +import org.jetbrains.annotations.Nullable; + +import java.nio.file.Path; + +public class FunctionalStorageTagsProvider extends ItemTagsProvider { + + public FunctionalStorageTagsProvider(DataGenerator p_126530_, BlockTagsProvider p_126531_, String modId, @Nullable ExistingFileHelper existingFileHelper) { + super(p_126530_, p_126531_, modId, existingFileHelper); + } + + @Override + protected void addTags() { + TagsProvider.TagAppender tTagAppender = this.tag(StorageTags.DRAWER); + for (FunctionalStorage.DrawerType drawerType : FunctionalStorage.DRAWER_TYPES.keySet()) { + for (RegistryObject blockRegistryObject : FunctionalStorage.DRAWER_TYPES.get(drawerType)) { + tTagAppender.add(blockRegistryObject.get().asItem()); + } + } + } +} diff --git a/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java b/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java new file mode 100644 index 0000000..ae1cb89 --- /dev/null +++ b/src/main/java/com/buuz135/functionalstorage/util/StorageTags.java @@ -0,0 +1,13 @@ +package com.buuz135.functionalstorage.util; + +import com.buuz135.functionalstorage.FunctionalStorage; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.ItemTags; +import net.minecraft.world.item.Item; +import net.minecraftforge.common.Tags; + +public class StorageTags { + + public static Tags.IOptionalNamedTag DRAWER = ItemTags.createOptional(new ResourceLocation(FunctionalStorage.MOD_ID, "drawer")); + +}