Skip to content

Commit

Permalink
Add default names to all data providers.
Browse files Browse the repository at this point in the history
  • Loading branch information
covers1624 committed Apr 26, 2024
1 parent baf638f commit 24d2c4f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/main/java/codechicken/lib/datagen/ItemModelProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ private ExistingFileHelper getExistingFileHelper() {
return existingFileHelper;
}

@Override
public String getName() {
return modid + " Item models.";
}

public static class SimpleItemModelBuilder {

private final ItemModelProvider provider;
Expand Down
19 changes: 10 additions & 9 deletions src/main/java/codechicken/lib/datagen/LootTableProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@
public abstract class LootTableProvider implements DataProvider {

private static final Logger logger = LogManager.getLogger();
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();

private final PackOutput.PathProvider output;
protected final String modId;
private final Map<ResourceLocation, LootTable> tables = new HashMap<>();

protected LootTableProvider(PackOutput output) {
protected LootTableProvider(PackOutput output, String modId) {
this.output = output.createPathProvider(PackOutput.Target.DATA_PACK, "loot_tables");
this.modId = modId;
}

@Override
Expand Down Expand Up @@ -88,19 +89,15 @@ protected void registerTable(ResourceLocation name, LootTable table) {
}
}

private static Path getPath(Path pathIn, ResourceLocation id) {
return pathIn.resolve("data/" + id.getNamespace() + "/loot_tables/" + id.getPath() + ".json");
}

public static abstract class BlockLootProvider extends LootTableProvider {

protected static final LootItemCondition.Builder SILK_TOUCH = MatchTool.toolMatches(ItemPredicate.Builder.item()
.hasEnchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.Ints.atLeast(1)))
);
protected static final LootItemCondition.Builder NO_SILK_TOUCH = SILK_TOUCH.invert();

protected BlockLootProvider(PackOutput output) {
super(output);
protected BlockLootProvider(PackOutput output, String modId) {
super(output, modId);
}

protected LootPool.Builder singleItem(ItemLike item) {
Expand Down Expand Up @@ -160,6 +157,10 @@ public void register(Block block, LootTable.Builder builder) {
protected void register(ResourceLocation name, LootTable.Builder builder) {
registerTable(new ResourceLocation(name.getNamespace(), "blocks/" + name.getPath()), builder.setParamSet(LootContextParamSets.BLOCK).build());
}
}

@Override
public String getName() {
return modId + " Block Loot Tables";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ public abstract class RecipeProvider implements DataProvider {

private final Map<ResourceLocation, RecipeBuilder> recipes = new HashMap<>();
private final PackOutput output;
protected final String modId;

public RecipeProvider(PackOutput output) {
public RecipeProvider(PackOutput output, String modId) {
this.output = output;
this.modId = modId;
}

@Override
Expand Down Expand Up @@ -169,4 +171,9 @@ protected InventoryChangeTrigger.TriggerInstance hasItem(TagKey<Item> tagIn) {
protected InventoryChangeTrigger.TriggerInstance hasItem(ItemPredicate... predicates) {
return new InventoryChangeTrigger.TriggerInstance(ContextAwarePredicate.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, MinMaxBounds.Ints.ANY, predicates);
}

@Override
public String getName() {
return modId + " Recipes.";
}
}

0 comments on commit 24d2c4f

Please sign in to comment.