USE DATAGEN
Some checks failed
构建 / build (push) Has been cancelled

This commit is contained in:
David-123 2025-03-15 01:51:08 +08:00
parent c6be33d99c
commit 877f0378a7
51 changed files with 462 additions and 78 deletions

View File

@ -65,6 +65,10 @@ jar {
}
}
//tasks.withType(Copy).all {
// duplicatesStrategy 'exclude'
//}
// configure the maven publication
publishing {
publications {

View File

@ -0,0 +1,7 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/FabricLearningRecipeProvider
909cf34a9dd2590a5904c5c305eb6627e4007e16 data/learning/advancement/recipes/food/baked_toast_from_smelting_toast.json
48e4de17c89453877299044a387ab270980a73f0 data/learning/advancement/recipes/food/overcooked_toast_from_smelting_baked_toast.json
3f312674e372bc99fef50332fe3b73ad2f0b8e8c data/learning/advancement/recipes/misc/damage_block.json
fa465ec49923885685cd0d0d97d1a8a8f86a6f9b data/learning/recipe/baked_toast_from_smelting_toast.json
4f79f807a401252843d3deab2fd21c0426477f21 data/learning/recipe/damage_block.json
073bdd46b2248dd3adcfda31d2ccfacef839d5a2 data/learning/recipe/overcooked_toast_from_smelting_baked_toast.json

View File

@ -0,0 +1,13 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/FabricDocsReference Model Provider
9b929e7065d522bc2f535cbf0be27b781747764c assets/learning/blockstates/damage_block.json
ae0d992c57701b5c4cfa1f74886b0c6643382dde assets/learning/blockstates/transform_block.json
7e8a7842ae92f24d68423d756ce6a9a33187439b assets/learning/items/baked_toast.json
d9cfa06092e4a6b79cf7d701c70deeb937b88155 assets/learning/items/damage_block.json
a47afe35b341d49ea1af4b9039c7ee7c5747fa5d assets/learning/items/overcooked_toast.json
bc0cb59f5b489dfdf541e42499fb4a28b9bacea0 assets/learning/items/toast.json
296544cf2c1bf4c18575d1637bd95cccd86bd6ba assets/learning/items/transform_block.json
61b7662769db9c343a2b01449f74b47dee072d69 assets/learning/models/block/damage_block.json
afa3a162ab44856a979f7206b9d9047fba19d45b assets/learning/models/block/transform_block.json
4f29a35228f6e93e29262172a11e8aaa145a10f9 assets/learning/models/item/baked_toast.json
7ac95480ea0a3b708095eda1fbff11ab770450b1 assets/learning/models/item/overcooked_toast.json
0ee68562153eab4dd8756c1c0d14ed8e67fd692f assets/learning/models/item/toast.json

View File

@ -0,0 +1,2 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/Tags for minecraft:block
38a917b5f6cf798e0cf0c65180771a0f310de0da data/minecraft/tags/block/mineable/pickaxe.json

View File

@ -0,0 +1,3 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/Block Loot Tables
0098930b7ed8d4f99711b81a043962b5a29d992b data/learning/loot_table/blocks/damage_block.json
3c5485c4b7890adb359efda5037235e72e85c33a data/learning/loot_table/blocks/transform_block.json

View File

@ -0,0 +1,2 @@
// 1.21.4 -999999999-01-01T00:00:00 Learning/Tags for minecraft:item
5930563a7f50b4e9c1f59dedf432c4fba846138c data/learning/tags/item/diamond_transformable.json

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "learning:block/damage_block"
}
}
}

View File

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "learning:block/transform_block"
}
}
}

View File

@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "learning:item/overcooked_toast"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/cube_bottom_top",
"textures": {
"bottom": "learning:block/white_block_bottom",
"side": "learning:block/damage_block_side",
"top": "learning:block/damage_block_top"
}
}

View File

@ -0,0 +1,8 @@
{
"parent": "minecraft:block/cube_bottom_top",
"textures": {
"bottom": "learning:block/white_block_bottom",
"side": "learning:block/transform_block_side",
"top": "learning:block/transform_block_top"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "learning:item/baked_toast"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "learning:item/overcooked_toast"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "learning:item/toast"
}
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:baked_toast_from_smelting_toast"
},
"trigger": "minecraft:recipe_unlocked"
},
"has_toast": {
"conditions": {
"items": [
{
"items": "learning:toast"
}
]
},
"trigger": "minecraft:inventory_changed"
}
},
"requirements": [
[
"has_the_recipe",
"has_toast"
]
],
"rewards": {
"recipes": [
"minecraft:baked_toast_from_smelting_toast"
]
}
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_baked_toast": {
"conditions": {
"items": [
{
"items": "learning:baked_toast"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:overcooked_toast_from_smelting_baked_toast"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_baked_toast"
]
],
"rewards": {
"recipes": [
"minecraft:overcooked_toast_from_smelting_baked_toast"
]
}
}

