Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use data generation #175

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ jobs:
- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Run Data Generation
run: ./gradlew runDatagen

- name: Build with Gradle
run: ./gradlew build

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ bin/
# fabric

run/
src/main/generated/
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ repositories {
maven { url = "https://repo.viaversion.com" }
}

fabricApi {
configureDataGeneration {
createSourceSet = true
modId = "nucleoid_extras"
}
}

dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
Expand Down
19 changes: 19 additions & 0 deletions src/datagen/java/xyz/nucleoid/extras/data/NEDatagen.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package xyz.nucleoid.extras.data;

import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
import xyz.nucleoid.extras.data.provider.NEAdvancementProvider;
import xyz.nucleoid.extras.data.provider.NEBlockTagProvider;
import xyz.nucleoid.extras.data.provider.NEItemTagProvider;

public class NEDatagen implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator dataGenerator) {
var pack = dataGenerator.createPack();

pack.addProvider(NEAdvancementProvider::new);

var blockTags = pack.addProvider(NEBlockTagProvider::new);
pack.addProvider((dataOutput, registries) -> new NEItemTagProvider(dataOutput, registries, blockTags));
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package xyz.nucleoid.extras.data.provider;

import java.util.concurrent.CompletableFuture;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
import net.minecraft.registry.tag.BlockTags;
import xyz.nucleoid.extras.lobby.NEBlocks;
import xyz.nucleoid.extras.tag.NEBlockTags;

public class NEBlockTagProvider extends FabricTagProvider.BlockTagProvider {
public NEBlockTagProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registries) {
super(dataOutput, registries);
}

@Override
protected void configure(WrapperLookup lookup) {
this.getOrCreateTagBuilder(BlockTags.DOORS)
.add(NEBlocks.TRANSIENT_IRON_DOOR);

this.getOrCreateTagBuilder(NEBlockTags.LUCKY_TATER_DROPS)
.add(NEBlocks.BRONZE_CAPSULE_TATER)
.add(NEBlocks.SILVER_CAPSULE_TATER)
.add(NEBlocks.GOLD_CAPSULE_TATER);

this.getOrCreateTagBuilder(NEBlockTags.NON_VIBRATING_TATERS)
.addOptionalTag(BlockTags.DAMPENS_VIBRATIONS)
.add(NEBlocks.WARDEN_TATER);

this.getOrCreateTagBuilder(BlockTags.WOODEN_DOORS)
.add(NEBlocks.TRANSIENT_OAK_DOOR)
.add(NEBlocks.TRANSIENT_SPRUCE_DOOR)
.add(NEBlocks.TRANSIENT_BIRCH_DOOR)
.add(NEBlocks.TRANSIENT_JUNGLE_DOOR)
.add(NEBlocks.TRANSIENT_ACACIA_DOOR)
.add(NEBlocks.TRANSIENT_CHERRY_DOOR)
.add(NEBlocks.TRANSIENT_DARK_OAK_DOOR)
.add(NEBlocks.TRANSIENT_MANGROVE_DOOR)
.add(NEBlocks.TRANSIENT_BAMBOO_DOOR)
.add(NEBlocks.TRANSIENT_CRIMSON_DOOR)
.add(NEBlocks.TRANSIENT_WARPED_DOOR);

this.getOrCreateTagBuilder(NEBlockTags.VIRAL_TATERS)
.add(NEBlocks.VIRAL_TATER);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package xyz.nucleoid.extras.data.provider;

import java.util.concurrent.CompletableFuture;

import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.RegistryWrapper.WrapperLookup;
import net.minecraft.registry.tag.BlockTags;
import net.minecraft.registry.tag.ItemTags;

public class NEItemTagProvider extends FabricTagProvider.ItemTagProvider {
public NEItemTagProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registries, FabricTagProvider.BlockTagProvider blockTags) {
super(dataOutput, registries, blockTags);
}

@Override
protected void configure(WrapperLookup lookup) {
this.copy(BlockTags.DOORS, ItemTags.DOORS);
this.copy(BlockTags.WOODEN_DOORS, ItemTags.WOODEN_DOORS);
}
}
5 changes: 0 additions & 5 deletions src/main/resources/data/minecraft/tags/blocks/doors.json

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/resources/data/minecraft/tags/blocks/wooden_doors.json

This file was deleted.

5 changes: 0 additions & 5 deletions src/main/resources/data/minecraft/tags/items/doors.json

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/resources/data/minecraft/tags/items/wooden_doors.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading