From 13f3b75df611ddb2c6ae707f785e43beca46ac6f Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Fri, 30 Sep 2022 15:14:10 +0200 Subject: [PATCH] fixed some blocks not dropping anything when broken Adresses #277 --- .../minecraft/tags/blocks/mineable/pickaxe.json | 15 +++++++++++++++ .../naturesaura/data/BlockTagProvider.java | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json diff --git a/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json new file mode 100644 index 00000000..a8d3ed08 --- /dev/null +++ b/src/generated/resources/data/minecraft/tags/blocks/mineable/pickaxe.json @@ -0,0 +1,15 @@ +{ + "values": [ + "naturesaura:spring", + "naturesaura:aura_timer", + "naturesaura:animal_container", + "naturesaura:blast_furnace_booster", + "naturesaura:snow_creator", + "naturesaura:chorus_generator", + "naturesaura:nether_grass", + "naturesaura:gold_nether_brick", + "naturesaura:gold_brick", + "naturesaura:item_distributor", + "naturesaura:weather_changer" + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java index 6719eaea..906348ef 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java +++ b/src/main/java/de/ellpeck/naturesaura/data/BlockTagProvider.java @@ -2,6 +2,7 @@ package de.ellpeck.naturesaura.data; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.blocks.ModBlocks; +import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.data.DataGenerator; import net.minecraft.data.tags.BlockTagsProvider; import net.minecraft.resources.ResourceLocation; @@ -9,6 +10,7 @@ import net.minecraft.tags.BlockTags; import net.minecraft.tags.TagKey; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.material.Material; import net.minecraftforge.common.data.ExistingFileHelper; import org.jetbrains.annotations.Nullable; @@ -38,5 +40,18 @@ public class BlockTagProvider extends BlockTagsProvider { this.tag(BlockTagProvider.NETHER_ALTAR_WOOD).add(Blocks.CRIMSON_PLANKS, Blocks.WARPED_PLANKS); this.tag(BlockTagProvider.NETHER_ALTAR_STONE).add(Blocks.NETHER_BRICKS); + for (var item : ModRegistry.ALL_ITEMS) { + if (!(item instanceof Block b)) + continue; + var state = b.defaultBlockState(); + if (!state.requiresCorrectToolForDrops()) + continue; + var material = state.getMaterial(); + if (material == Material.STONE) { + this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(b); + } else if (material == Material.WOOD) { + this.tag(BlockTags.MINEABLE_WITH_AXE).add(b); + } + } } }