View File

@ -0,0 +1,32 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_iron_sword": {
"conditions": {
"items": [
{
"items": "minecraft:iron_sword"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "learning:damage_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_the_recipe",
"has_iron_sword"
]
],
"rewards": {
"recipes": [
"learning:damage_block"
]
}
}

View File

@ -16,6 +16,5 @@
],
"rolls": 1.0
}
],
"random_sequence": "learning:blocks/damage_block"
]
}

View File

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "learning:transform_block"
}
],
"rolls": 1.0
}
]
}

View File

@ -3,6 +3,7 @@
"category": "food",
"cookingtime": 200,
"experience": 0.35,
"group": "toast_furnace",
"ingredient": "learning:toast",
"result": {
"id": "learning:baked_toast"

View File

@ -0,0 +1,18 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"B": "minecraft:iron_block",
"R": "minecraft:red_dye",
"S": "minecraft:iron_sword"
},
"pattern": [
"SSS",
"BRB",
"BBB"
],
"result": {
"count": 4,
"id": "learning:damage_block"
}
}

View File

@ -0,0 +1,11 @@
{
"type": "minecraft:smelting",
"category": "misc",
"cookingtime": 200,
"experience": 0.35,
"group": "toast_furnace",
"ingredient": "learning:baked_toast",
"result": {
"id": "learning:overcooked_toast"
}
}

View File

@ -0,0 +1,6 @@
{
"values": [
"minecraft:diamond",
"learning:baked_toast"
]
}

View File

@ -0,0 +1,5 @@
{
"values": [
"learning:damage_block"
]
}

View File

@ -3,6 +3,9 @@ package com.learning;
import com.learning.block.CustomBlocks;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.registry.CompostingChanceRegistry;
import net.fabricmc.fabric.api.registry.FuelRegistryEvents;
import net.minecraft.item.FuelRegistry;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -27,5 +30,14 @@ public class Learning implements ModInitializer {
CustomBlocks.registerBlocks();
CustomItems.registerItems();
CustomItemGroup.registerItemGroup();
LOGGER.info("Adding Fuel registries...");
FuelRegistryEvents.BUILD.register(((builder, context) -> {
builder.add(CustomItems.overcookedToast, 6000);
}));
LOGGER.info("Adding Compostable registries...");
CompostingChanceRegistry.INSTANCE.add(CustomItems.toast, 0.3f);
CompostingChanceRegistry.INSTANCE.add(CustomItems.bakedToast, 0.5f);
}
}

View File

@ -1,11 +1,17 @@
package com.learning;
import com.learning.datagen.*;
import net.fabricmc.fabric.api.datagen.v1.DataGeneratorEntrypoint;
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
public class LearningDataGenerator implements DataGeneratorEntrypoint {
@Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
pack.addProvider(ModModelProvider::new);
pack.addProvider(ModRecipeProvider::new);
pack.addProvider(ModItemTagProvider::new);
pack.addProvider(ModBlockTagProvider::new);
pack.addProvider(ModLootTableProvider::new);
}
}

View File

@ -18,20 +18,23 @@ public class CustomBlocks {
}
public static final Block testBlock = register("test_block");
public static final Block damageBlock = register("damage_block", DamageBlock::new, AbstractBlock.Settings.create());
public static final Block transformBlock = register("transform_block", TransformBlock::new, AbstractBlock.Settings.create());
public static final Block damageBlock = register("damage_block", DamageBlock::new, AbstractBlock.Settings.create().requiresTool());
public static final Block transformBlock = register("transform_block", TransformBlock::new);
public static final Block register(String blockId) {
public static Block register(String blockId) {
return register(blockId, Block::new, AbstractBlock.Settings.create());
}
public static Block register(String blockId, Function<AbstractBlock.Settings, Block> factory) {
return register(blockId, factory, AbstractBlock.Settings.create());
}
public static Block register(String blockId, Function<AbstractBlock.Settings, Block> factory, AbstractBlock.Settings settings) {
RegistryKey<Block> key = keyOf(blockId);
return Registry.register(Registries.BLOCK, key, factory.apply(settings.registryKey(key)));
}
private static final RegistryKey<Block> keyOf(String blockId) {
private static RegistryKey<Block> keyOf(String blockId) {
return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(Learning.MOD_ID, blockId));
}
}

