From c77dae246755687296e5e8d0b80b008bcf999a86 Mon Sep 17 00:00:00 2001 From: Buuz135 Date: Sun, 3 Jul 2022 20:33:52 +0200 Subject: [PATCH] Fixed Drawer drops and added some missing data --- .../loot_tables/blocks/framed_1.json | 3 ++ .../loot_tables/blocks/framed_2.json | 3 ++ .../loot_tables/blocks/framed_4.json | 3 ++ .../functionalstorage/recipes/framed_1.json | 37 ++++++++++++++++++ .../functionalstorage/recipes/framed_2.json | 38 +++++++++++++++++++ .../functionalstorage/recipes/framed_4.json | 38 +++++++++++++++++++ .../minecraft/tags/blocks/mineable/axe.json | 35 +++++++++-------- .../block/FramedDrawerBlock.java | 33 ++++++++++++++++ 8 files changed, 174 insertions(+), 16 deletions(-) create mode 100644 src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_1.json create mode 100644 src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_2.json create mode 100644 src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_4.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/framed_1.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/framed_2.json create mode 100644 src/generated/resources/data/functionalstorage/recipes/framed_4.json diff --git a/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_1.json b/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_1.json new file mode 100644 index 0000000..68701f9 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_1.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:block" +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_2.json b/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_2.json new file mode 100644 index 0000000..68701f9 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_2.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:block" +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_4.json b/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_4.json new file mode 100644 index 0000000..68701f9 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/loot_tables/blocks/framed_4.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:block" +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/framed_1.json b/src/generated/resources/data/functionalstorage/recipes/framed_1.json new file mode 100644 index 0000000..de3af52 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/framed_1.json @@ -0,0 +1,37 @@ +{ + "type": "forge:conditional", + "recipes": [ + { + "conditions": [ + { + "values": [ + { + "item": "functionalstorage:framed_1", + "type": "forge:item_exists" + } + ], + "type": "forge:and" + } + ], + "recipe": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "PPP", + "PCP", + "PPP" + ], + "key": { + "P": { + "item": "minecraft:iron_nugget" + }, + "C": { + "tag": "forge:chests/wooden" + } + }, + "result": { + "item": "functionalstorage:framed_1" + } + } + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/framed_2.json b/src/generated/resources/data/functionalstorage/recipes/framed_2.json new file mode 100644 index 0000000..e8487a2 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/framed_2.json @@ -0,0 +1,38 @@ +{ + "type": "forge:conditional", + "recipes": [ + { + "conditions": [ + { + "values": [ + { + "item": "functionalstorage:framed_2", + "type": "forge:item_exists" + } + ], + "type": "forge:and" + } + ], + "recipe": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "PCP", + "PPP", + "PCP" + ], + "key": { + "P": { + "item": "minecraft:iron_nugget" + }, + "C": { + "tag": "forge:chests/wooden" + } + }, + "result": { + "item": "functionalstorage:framed_2", + "count": 2 + } + } + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/functionalstorage/recipes/framed_4.json b/src/generated/resources/data/functionalstorage/recipes/framed_4.json new file mode 100644 index 0000000..96b46f4 --- /dev/null +++ b/src/generated/resources/data/functionalstorage/recipes/framed_4.json @@ -0,0 +1,38 @@ +{ + "type": "forge:conditional", + "recipes": [ + { + "conditions": [ + { + "values": [ + { + "item": "functionalstorage:framed_4", + "type": "forge:item_exists" + } + ], + "type": "forge:and" + } + ], + "recipe": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "CPC", + "PPP", + "CPC" + ], + "key": { + "P": { + "item": "minecraft:iron_nugget" + }, + "C": { + "tag": "forge:chests/wooden" + } + }, + "result": { + "item": "functionalstorage:framed_4", + "count": 4 + } + } + } + ] +} \ 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 6dff867..9e05415 100644 --- a/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/axe.json @@ -1,14 +1,15 @@ { "replace": false, "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: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:framed_2", "functionalstorage:oak_4", "functionalstorage:spruce_4", "functionalstorage:birch_4", @@ -17,13 +18,15 @@ "functionalstorage:dark_oak_4", "functionalstorage:crimson_4", "functionalstorage:warped_4", - "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:framed_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", + "functionalstorage:framed_1" ] } \ No newline at end of file diff --git a/src/main/java/com/buuz135/functionalstorage/block/FramedDrawerBlock.java b/src/main/java/com/buuz135/functionalstorage/block/FramedDrawerBlock.java index 996b7ae..6d4a2ee 100644 --- a/src/main/java/com/buuz135/functionalstorage/block/FramedDrawerBlock.java +++ b/src/main/java/com/buuz135/functionalstorage/block/FramedDrawerBlock.java @@ -12,19 +12,25 @@ import com.hrznstudio.titanium.recipe.generator.TitaniumShapedRecipeBuilder; import com.hrznstudio.titanium.util.ItemHandlerUtil; import com.hrznstudio.titanium.util.TileUtil; import net.minecraft.core.BlockPos; +import net.minecraft.core.NonNullList; import net.minecraft.data.recipes.FinishedRecipe; import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.tooltip.TooltipComponent; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.entity.BlockEntityType; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.storage.loot.LootContext; +import net.minecraft.world.level.storage.loot.parameters.LootContextParams; +import net.minecraft.world.phys.HitResult; import net.minecraftforge.common.Tags; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.items.ItemHandlerHelper; @@ -33,6 +39,7 @@ import org.apache.commons.lang3.tuple.Pair; import org.jetbrains.annotations.Nullable; import java.util.HashMap; +import java.util.List; import java.util.Optional; import java.util.function.Consumer; @@ -77,6 +84,32 @@ public class FramedDrawerBlock extends DrawerBlock{ return drawer; } + @Override + public List getDrops(BlockState p_60537_, LootContext.Builder builder) { + NonNullList stacks = NonNullList.create(); + ItemStack stack = new ItemStack(this); + BlockEntity drawerTile = builder.getOptionalParameter(LootContextParams.BLOCK_ENTITY); + if (drawerTile instanceof FramedDrawerTile) { + if (!((FramedDrawerTile) drawerTile).isEverythingEmpty()) { + stack.getOrCreateTag().put("Tile", drawerTile.saveWithoutMetadata()); + } + stack.getOrCreateTag().put("Style", ((FramedDrawerTile) drawerTile).getFramedDrawerModelData().serializeNBT()); + } + stacks.add(stack); + return stacks; + } + + @Override + public ItemStack getCloneItemStack(BlockState state, HitResult target, BlockGetter level, BlockPos pos, Player player) { + BlockEntity entity = level.getBlockEntity(pos); + if (entity instanceof FramedDrawerTile framedDrawerTile){ + ItemStack stack = new ItemStack(this); + stack.getOrCreateTag().put("Style", framedDrawerTile.getFramedDrawerModelData().serializeNBT()); + return stack; + } + return super.getCloneItemStack(state, target, level, pos, player); + } + @Override public void registerRecipe(Consumer consumer) { if (this.getType() == FunctionalStorage.DrawerType.X_1) {