Skip to content

Commit

Permalink
feat: allow neo and forge book providers to take custom registry prov…
Browse files Browse the repository at this point in the history
…iders
  • Loading branch information
klikli-dev committed Dec 3, 2024
1 parent 18777c4 commit 3662949
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,33 @@

package com.klikli_dev.modonomicon.api.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraftforge.data.event.GatherDataEvent;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public class ForgeBookProvider {

/**
* Creates a new BookProvider with the given subProviders. This is the main entry point for book generation, as each BookSubProvider represents one book or leaflet.
* @param event the gather data event that will be used to access datagen context needed for the provider.
* @param subProviders the sub providers to generate books from.
* @return the book provider to register on the DataGenerator provided by the GatherDataEvent.
*/
public static BookProvider of(GatherDataEvent event, BookSubProvider... subProviders) {
return new BookProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), event.getModContainer().getModId(), List.of(subProviders));
}

/**
* Creates a new BookProvider with the given subProviders. This is the main entry point for book generation, as each BookSubProvider represents one book or leaflet.
* This overload allows to pass a custom CompletableFuture for the HolderLookup.Provider. The main use case for this is to provide a HolderLookup.Provide returned by DatapackBuiltinEntriesProvider#getRegistryProvider() to access datapack registries in the book generation.
* @param event the gather data event that will be used to access datagen context needed for the provider.
* @param lookupProvider the lookup provider to use for the book generation.
* @param subProviders the sub providers to generate books from.
* @return the book provider to register on the DataGenerator provided by the GatherDataEvent.
*/
public static BookProvider of(GatherDataEvent event, CompletableFuture<HolderLookup.Provider> lookupProvider, BookSubProvider... subProviders) {
return new BookProvider(event.getGenerator().getPackOutput(), lookupProvider, event.getModContainer().getModId(), List.of(subProviders));
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ group=com.klikli_dev
mod_id=modonomicon
mod_name=Modonomicon
mod_license=MIT AND CC-BY-4.0
mod_version=1.106.0
mod_version=1.110.0
mod_authors=Kli Kli
mod_description=Data-driven minecraft in-game documentation with progress visualization.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,34 @@

package com.klikli_dev.modonomicon.api.datagen;

import net.minecraft.core.HolderLookup;
import net.neoforged.neoforge.data.event.GatherDataEvent;

import java.util.List;
import java.util.concurrent.CompletableFuture;

public class NeoBookProvider {
/**
* Creates a new BookProvider with the given subProviders. This is the main entry point for book generation, as each BookSubProvider represents one book or leaflet.
*
* @param event the gather data event that will be used to access datagen context needed for the provider.
* @param subProviders the sub providers to generate books from.
* @return the book provider to register on the DataGenerator provided by the GatherDataEvent.
*/
public static BookProvider of(GatherDataEvent event, BookSubProvider... subProviders) {
return new BookProvider(event.getGenerator().getPackOutput(), event.getLookupProvider(), event.getModContainer().getModId(), List.of(subProviders));
}

/**
* Creates a new BookProvider with the given subProviders. This is the main entry point for book generation, as each BookSubProvider represents one book or leaflet.
* This overload allows to pass a custom CompletableFuture for the HolderLookup.Provider. The main use case for this is to provide a HolderLookup.Provide returned by DatapackBuiltinEntriesProvider#getRegistryProvider() to access datapack registries in the book generation.
*
* @param event the gather data event that will be used to access datagen context needed for the provider.
* @param lookupProvider the lookup provider to use for the book generation.
* @param subProviders the sub providers to generate books from.
* @return the book provider to register on the DataGenerator provided by the GatherDataEvent.
*/
public static BookProvider of(GatherDataEvent event, CompletableFuture<HolderLookup.Provider> lookupProvider, BookSubProvider... subProviders) {
return new BookProvider(event.getGenerator().getPackOutput(), lookupProvider, event.getModContainer().getModId(), List.of(subProviders));
}
}

0 comments on commit 3662949

Please sign in to comment.