View File

@ -0,0 +1,26 @@
package com.learning.datagen;
import com.learning.block.CustomBlocks;
import com.learning.item.CustomItems;
import com.learning.util.ModTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.BlockTags;
import java.util.concurrent.CompletableFuture;
public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider {
public ModBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}
@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(BlockTags.PICKAXE_MINEABLE)
.add(CustomBlocks.damageBlock);
}
}

View File

@ -0,0 +1,23 @@
package com.learning.datagen;
import com.learning.item.CustomItems;
import com.learning.util.ModTags;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.item.Items;
import net.minecraft.registry.RegistryWrapper;
import java.util.concurrent.CompletableFuture;
public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider {
public ModItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
super(output, completableFuture);
}
@Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(ModTags.ItemTags.DIAMOND_TRANSFORMABLE)
.add(Items.DIAMOND)
.add(CustomItems.bakedToast);
}
}

View File

@ -0,0 +1,20 @@
package com.learning.datagen;
import com.learning.block.CustomBlocks;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
import net.minecraft.registry.RegistryWrapper;
import java.util.concurrent.CompletableFuture;
public class ModLootTableProvider extends FabricBlockLootTableProvider {
public ModLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
super(dataOutput, registryLookup);
}
@Override
public void generate() {
addDrop(CustomBlocks.transformBlock);
addDrop(CustomBlocks.damageBlock);
}
}

View File

@ -0,0 +1,41 @@
package com.learning.datagen;
import com.learning.Learning;
import com.learning.block.CustomBlocks;
import com.learning.item.CustomItems;
import net.fabricmc.fabric.api.client.datagen.v1.provider.FabricModelProvider;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.minecraft.block.Block;
import net.minecraft.client.data.*;
import net.minecraft.util.Identifier;
public class ModModelProvider extends FabricModelProvider {
public ModModelProvider(FabricDataOutput output) {
super(output);
}
public TextureMap blockOnlySideTop(Block block) {
return new TextureMap()
.put(TextureKey.TOP, ModelIds.getBlockSubModelId(block, "_top"))
.put(TextureKey.BOTTOM, Identifier.of(Learning.MOD_ID, "block/white_block_bottom"))
.put(TextureKey.SIDE, ModelIds.getBlockSubModelId(block, "_side"));
}
@Override
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
blockStateModelGenerator.registerSingleton(CustomBlocks.damageBlock, TexturedModel.makeFactory(this::blockOnlySideTop, Models.CUBE_BOTTOM_TOP));
blockStateModelGenerator.registerSingleton(CustomBlocks.transformBlock, TexturedModel.makeFactory(this::blockOnlySideTop, Models.CUBE_BOTTOM_TOP));
}
@Override
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
itemModelGenerator.register(CustomItems.overcookedToast, Models.GENERATED);
itemModelGenerator.register(CustomItems.bakedToast, Models.GENERATED);
itemModelGenerator.register(CustomItems.toast, Models.GENERATED);
}
@Override
public String getName() {
return "FabricDocsReference Model Provider";
}
}

View File

@ -0,0 +1,51 @@
package com.learning.datagen;
import com.learning.item.CustomItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.recipe.CookingRecipeJsonBuilder;
import net.minecraft.data.recipe.RecipeExporter;
import net.minecraft.data.recipe.RecipeGenerator;
import net.minecraft.data.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.Items;
import net.minecraft.recipe.*;
import net.minecraft.recipe.book.CookingRecipeCategory;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.registry.RegistryWrapper;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class ModRecipeProvider extends FabricRecipeProvider {
public ModRecipeProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture);
}
@Override
protected RecipeGenerator getRecipeGenerator(RegistryWrapper.WrapperLookup wrapperLookup, RecipeExporter recipeExporter) {
return new RecipeGenerator(wrapperLookup, recipeExporter) {
@Override
public void generate() {
offerSmelting(List.of(CustomItems.toast), RecipeCategory.FOOD, CustomItems.bakedToast, 0.35f, 200, "toast_furnace");
offerSmelting(List.of(CustomItems.bakedToast), RecipeCategory.FOOD, CustomItems.overcookedToast, 0.35f, 200, "toast_furnace");
createShaped(RecipeCategory.MISC, CustomItems.damageBlock, 4)
.pattern("SSS")
.pattern("BRB")
.pattern("BBB")
.input('S', Items.IRON_SWORD)
.input('B', Items.IRON_BLOCK)
.input('R', Items.RED_DYE)
.criterion(hasItem(Items.IRON_SWORD), conditionsFromItem(Items.IRON_SWORD))
.offerTo(exporter);
}
};
}
@Override
public String getName() {
return "FabricLearningRecipeProvider";
}
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.consume.UseAction;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;

