got tags working

This commit is contained in:
Ell 2023-07-24 17:56:29 +02:00
parent 2ed4e45d38
commit b2e7a3f467
92 changed files with 245 additions and 307 deletions

1
.gitignore vendored
View file

@ -12,6 +12,7 @@
/classes
/bin/
/run/
/run-data/
/logs
*.classpath

View file

@ -83,6 +83,9 @@ minecraft {
source sourceSets.main
}
}
property 'mixin.env.remapRefMap', 'true'
property 'mixin.env.refMapRemappingFile', "${projectDir}/build/createSrgToMcp/output.srg"
}
client {

View file

@ -1,15 +0,0 @@
{
"values": [
"naturesaura:ancient_bark",
"naturesaura:ancient_log",
"naturesaura:ancient_planks",
"naturesaura:ancient_slab",
"naturesaura:ancient_stairs",
"naturesaura:auto_crafter",
"naturesaura:flower_generator",
"naturesaura:nether_wart_mushroom",
"naturesaura:oak_generator",
"naturesaura:offering_table",
"naturesaura:wood_stand"
]
}

View file

@ -1,49 +0,0 @@
{
"values": [
"naturesaura:animal_container",
"naturesaura:animal_generator",
"naturesaura:animal_spawner",
"naturesaura:aura_detector",
"naturesaura:aura_timer",
"naturesaura:blast_furnace_booster",
"naturesaura:chorus_generator",
"naturesaura:chunk_loader",
"naturesaura:conversion_catalyst",
"naturesaura:crushing_catalyst",
"naturesaura:depth_ingot_block",
"naturesaura:ender_crate",
"naturesaura:field_creator",
"naturesaura:firework_generator",
"naturesaura:furnace_heater",
"naturesaura:generator_limit_remover",
"naturesaura:gold_brick",
"naturesaura:gold_nether_brick",
"naturesaura:grated_chute",
"naturesaura:hopper_upgrade",
"naturesaura:infused_brick",
"naturesaura:infused_brick_slab",
"naturesaura:infused_brick_stairs",
"naturesaura:infused_iron_block",
"naturesaura:infused_slab",
"naturesaura:infused_stairs",
"naturesaura:infused_stone",
"naturesaura:item_distributor",
"naturesaura:lower_limiter",
"naturesaura:moss_generator",
"naturesaura:nature_altar",
"naturesaura:nether_grass",
"naturesaura:pickup_stopper",
"naturesaura:placer",
"naturesaura:potion_generator",
"naturesaura:powder_placer",
"naturesaura:projectile_generator",
"naturesaura:rf_converter",
"naturesaura:sky_ingot_block",
"naturesaura:snow_creator",
"naturesaura:spawn_lamp",
"naturesaura:spring",
"naturesaura:tainted_gold_block",
"naturesaura:time_changer",
"naturesaura:weather_changer"
]
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_bark"
}

View file

@ -26,5 +26,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_leaves"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_log"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_planks"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_sapling"
}

View file

@ -30,5 +30,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_slab"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ancient_stairs"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/animal_container"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/animal_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/animal_spawner"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/aura_bloom"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/aura_cactus"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/aura_detector"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/aura_mushroom"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/aura_timer"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/auto_crafter"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/blast_furnace_booster"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/chorus_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/chunk_loader"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/conversion_catalyst"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/crimson_aura_mushroom"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/crushing_catalyst"
}

View file

@ -26,5 +26,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/decayed_leaves"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/depth_ingot_block"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/dimension_rail_end"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/dimension_rail_nether"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/dimension_rail_overworld"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/end_flower"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/ender_crate"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/field_creator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/firework_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/flower_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/furnace_heater"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/generator_limit_remover"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/gold_brick"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/gold_nether_brick"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/gold_powder"
}

View file

@ -29,5 +29,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/golden_leaves"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/grated_chute"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/hopper_upgrade"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_brick"
}

View file

@ -30,5 +30,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_brick_slab"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_brick_stairs"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_iron_block"
}

View file

@ -30,5 +30,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_slab"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_stairs"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/infused_stone"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/item_distributor"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/light"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/lower_limiter"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/moss_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/nature_altar"
}

View file

@ -11,30 +11,17 @@
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:alternative",
"terms": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:shears"
]
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
]
}
}
],
"name": "naturesaura:nether_grass"
@ -48,5 +35,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/nether_grass"
}

View file

@ -11,30 +11,17 @@
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:alternative",
"terms": [
{
"condition": "minecraft:match_tool",
"predicate": {
"items": [
"minecraft:shears"
]
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
},
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
]
]
}
}
],
"name": "naturesaura:nether_wart_mushroom"
@ -59,5 +46,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/nether_wart_mushroom"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/oak_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/offering_table"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/pickup_stopper"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/placer"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/potion_generator"
}

