Skip to content

Commit

Permalink
feat: datagen some block tags
Browse files Browse the repository at this point in the history
  • Loading branch information
CallMeEchoCodes committed Nov 24, 2024
1 parent a9d42dc commit 95be990
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"replace": false,
"values": [
"hollow:stripped_oak_hollow_log",
"hollow:oak_hollow_log",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package dev.spiritstudios.hollow.datagen;

import dev.spiritstudios.hollow.HollowTags;
import dev.spiritstudios.hollow.block.HollowLogBlock;
import dev.spiritstudios.hollow.registry.HollowBlockRegistrar;
import dev.spiritstudios.specter.api.core.util.ReflectionHelper;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.TagBuilder;
import net.minecraft.util.Identifier;

import java.util.concurrent.CompletableFuture;

public class BlockTagProvider extends FabricTagProvider.BlockTagProvider {
public BlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}

@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
TagBuilder hollowLogs = getTagBuilder(HollowTags.HOLLOW_LOGS);
TagBuilder axeMineable = getTagBuilder(BlockTags.AXE_MINEABLE);

ReflectionHelper.forEachStaticField(
HollowBlockRegistrar.class,
HollowLogBlock.class,
(block, name, field) -> {
Identifier id = Registries.BLOCK.getId(block);
hollowLogs.add(id);
axeMineable.add(id);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
pack.addProvider(ConfiguredFeatureProvider::new);
pack.addProvider(PlacedFeatureProvider::new);
pack.addProvider(BlockMetatagProvider::new);
pack.addProvider(BlockTagProvider::new);
}

@Override
Expand Down

0 comments on commit 95be990

Please sign in to comment.