add code generation, move block transparency to client

This commit is contained in:
zongor 2024-11-16 18:22:33 -05:00
parent 1106b54082
commit ae744059e9
37 changed files with 358 additions and 25 deletions

View File

@ -0,0 +1,3 @@
// 1.20.1 2024-11-16T18:16:03.177455006 futhark/Tags for minecraft:block
9d53a90ae3f26d6181121ef328fe1447d076d138 data/fabric/tags/blocks/needs_tool_level_4.json
a9b55e67ddbec4f60d16ca1cbece69abb4c1b045 data/futhark/tags/blocks/rune_component_blocks.json

View File

@ -0,0 +1,3 @@
// 1.20.1 2024-11-16T18:16:03.17674354 futhark/Block Loot Tables
11dffe7e3a626334ae291fa9f719130ef92d7146 data/futhark/loot_tables/blocks/rune_block.json
9e1a8f29e55a3641f089d9793addae4f5d7e6531 data/futhark/loot_tables/blocks/jaffa_jam_block.json

View File

@ -0,0 +1,7 @@
// 1.20.1 2024-11-16T18:16:03.178005707 futhark/Recipes
b3ebe698aedaace80b70616d5a3a3f4cdea18b14 data/futhark/advancements/recipes/building_blocks/jaffa_jam_block.json
af261655798bc6798f072eefbd173c094976d5d2 data/futhark/recipes/jaffa_jam_bottle.json
21aaf3e299205cd147f9a7cd07db055f3b6f707d data/futhark/recipes/jaffa_jam_block.json
30d45b6c110019dbf22e4dc7e13899631793c07a data/futhark/recipes/runic_chisel.json
af167e526e8e42f625ad7be3bf8b762019737cd9 data/futhark/advancements/recipes/food/jaffa_jam_bottle.json
78ed4c6f8275ac2acfc26772741203479f7be97b data/futhark/advancements/recipes/tools/runic_chisel.json

View File

@ -0,0 +1,10 @@
// 1.20.1 2024-11-16T18:16:03.178423491 futhark/Model Definitions
73dfda6a56d6357526a78744df4a3629ed627de0 assets/futhark/models/block/jaffa_jam_block.json
276f160a0d27df492aec9e46ffdc1dc17d7ad376 assets/futhark/models/item/jaffa_jam_block.json
f38e69eb4a4c2e11ce36b08d0223122343bd510f assets/futhark/models/item/rune_block.json
633e38d5782fbde20e8458c7c6b99741a71f5f88 assets/futhark/models/item/runic_chisel.json
8bd22ab66e5b65494a4a44a42073ef5db2d2595c assets/futhark/blockstates/rune_block.json
1f32bfa134be73e11aab069870879b8933c36a2a assets/futhark/models/block/rune_block.json
e3a75c74be3035068fcf74a97c29e7d0338ba9c3 assets/futhark/models/item/jaffa_cake.json
8046d8fa422be23ddaedf65df32204f7050e9ff5 assets/futhark/blockstates/jaffa_jam_block.json
b6b689060a02a2c8e1e0c90e5ec8788e8a58e807 assets/futhark/models/item/jaffa_jam.json

View File

@ -0,0 +1 @@
// 1.20.1 2024-11-16T18:16:03.17777695 futhark/Tags for minecraft:item

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "futhark:block/jaffa_jam_block"
}
}

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"all": "futhark:block/rune_block"
}
}

View File

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "futhark:item/jaffa_cake" "layer0": "futhark:item/jaffa_cake"
} }

View File

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "futhark:item/jaffa_jam" "layer0": "futhark:item/jaffa_jam"
} }

View File

@ -1,5 +1,5 @@
{ {
"parent": "item/generated", "parent": "minecraft:item/generated",
"textures": { "textures": {
"layer0": "futhark:item/runic_chisel" "layer0": "futhark:item/runic_chisel"
} }

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"futhark:rune_block"
]
}