View file

@ -26,10 +26,11 @@
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:aura_bloom"
"name": "minecraft:air"
}
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/potted_aura_bloom"
}

View file

@ -26,10 +26,11 @@
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:aura_cactus"
"name": "minecraft:air"
}
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/potted_aura_cactus"
}

View file

@ -26,10 +26,11 @@
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:aura_mushroom"
"name": "minecraft:air"
}
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/potted_aura_mushroom"
}

View file

@ -26,10 +26,11 @@
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:crimson_aura_mushroom"
"name": "minecraft:air"
}
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/potted_crimson_aura_mushroom"
}

View file

@ -26,10 +26,11 @@
"entries": [
{
"type": "minecraft:item",
"name": "naturesaura:warped_aura_mushroom"
"name": "minecraft:air"
}
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/potted_warped_aura_mushroom"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/powder_placer"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/projectile_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/rf_converter"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/sky_ingot_block"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/slime_split_generator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/snow_creator"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/spawn_lamp"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/spring"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/tainted_gold_block"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/time_changer"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/warped_aura_mushroom"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/weather_changer"
}

View file

@ -16,5 +16,6 @@
],
"rolls": 1.0
}
]
],
"random_sequence": "naturesaura:blocks/wood_stand"
}

View file

@ -1,7 +1,5 @@
package de.ellpeck.naturesaura.data;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import de.ellpeck.naturesaura.blocks.BlockFlowerPot;
import de.ellpeck.naturesaura.blocks.BlockGoldenLeaves;
import de.ellpeck.naturesaura.blocks.ModBlocks;
@ -9,114 +7,51 @@ import de.ellpeck.naturesaura.blocks.Slab;
import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
import net.minecraft.data.CachedOutput;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider;
import net.minecraft.data.loot.BlockLoot;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.FlowerPotBlock;
import net.minecraft.world.level.storage.loot.LootPool;
import net.minecraft.world.level.storage.loot.LootTable;
import net.minecraft.world.level.storage.loot.LootTables;
import net.minecraft.world.level.storage.loot.entries.LootItem;
import net.minecraft.world.level.storage.loot.entries.LootPoolEntryContainer;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.predicates.ConditionUserBuilder;
import net.minecraft.world.level.storage.loot.predicates.LootItemBlockStatePropertyCondition;
import net.minecraft.world.level.storage.loot.predicates.LootItemRandomChanceCondition;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import net.minecraftforge.registries.ForgeRegistries;
import javax.annotation.Nonnull;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.Set;
public class BlockLootProvider implements DataProvider {
public class BlockLootProvider extends BlockLootSubProvider {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
private final DataGenerator generator;
private final Map<Block, Function<Block, LootTable.Builder>> lootFunctions = new HashMap<>();
public BlockLootProvider(DataGenerator generator) {
this.generator = generator;
public BlockLootProvider() {
super(Set.of(), FeatureFlags.REGISTRY.allFlags());
}
@Override
protected void generate() {
for (var item : ModRegistry.ALL_ITEMS) {
if (!(item instanceof Block block))
continue;
if (block instanceof Slab) {
this.lootFunctions.put(block, LootTableHooks::genSlab);
this.add(block, this::createSlabItemTable);
} else if (block instanceof BlockFlowerPot) {
this.lootFunctions.put(block, LootTableHooks::genFlowerPot);
this.add(block, this::createPotFlowerItemTable);
} else {
this.lootFunctions.put(block, LootTableHooks::genRegular);
this.dropSelf(block);
}
}
this.lootFunctions.put(ModBlocks.ANCIENT_LEAVES, LootTableHooks::genSilkOnly);
this.lootFunctions.put(ModBlocks.DECAYED_LEAVES, LootTableHooks::genSilkOnly);
this.lootFunctions.put(ModBlocks.GOLDEN_LEAVES, b -> LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(LootTableHooks.survivesExplosion(b, LootItem.lootTableItem(ModItems.GOLD_LEAF)).when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(b).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).when(LootItemRandomChanceCondition.randomChance(0.75F))));
this.lootFunctions.put(ModBlocks.NETHER_WART_MUSHROOM, b -> LootTableHooks.genSilkOr(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2)))));
this.lootFunctions.put(ModBlocks.NETHER_GRASS, b -> LootTableHooks.genSilkOr(b, LootItem.lootTableItem(Blocks.NETHERRACK)));
}
private static Path getPath(Path root, ResourceLocation res) {
return root.resolve("data/" + res.getNamespace() + "/loot_tables/blocks/" + res.getPath() + ".json");
this.add(ModBlocks.ANCIENT_LEAVES, BlockLootProvider::createSilkTouchOnlyTable);
this.add(ModBlocks.DECAYED_LEAVES, BlockLootProvider::createSilkTouchOnlyTable);
this.add(ModBlocks.GOLDEN_LEAVES, b -> LootTable.lootTable().withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)).add(this.applyExplosionCondition(b, LootItem.lootTableItem(ModItems.GOLD_LEAF)).when(LootItemBlockStatePropertyCondition.hasBlockStateProperties(b).setProperties(StatePropertiesPredicate.Builder.properties().hasProperty(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).when(LootItemRandomChanceCondition.randomChance(0.75F))));
this.add(ModBlocks.NETHER_WART_MUSHROOM, b -> BlockLootSubProvider.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Items.NETHER_WART).apply(SetItemCountFunction.setCount(UniformGenerator.between(1, 2)))));
this.add(ModBlocks.NETHER_GRASS, b -> BlockLootSubProvider.createSilkTouchDispatchTable(b, LootItem.lootTableItem(Blocks.NETHERRACK)));
}
@Override
public void run(CachedOutput cache) throws IOException {
for (var function : this.lootFunctions.entrySet()) {
var block = function.getKey();
var func = function.getValue();
var table = func.apply(block).setParamSet(LootContextParamSets.BLOCK).build();
var path = BlockLootProvider.getPath(this.generator.getOutputFolder(), ForgeRegistries.BLOCKS.getKey(block));
DataProvider.saveStable(cache, LootTables.serialize(table), path);
}
}
@Nonnull
@Override
public String getName() {
return "Nature's Aura Loot";
}
// What a mess
private static class LootTableHooks extends BlockLoot {
public static LootTable.Builder genLeaves(Block block, Block drop) {
return BlockLoot.createLeavesDrops(block, drop, 0.05F, 0.0625F, 0.083333336F, 0.1F);
}
public static LootTable.Builder genSlab(Block block) {
return BlockLoot.createSlabItemTable(block);
}
public static LootTable.Builder genRegular(Block block) {
return BlockLoot.createSingleItemTable(block);
}
public static LootTable.Builder genSilkOnly(Block block) {
return BlockLoot.createSilkTouchOnlyTable(block);
}
public static LootTable.Builder genSilkOr(Block block, LootPoolEntryContainer.Builder<?> builder) {
return BlockLoot.createSilkTouchOrShearsDispatchTable(block, builder);
}
public static LootTable.Builder genFlowerPot(Block block) {
return BlockLoot.createPotFlowerItemTable(((FlowerPotBlock) block).getContent());
}
public static <T extends ConditionUserBuilder<T>> T survivesExplosion(Block block, ConditionUserBuilder<T> then) {
return BlockLoot.applyExplosionCondition(block, then);
}
protected Iterable<Block> getKnownBlocks() {
return ModRegistry.ALL_ITEMS.stream().filter(i -> i instanceof Block).map(i -> (Block) i).toList();
}
}

