Skip to content

Commit

Permalink
Finished Datagenerators too make it easier and faster in adding model…
Browse files Browse the repository at this point in the history
…s recipes tags etc...

Spiritual Fire has been added as a fuel using the firecharge texture (thats temporary)
  • Loading branch information
MrEizy committed Sep 11, 2024
1 parent cbc69e7 commit aad41c1
Show file tree
Hide file tree
Showing 37 changed files with 450 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// 1.21 2024-09-11T10:55:09.196605 Item Models: ascension
3ad9a12ddaf5421f386991c79685ecfdeb06d79f assets/ascension/models/item/jade.json
ebe2ed83136a87351440556549a452ac29cd9d4f assets/ascension/models/item/peach.json
e38ccf1284a27e3fb50fd8cceb40628da797236a assets/ascension/models/item/spiritual_fire.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// 1.21 2024-09-11T10:22:29.8725753 Tags for minecraft:block mod id ascension
d9443f955f1eb385377adc7594d2873c571243ab data/minecraft/tags/block/mineable/pickaxe.json
d9443f955f1eb385377adc7594d2873c571243ab data/minecraft/tags/block/needs_iron_tool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21 2024-09-11T10:22:29.871072 Tags for minecraft:item mod id ascension
d9be6b415ca01466373194f5d9db52b5f30806d4 data/ascension/tags/item/ascension_item.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21 2024-09-11T09:39:35.3773707 Loot Tables
57bb7a7f3ca90dd11fbf957b2e2bc353df616830 data/ascension/loot_table/blocks/jade_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// 1.21 2024-09-11T10:38:08.9743012 Recipes
dc2129d95844f8f9a2e48ebf668843b8711708f9 data/ascenion/advancement/recipes/misc/jade_block_to_jade.json
89a010bb5c47ee10b93526647cde14bd7bb99a91 data/ascenion/recipe/jade_block_to_jade.json
45a656c3621c890dd10dadfb825092ba1e9d4a73 data/ascension/advancement/recipes/misc/jade_to_jade_block.json
00f712e28e7fa174b24d7e32a3ae890441c6f8b1 data/ascension/recipe/jade_to_jade_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// 1.21 2024-09-11T09:54:41.8554172 Block States: ascension
edd98a3b59f53a47a23db11b31f7ce43caaf4358 assets/ascension/blockstates/jade_block.json
51998acf770b2c2865d7b6210bc2a32015eb64b3 assets/ascension/models/block/jade_block.json
1c96dd4d1df9714c262c740c8ae0c4b53ad3c691 assets/ascension/models/item/jade_block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21 2024-09-11T10:55:09.1956046 Data Maps
b04060e50a839d6de8006f9dbe35a7473d05d0f0 data/neoforge/data_maps/item/furnace_fuels.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"variants": {
"": {
"model": "ascension:block/jade_block"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "ascension:item/spiritual_fire"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_jade_block": {
"conditions": {
"items": [
{
"items": "ascension:jade_block"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "ascenion:jade_block_to_jade"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_jade_block"
]
],
"rewards": {
"recipes": [
"ascenion:jade_block_to_jade"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "ascension:jade_block"
}
],
"result": {
"count": 9,
"id": "ascension:jade"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_jade": {
"conditions": {
"items": [
{
"items": "ascension:jade"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "ascension:jade_to_jade_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_jade"
]
],
"rewards": {
"recipes": [
"ascension:jade_to_jade_block"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "ascension:jade_block"
}
],
"rolls": 1.0
}
],
"random_sequence": "ascension:blocks/jade_block"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"B": {
"item": "ascension:jade"
}
},
"pattern": [
"BBB",
"BBB",
"BBB"
],
"result": {
"count": 1,
"id": "ascension:jade_block"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"ascension:jade",
"ascension:peach"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"ascension:jade_block"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"values": [
"ascension:jade_block"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"values": {
"ascension:spiritual_fire": {
"burn_time": 2400
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package net.thejadeproject.ascension.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.PackOutput;
import net.minecraft.data.loot.LootTableProvider;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.neoforged.bus.api.SubscribeEvent;
import net.neoforged.fml.common.EventBusSubscriber;
import net.neoforged.neoforge.common.data.BlockTagsProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.data.event.GatherDataEvent;
import net.thejadeproject.ascension.AscensionCraft;

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

@EventBusSubscriber(modid = AscensionCraft.MOD_ID, bus = EventBusSubscriber.Bus.MOD)
public class DataGenerators {
@SubscribeEvent
public static void gatherData(GatherDataEvent event) {
DataGenerator generator = event.getGenerator();
PackOutput packOutput = generator.getPackOutput();
ExistingFileHelper existingFileHelper = event.getExistingFileHelper();
CompletableFuture<HolderLookup.Provider> lookupProvider = event.getLookupProvider();

generator.addProvider(event.includeServer(), new LootTableProvider(packOutput, Collections.emptySet(),
List.of(new LootTableProvider.SubProviderEntry(ModBlockLootTableProvider::new, LootContextParamSets.BLOCK)), lookupProvider));
generator.addProvider(event.includeServer(), new ModRecipeProvider(packOutput, lookupProvider));

BlockTagsProvider blockTagsProvider = new ModBlockTagProvider(packOutput, lookupProvider,existingFileHelper);
generator.addProvider(event.includeServer(), blockTagsProvider);
generator.addProvider(event.includeServer(), new ModItemTagProvider(packOutput, lookupProvider, blockTagsProvider.contentsGetter(), existingFileHelper));

generator.addProvider(event.includeServer(), new ModDataMapProvider(packOutput, lookupProvider));

generator.addProvider(event.includeClient(), new ModItemModelProvider(packOutput, existingFileHelper));
generator.addProvider(event.includeClient(), new ModBlockStateProvider(packOutput, existingFileHelper));

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package net.thejadeproject.ascension.datagen;

import net.minecraft.core.Holder;
import net.minecraft.core.HolderLookup;
import net.minecraft.data.loot.BlockLootSubProvider;
import net.minecraft.world.flag.FeatureFlagSet;
import net.minecraft.world.flag.FeatureFlags;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.thejadeproject.ascension.block.ModBlocks;

import java.util.Set;

public class ModBlockLootTableProvider extends BlockLootSubProvider {
protected ModBlockLootTableProvider(HolderLookup.Provider registries) {
super(Set.of(), FeatureFlags.REGISTRY.allFlags(), registries);
}

@Override
protected void generate() {
dropSelf(ModBlocks.JADE_BLOCK.get());
}


@Override
protected Iterable<Block> getKnownBlocks() {
return ModBlocks.BLOCKS.getEntries().stream().map(Holder::value)::iterator;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package net.thejadeproject.ascension.datagen;

import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.neoforged.neoforge.registries.DeferredBlock;
import net.thejadeproject.ascension.AscensionCraft;
import net.thejadeproject.ascension.block.ModBlocks;

public class ModBlockStateProvider extends BlockStateProvider {
public ModBlockStateProvider(PackOutput output, ExistingFileHelper exFileHelper) {
super(output, AscensionCraft.MOD_ID, exFileHelper);
}

@Override
protected void registerStatesAndModels() {
blockWithItem(ModBlocks.JADE_BLOCK);

}

private void blockWithItem(DeferredBlock<?> deferredBlock) {
simpleBlockWithItem(deferredBlock.get(), cubeAll(deferredBlock.get()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.thejadeproject.ascension.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.minecraft.tags.BlockTags;
import net.neoforged.neoforge.common.data.BlockTagsProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.thejadeproject.ascension.AscensionCraft;
import net.thejadeproject.ascension.block.ModBlocks;
import org.jetbrains.annotations.Nullable;

import java.util.concurrent.CompletableFuture;

public class ModBlockTagProvider extends BlockTagsProvider {
public ModBlockTagProvider(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, AscensionCraft.MOD_ID, existingFileHelper);
}

@Override
protected void addTags(HolderLookup.Provider provider) {
tag(BlockTags.MINEABLE_WITH_PICKAXE)
.add(ModBlocks.JADE_BLOCK.get());

tag(BlockTags.NEEDS_IRON_TOOL)
.add(ModBlocks.JADE_BLOCK.get());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.thejadeproject.ascension.datagen;

import net.minecraft.core.HolderLookup;
import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.common.data.DataMapProvider;
import net.neoforged.neoforge.registries.datamaps.builtin.FurnaceFuel;
import net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps;
import net.thejadeproject.ascension.item.ModItems;

import java.util.concurrent.CompletableFuture;

public class ModDataMapProvider extends DataMapProvider {
protected ModDataMapProvider(PackOutput packOutput, CompletableFuture<HolderLookup.Provider> lookupProvider) {
super(packOutput, lookupProvider);
}

@Override
protected void gather() {
this.builder(NeoForgeDataMaps.FURNACE_FUELS)
.add(ModItems.SPIRITUAL_FIRE.getId(), new FurnaceFuel(2400), false);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package net.thejadeproject.ascension.datagen;

import net.minecraft.data.PackOutput;
import net.neoforged.neoforge.client.model.generators.ItemModelProvider;
import net.neoforged.neoforge.common.data.ExistingFileHelper;
import net.thejadeproject.ascension.AscensionCraft;
import net.thejadeproject.ascension.item.ModItems;

public class ModItemModelProvider extends ItemModelProvider {
public ModItemModelProvider(PackOutput output, ExistingFileHelper existingFileHelper) {
super(output, AscensionCraft.MOD_ID, existingFileHelper);
}

@Override
protected void registerModels() {
basicItem(ModItems.JADE.get());

basicItem(ModItems.PEACH.get());
basicItem(ModItems.SPIRITUAL_FIRE.get());

}
}
Loading

0 comments on commit aad41c1

Please sign in to comment.