View File

@ -1,6 +1,7 @@
package com.learning.item;
import java.util.List;
import java.util.function.Function;
import com.learning.Learning;
@ -9,10 +10,15 @@ import com.learning.component.Foods;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.tooltip.TooltipType;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.block.Block;
import net.minecraft.component.type.ConsumableComponents;
@ -24,17 +30,27 @@ public class CustomItems {
public static Item toast = register("toast", Toast::new, new Item.Settings().food(Foods.toastFood));
public static Item bakedToast = register("baked_toast", BakedToast::new, new Item.Settings().food(Foods.bakedToastFood, ConsumableComponents.food().consumeSeconds(0.8f).build()));
public static Item overcookedToast = register(keyOf("overcooked_toast"), new Item(new Item.Settings().registryKey(keyOf("overcooked_toast"))) {
@Override
public void appendTooltip(ItemStack stack, TooltipContext context, List<Text> tooltip, TooltipType type) {
tooltip.add(Text.translatable("toolTip.learning.overcooked_toast").formatted(Formatting.GRAY));
super.appendTooltip(stack, context, tooltip, type);
}
});
public static Item damageBlock = register(CustomBlocks.damageBlock, false);
public static Item transformBlock = register(CustomBlocks.transformBlock, false);
private static Item register(Block block, Boolean useItemTranslateKey) {
if (Registries.BLOCK.getKey(block).isPresent()) {
RegistryKey<Item> key = keyOf(Registries.BLOCK.getKey(block).get());
Item.Settings settings = new Item.Settings().registryKey(key);
if (!useItemTranslateKey) {
settings.useBlockPrefixedTranslationKey();
}
return register(key, new BlockItem(block, settings));
}
return Items.AIR;
}
private static Item register(String itemId) {
@ -56,7 +72,6 @@ public class CustomItems {
private static Item register(RegistryKey<Item> key, Item item) {
return Registry.register(Registries.ITEM, key, item);
}
private static RegistryKey<Item> keyOf(String itemId) {

View File

@ -28,6 +28,7 @@ public class CustomItemGroup {
.entries((displayContext, entries) -> {
entries.add(CustomItems.toast);
entries.add(CustomItems.bakedToast);
entries.add(CustomItems.overcookedToast);
entries.add(CustomItems.damageBlock);
entries.add(CustomItems.transformBlock);
})

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "learning:block/damage_block"
}
}
}

View File

@ -1,7 +0,0 @@
{
"variants": {
"": {
"model": "learning:block/transform_block"
}
}
}

View File

@ -1,6 +1,7 @@
{
"item.learning.toast": "Toast",
"item.learning.baked_toast": "Baked Toast",
"item.learning.overcooked_toast": "Overcooked Toast",
"block.learning.damage_block": "Damage Block",
"block.learning.transform_block": "Transform Block",
@ -12,6 +13,7 @@
"toolTip.learning.toast1": "Will be tastier after baking in the furnace!",
"toolTip.learning.baked_toast": "Yummy!",
"toolTip.learning.damage_block": "Will hurt entities which stands on this block.",
"toolTip.learning.overcooked_toast": "It turns to coal, totally...",
"toolTip.learning.hold_control": "Hold §6Control §rto show more information.",
"toolTip.learning.hold_shift": "Hold §6Shift §rto show more information."

View File

@ -1,8 +0,0 @@
{
"parent": "block/cube_bottom_top",
"textures": {
"bottom": "learning:block/white_block_bottom",
"top": "learning:block/damage_block_top",
"side": "learning:block/damage_block_side"
}
}

View File

@ -1,8 +0,0 @@
{
"parent": "block/cube_bottom_top",
"textures": {
"bottom": "learning:block/white_block_bottom",
"top": "learning:block/transformblock_top",
"side": "learning:block/transformblock_side"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "learning:item/baked_toast"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "item/generated",
"textures": {
"layer0": "learning:item/toast"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 108 B

View File

@ -1,10 +0,0 @@
{
"type": "minecraft:smoking",
"category": "food",
"cookingtime": 100,
"experience": 0.35,
"ingredient": "learning:toast",
"result": {
"id": "learning:baked_toast"
}
}

View File

@ -1,6 +0,0 @@
{
"values": [
"minecraft:coal",
"learning:baked_toast"
]
}