vague more attempts at Datagen fixes

This commit is contained in:
Talia-12 2023-06-20 18:50:29 +10:00
parent 488cc3ea74
commit e745ff6773
4 changed files with 62 additions and 25 deletions

View file

@ -1,16 +1,17 @@
package at.petrak.hexcasting.datagen;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.common.blocks.circles.BlockEntitySlate;
import at.petrak.hexcasting.common.lib.HexBlocks;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.common.loot.HexLootHandler;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import at.petrak.paucal.api.datagen.PaucalLootTableProvider;
import at.petrak.paucal.api.datagen.PaucalLootTableSubProvider;
import net.minecraft.advancements.critereon.EnchantmentPredicate;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.advancements.critereon.MinMaxBounds;
import net.minecraft.advancements.critereon.StatePropertiesPredicate;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DataProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.enchantment.Enchantments;
@ -27,16 +28,19 @@ import net.minecraft.world.level.storage.loot.functions.ApplyBonusCount;
import net.minecraft.world.level.storage.loot.functions.ApplyExplosionDecay;
import net.minecraft.world.level.storage.loot.functions.CopyNbtFunction;
import net.minecraft.world.level.storage.loot.functions.SetItemCountFunction;
import net.minecraft.world.level.storage.loot.predicates.*;
import net.minecraft.world.level.storage.loot.predicates.BonusLevelTableCondition;
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.predicates.MatchTool;
import net.minecraft.world.level.storage.loot.providers.nbt.ContextNbtProvider;
import net.minecraft.world.level.storage.loot.providers.number.ConstantValue;
import net.minecraft.world.level.storage.loot.providers.number.UniformGenerator;
import java.util.Map;
public class HexLootTables extends PaucalLootTableProvider {
public HexLootTables(DataGenerator pGenerator) {
super(pGenerator);
public class HexLootTables extends PaucalLootTableSubProvider {
public HexLootTables() {
super(HexAPI.MOD_ID);
}
@Override

View file

@ -3,19 +3,22 @@ package at.petrak.hexcasting.datagen.tag;
import at.petrak.hexcasting.api.casting.ActionRegistryEntry;
import at.petrak.hexcasting.api.mod.HexTags;
import at.petrak.hexcasting.xplat.IXplatAbstractions;
import net.minecraft.data.DataGenerator;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.resources.ResourceKey;
import java.util.concurrent.CompletableFuture;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
public class HexActionTagProvider extends TagsProvider<ActionRegistryEntry> {
public HexActionTagProvider(DataGenerator generator) {
super(generator, IXplatAbstractions.INSTANCE.getActionRegistry());
public HexActionTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> provider) {
super(output, IXplatAbstractions.INSTANCE.getActionRegistry(), provider);
}
@Override
protected void addTags() {
protected void addTags(HolderLookup.Provider provider) {
// In-game almost all great spells are always per-world
for (var normalGreat : new String[]{
"lightning", "flight", "create_lava", "teleport", "sentinel/create/great",

View file

@ -1,39 +1,54 @@
package at.petrak.hexcasting.datagen.tag;
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.mod.HexTags;
import at.petrak.hexcasting.common.lib.HexItems;
import at.petrak.hexcasting.xplat.IXplatTags;
import at.petrak.paucal.api.datagen.PaucalItemTagProvider;
import net.minecraft.core.HolderLookup;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.data.tags.TagsProvider;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ItemTags;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.Block;
import java.util.concurrent.CompletableFuture;
public class HexItemTagProvider extends PaucalItemTagProvider {
private final IXplatTags xtags;
public HexItemTagProvider(DataGenerator pGenerator, TagsProvider<Block> pBlockTagsProvider, IXplatTags xtags) {
super(pGenerator, pBlockTagsProvider);
public HexItemTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookup, TagsProvider<Block> pBlockTagsProvider, IXplatTags xtags) {
super(output, lookup, HexAPI.MOD_ID, pBlockTagsProvider);
this.xtags = xtags;
}
@Override
protected void addTags() {
tag(xtags.gems()).add(HexItems.CHARGED_AMETHYST);
tag(xtags.amethystDust()).add(HexItems.AMETHYST_DUST);
tag(HexTags.Items.STAVES).add(HexItems.STAFF_EDIFIED,
@Override
protected void addTags(HolderLookup.Provider provider) {
add(tag(xtags.gems()),
HexItems.CHARGED_AMETHYST);
add(tag(xtags.amethystDust()),
HexItems.AMETHYST_DUST);
add(tag(HexTags.Items.STAVES),
HexItems.STAFF_EDIFIED,
HexItems.STAFF_OAK, HexItems.STAFF_SPRUCE, HexItems.STAFF_BIRCH,
HexItems.STAFF_JUNGLE, HexItems.STAFF_ACACIA, HexItems.STAFF_DARK_OAK,
HexItems.STAFF_CRIMSON, HexItems.STAFF_WARPED, HexItems.STAFF_MANGROVE,
HexItems.STAFF_QUENCHED, HexItems.STAFF_MINDSPLICE);
tag(HexTags.Items.PHIAL_BASE).add(Items.GLASS_BOTTLE);
tag(HexTags.Items.GRANTS_ROOT_ADVANCEMENT).add(HexItems.AMETHYST_DUST, Items.AMETHYST_SHARD,
add(tag(HexTags.Items.PHIAL_BASE),
Items.GLASS_BOTTLE);
add(tag(HexTags.Items.GRANTS_ROOT_ADVANCEMENT),
HexItems.AMETHYST_DUST, Items.AMETHYST_SHARD,
HexItems.CHARGED_AMETHYST);
tag(HexTags.Items.SEAL_MATERIALS).add(Items.HONEYCOMB);
add(tag(HexTags.Items.SEAL_MATERIALS),
Items.HONEYCOMB);
this.copy(HexTags.Blocks.EDIFIED_LOGS, HexTags.Items.EDIFIED_LOGS);
this.copy(HexTags.Blocks.EDIFIED_PLANKS, HexTags.Items.EDIFIED_PLANKS);
@ -55,4 +70,10 @@ public class HexItemTagProvider extends PaucalItemTagProvider {
this.copy(BlockTags.BUTTONS, ItemTags.BUTTONS);
this.copy(BlockTags.WOODEN_BUTTONS, ItemTags.WOODEN_BUTTONS);
}
void add(TagAppender<Item> appender, Item... items) {
for (Item item : items) {
appender.add(BuiltInRegistries.ITEM.getResourceKey(item).orElseThrow());
}
}
}

View file

@ -28,18 +28,27 @@ public class HexFabricDataGenerators implements DataGeneratorEntrypoint {
public void onInitializeDataGenerator(FabricDataGenerator gen) {
HexAPI.LOGGER.info("Starting Fabric-specific datagen");
gen.addProvider(new HexplatRecipes(gen, INGREDIENTS, HexFabricConditionsBuilder::new));
var pack = gen.createPack();
pack.addProvider((FabricDataGenerator.Pack.Factory<HexplatRecipes>) x -> new HexplatRecipes(x, INGREDIENTS, HexFabricConditionsBuilder::new));
var xtags = IXplatAbstractions.INSTANCE.tags();
var blockTagProvider = new HexBlockTagProvider(gen, xtags);
gen.addProvider(blockTagProvider);
gen.addProvider(new HexItemTagProvider(gen, blockTagProvider, xtags));
var btagProviderWrapper = new BlockTagProviderWrapper(); // CURSED
pack.addProvider((output, lookup) -> {
btagProviderWrapper.provider = new HexBlockTagProvider(output, lookup, xtags);
return btagProviderWrapper.provider;
});
pack.addProvider((output, lookup) -> new HexItemTagProvider(output, lookup, btagProviderWrapper.provider, xtags));
gen.addProvider(new HexActionTagProvider(gen));
pack.addProvider(HexActionTagProvider::new);
gen.addProvider(new HexLootTables(gen));
}
private static class BlockTagProviderWrapper {
HexBlockTagProvider provider;
}
private static final IXplatIngredients INGREDIENTS = new IXplatIngredients() {
@Override
public Ingredient glowstoneDust() {