View file

@ -3,15 +3,15 @@ package de.ellpeck.naturesaura.data;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.model.generators.BlockStateProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
public class BlockStateGenerator extends BlockStateProvider {
public BlockStateGenerator(DataGenerator gen, ExistingFileHelper exFileHelper) {
super(gen, NaturesAura.MOD_ID, exFileHelper);
public BlockStateGenerator(PackOutput output, ExistingFileHelper exFileHelper) {
super(output, NaturesAura.MOD_ID, exFileHelper);
}
@Override

View file

@ -4,18 +4,19 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.resources.ResourceLocation;
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.BlockTagsProvider;
import net.minecraftforge.common.data.ExistingFileHelper;
import org.jetbrains.annotations.Nullable;
import java.util.Comparator;
import java.util.concurrent.CompletableFuture;
public class BlockTagProvider extends BlockTagsProvider {
@ -24,12 +25,12 @@ public class BlockTagProvider extends BlockTagsProvider {
public static final TagKey<Block> ALTAR_GOLD_BRICK = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_gold_brick"));
public static final TagKey<Block> ALTAR_FANCY_BRICK = BlockTags.create(new ResourceLocation(NaturesAura.MOD_ID, "altar_fancy_brick"));
public BlockTagProvider(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper) {
super(gen, NaturesAura.MOD_ID, existingFileHelper);
public BlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, NaturesAura.MOD_ID, existingFileHelper);
}
@Override
protected void addTags() {
protected void addTags(HolderLookup.Provider provider) {
this.tag(BlockTags.LOGS).add(ModBlocks.ANCIENT_LOG, ModBlocks.ANCIENT_BARK);
this.tag(BlockTags.PLANKS).add(ModBlocks.ANCIENT_PLANKS);
this.tag(BlockTags.STAIRS).add(ModBlocks.ANCIENT_STAIRS, ModBlocks.INFUSED_BRICK_STAIRS, ModBlocks.INFUSED_STAIRS);
@ -45,12 +46,13 @@ public class BlockTagProvider extends BlockTagsProvider {
// sort these so that they don't change the json every time we run data (because it's a set)
ModRegistry.ALL_ITEMS.stream().sorted(Comparator.comparing(IModItem::getBaseName)).filter(i -> i instanceof Block).map(i -> (Block) i).forEach(b -> {
var material = b.defaultBlockState().getMaterial();
// TODO figure out what to do about materials for mineability
/*var material = b.defaultBlockState().getMaterial();
if (material == Material.STONE || material == Material.METAL) {
this.tag(BlockTags.MINEABLE_WITH_PICKAXE).add(b);
} else if (material == Material.WOOD) {
this.tag(BlockTags.MINEABLE_WITH_AXE).add(b);
}
}*/
});
}
}

View file

@ -4,7 +4,7 @@ import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.reg.ICustomItemModel;
import de.ellpeck.naturesaura.reg.INoItemBlock;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.client.model.generators.ItemModelProvider;
@ -12,8 +12,8 @@ import net.minecraftforge.common.data.ExistingFileHelper;
public class ItemModelGenerator extends ItemModelProvider {
public ItemModelGenerator(DataGenerator generator, ExistingFileHelper existingFileHelper) {
super(generator, NaturesAura.MOD_ID, existingFileHelper);
public ItemModelGenerator(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, NaturesAura.MOD_ID, existingFileHelper);
}
@Override

View file

@ -6,27 +6,29 @@ import de.ellpeck.naturesaura.items.ModItems;
import de.ellpeck.naturesaura.items.tools.*;
import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.tags.BlockTagsProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.IntrinsicHolderTagsProvider;
import net.minecraft.data.tags.ItemTagsProvider;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.tags.TagKey;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper;
import java.util.Comparator;
import java.util.concurrent.CompletableFuture;
public class ItemTagProvider extends ItemTagsProvider {
public ItemTagProvider(DataGenerator generatorIn, BlockTagsProvider blockTagProvider, ExistingFileHelper helper) {
super(generatorIn, blockTagProvider, NaturesAura.MOD_ID, helper);
public ItemTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, CompletableFuture<TagLookup<Block>> blockTagProvider, ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, blockTagProvider, NaturesAura.MOD_ID, existingFileHelper);
}
@Override
protected void addTags() {
protected void addTags(HolderLookup.Provider provider) {
this.copy(BlockTags.LOGS, ItemTags.LOGS);
this.copy(BlockTags.PLANKS, ItemTags.PLANKS);
this.copy(BlockTags.STAIRS, ItemTags.STAIRS);

View file

@ -1,21 +1,29 @@
package de.ellpeck.naturesaura.data;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraftforge.data.event.GatherDataEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import java.util.List;
import java.util.Set;
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
public final class ModData {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
var generator = event.getGenerator();
var ex = event.getExistingFileHelper();
var blockTags = new BlockTagProvider(generator, ex);
generator.addProvider(event.includeServer(), blockTags);
generator.addProvider(event.includeServer(), new ItemTagProvider(generator, blockTags, ex));
generator.addProvider(event.includeServer(), new BlockLootProvider(generator));
generator.addProvider(event.includeServer(), new BlockStateGenerator(generator, ex));
generator.addProvider(event.includeServer(), new ItemModelGenerator(generator, ex));
var gen = event.getGenerator();
var out = gen.getPackOutput();
var lookup = event.getLookupProvider();
var existing = event.getExistingFileHelper();
var blockTags = new BlockTagProvider(out, lookup, existing);
gen.addProvider(event.includeServer(), blockTags);
gen.addProvider(event.includeServer(), new ItemTagProvider(out, lookup, blockTags.contentsGetter(), existing));
gen.addProvider(event.includeServer(), new LootTableProvider(out, Set.of(), List.of(new LootTableProvider.SubProviderEntry(BlockLootProvider::new, LootContextParamSets.BLOCK))));
gen.addProvider(event.includeServer(), new BlockStateGenerator(out, existing));
gen.addProvider(event.includeServer(), new ItemModelGenerator(out, existing));
}
}