View File

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_jaffa_jam": {
"conditions": {
"items": [
{
"items": [
"futhark:jaffa_jam"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:jaffa_jam_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_jaffa_jam",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:jaffa_jam_block"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_jaffa_jam_block": {
"conditions": {
"items": [
{
"items": [
"futhark:jaffa_jam_block"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:jaffa_jam_bottle"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_jaffa_jam_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:jaffa_jam_bottle"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,35 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_lapis_lazuli": {
"conditions": {
"items": [
{
"items": [
"minecraft:lapis_lazuli"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "minecraft:runic_chisel"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_lapis_lazuli",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:runic_chisel"
]
},
"sends_telemetry_event": false
}

View File

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

View File

@ -1,6 +1,6 @@
{ {
"type": "minecraft:crafting_shaped", "type": "minecraft:crafting_shaped",
"category": "misc", "category": "building",
"key": { "key": {
"#": { "#": {
"item": "futhark:jaffa_jam" "item": "futhark:jaffa_jam"

View File

@ -5,11 +5,11 @@
"#": { "#": {
"item": "minecraft:stick" "item": "minecraft:stick"
}, },
"X": {
"item": "minecraft:iron_ingot"
},
"L": { "L": {
"item": "minecraft:lapis_lazuli" "item": "minecraft:lapis_lazuli"
},
"X": {
"item": "minecraft:iron_ingot"
} }
}, },
"pattern": [ "pattern": [
@ -18,7 +18,7 @@
" L" " L"
], ],
"result": { "result": {
"item": "futhark.runic_chisel" "item": "futhark:runic_chisel"
}, },
"show_notification": true "show_notification": true
} }

View File

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:lapis_block"
]
}

View File

@ -4,7 +4,6 @@ import com.futhark.block.ModBlocks;
import com.futhark.item.ModItemGroups; import com.futhark.item.ModItemGroups;
import com.futhark.item.ModItems; import com.futhark.item.ModItems;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.event.player.UseBlockCallback; import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry; import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;

View File

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

View File

@ -1,12 +1,15 @@
package com.futhark; package com.futhark;
import com.futhark.block.ModBlocks;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry; import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.entity.MinecartEntityRenderer; import net.minecraft.client.render.entity.MinecartEntityRenderer;
public class FutharkModClient implements ClientModInitializer{ public class FutharkModClient implements ClientModInitializer{
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.JAFFA_JAM_BLOCK, RenderLayer.getTranslucent());
} }
} }

View File

@ -0,0 +1,24 @@
package com.futhark;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
public class ModTags {
public static class Blocks {
public static final TagKey<Block> RUNE_COMPONENT_BLOCKS = createTag("rune_component_blocks");
private static TagKey<Block> createTag(String name) {
return TagKey.of(RegistryKeys.BLOCK, new Identifier(Futhark.MOD_ID, name));
}
}
public static class Items {
private static TagKey<Item> createTag(String name) {
return TagKey.of(RegistryKeys.ITEM, new Identifier(Futhark.MOD_ID, name));
}
}
}

View File

@ -1,7 +1,6 @@
package com.futhark.block; package com.futhark.block;
import com.futhark.Futhark; import com.futhark.Futhark;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.*; import net.minecraft.block.*;
@ -31,6 +30,5 @@ public class ModBlocks extends Block {
public static void init() { public static void init() {
Futhark.LOGGER.info("Registering Blocks"); Futhark.LOGGER.info("Registering Blocks");
BlockRenderLayerMap.INSTANCE.putBlock(ModBlocks.JAFFA_JAM_BLOCK, RenderLayer.getTranslucent());
} }
} }

View File

@ -0,0 +1,26 @@
package com.futhark.datagen;
import com.futhark.ModTags;
import com.futhark.block.ModBlocks;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.block.Blocks;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.registry.RegistryWrapper;
import net.minecraft.registry.tag.TagKey;
import net.minecraft.util.Identifier;
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(ModTags.Blocks.RUNE_COMPONENT_BLOCKS).add(Blocks.LAPIS_BLOCK);
getOrCreateTagBuilder(TagKey.of(RegistryKeys.BLOCK, new Identifier("fabric", "needs_tool_level_4"))).add(ModBlocks.RUNE_BLOCK);
}
}

View File

@ -0,0 +1,18 @@
package com.futhark.datagen;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
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) {
}
}

View File

@ -0,0 +1,18 @@
package com.futhark.datagen;
import com.futhark.block.ModBlocks;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricLootTableProvider;
public class ModLootTableProvider extends FabricBlockLootTableProvider {
public ModLootTableProvider(FabricDataOutput dataOutput) {
super(dataOutput);
}
@Override
public void generate() {
addDrop(ModBlocks.JAFFA_JAM_BLOCK);
addDrop(ModBlocks.RUNE_BLOCK);
}
}

View File

@ -0,0 +1,28 @@
package com.futhark.datagen;
import com.futhark.block.ModBlocks;
import com.futhark.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider;
import net.minecraft.data.client.BlockStateModelGenerator;
import net.minecraft.data.client.ItemModelGenerator;
import net.minecraft.data.client.Models;
public class ModModelProvider extends FabricModelProvider {
public ModModelProvider(FabricDataOutput output) {
super(output);
}
@Override
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.JAFFA_JAM_BLOCK);
blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.RUNE_BLOCK);
}
@Override
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
itemModelGenerator.register(ModItems.JAFFA_CAKE, Models.GENERATED);
itemModelGenerator.register(ModItems.JAFFA_JAM, Models.GENERATED);
itemModelGenerator.register(ModItems.RUNIC_CHISEL, Models.GENERATED);
}
}

View File

@ -0,0 +1,49 @@
package com.futhark.datagen;
import com.futhark.block.ModBlocks;
import com.futhark.item.ModItems;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricRecipeProvider;
import net.minecraft.data.server.recipe.RecipeJsonProvider;
import net.minecraft.data.server.recipe.ShapedRecipeJsonBuilder;
import net.minecraft.data.server.recipe.ShapelessRecipeJsonBuilder;
import net.minecraft.item.Items;
import net.minecraft.recipe.book.RecipeCategory;
import net.minecraft.util.Identifier;
import java.util.function.Consumer;
public class ModRecipeProvider extends FabricRecipeProvider {
public ModRecipeProvider(FabricDataOutput output) {
super(output);
}
@Override
public void generate(Consumer<RecipeJsonProvider> consumer) {
ShapedRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, ModBlocks.JAFFA_JAM_BLOCK, 1)
.pattern("##")
.pattern("##")
.input('#', ModItems.JAFFA_JAM)
.criterion(hasItem(ModItems.JAFFA_JAM), conditionsFromItem(ModItems.JAFFA_JAM))
.offerTo(consumer, new Identifier(getRecipeName(ModBlocks.JAFFA_JAM_BLOCK)));
ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, ModItems.RUNIC_CHISEL, 1)
.pattern("X ")
.pattern(" # ")
.pattern(" L")
.input('X', Items.IRON_INGOT)
.input('#', Items.STICK)
.input('L', Items.LAPIS_LAZULI)
.criterion(hasItem(Items.LAPIS_LAZULI), conditionsFromItem(Items.LAPIS_LAZULI))
.offerTo(consumer, new Identifier(getRecipeName(ModItems.RUNIC_CHISEL)));
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, ModItems.JAFFA_JAM, 4)
.input(ModBlocks.JAFFA_JAM_BLOCK)
.input(Items.GLASS_BOTTLE)
.input(Items.GLASS_BOTTLE)
.input(Items.GLASS_BOTTLE)
.input(Items.GLASS_BOTTLE)
.criterion(hasItem(ModBlocks.JAFFA_JAM_BLOCK), conditionsFromItem(ModBlocks.JAFFA_JAM_BLOCK))
.offerTo(consumer, new Identifier("jaffa_jam_bottle"));
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "futhark:block/jaffa_jam_block"
}
}

View File

@ -1,6 +0,0 @@
{
"parent": "block/cube_all",
"textures": {
"all": "futhark:block/rune_block"
}
}

View File

@ -18,6 +18,9 @@
"main": [ "main": [
"com.futhark.Futhark" "com.futhark.Futhark"
], ],
"client": [
"com.futhark.FutharkModClient"
],
"fabric-datagen": [ "fabric-datagen": [
"com.futhark.FutharkDataGenerator" "com.futhark.FutharkDataGenerator"
] ]