rename providers, add simple save/load for rune blocks, update textures

This commit is contained in:
zongor 2024-11-16 23:01:43 -05:00
parent ae744059e9
commit 6a94d4c45a
36 changed files with 372 additions and 192 deletions

View File

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

View File

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

View File

@ -1,7 +1,11 @@
// 1.20.1 2024-11-16T18:16:03.178005707 futhark/Recipes // 1.20.1 2024-11-16T22:02:16.086614598 futhark/Recipes
b3ebe698aedaace80b70616d5a3a3f4cdea18b14 data/futhark/advancements/recipes/building_blocks/jaffa_jam_block.json b3ebe698aedaace80b70616d5a3a3f4cdea18b14 data/futhark/advancements/recipes/building_blocks/jaffa_jam_block.json
af261655798bc6798f072eefbd173c094976d5d2 data/futhark/recipes/jaffa_jam_bottle.json af895c0e364ad231c6a56fbf0c90d8724a422f48 data/futhark/recipes/jaffa_jam_bottle.json
21aaf3e299205cd147f9a7cd07db055f3b6f707d data/futhark/recipes/jaffa_jam_block.json 21aaf3e299205cd147f9a7cd07db055f3b6f707d data/futhark/recipes/jaffa_jam_block.json
30d45b6c110019dbf22e4dc7e13899631793c07a data/futhark/recipes/runic_chisel.json 30d45b6c110019dbf22e4dc7e13899631793c07a data/futhark/recipes/runic_chisel.json
af167e526e8e42f625ad7be3bf8b762019737cd9 data/futhark/advancements/recipes/food/jaffa_jam_bottle.json af261655798bc6798f072eefbd173c094976d5d2 data/futhark/recipes/jaffa_jam_bottle_from_jaffa_jam_block.json
70d3923b10acb9bbe661692f2a8b74257ca16435 data/futhark/recipes/jaffa_cake.json
760fb732cfc401aab72fb8bda219ef2f369d3728 data/futhark/advancements/recipes/food/jaffa_jam_bottle.json
17ac5c13d215550509aa3fc2af2742579da5746b data/futhark/advancements/recipes/food/jaffa_jam_bottle_from_jaffa_jam_block.json
78ed4c6f8275ac2acfc26772741203479f7be97b data/futhark/advancements/recipes/tools/runic_chisel.json 78ed4c6f8275ac2acfc26772741203479f7be97b data/futhark/advancements/recipes/tools/runic_chisel.json
f3be38c90dfb6294dd866d9a5dee87f019e3965a data/futhark/advancements/recipes/tools/jaffa_cake.json

View File

@ -1,4 +1,4 @@
// 1.20.1 2024-11-16T18:16:03.178423491 futhark/Model Definitions // 1.20.1 2024-11-16T22:02:16.087103099 futhark/Model Definitions
73dfda6a56d6357526a78744df4a3629ed627de0 assets/futhark/models/block/jaffa_jam_block.json 73dfda6a56d6357526a78744df4a3629ed627de0 assets/futhark/models/block/jaffa_jam_block.json
276f160a0d27df492aec9e46ffdc1dc17d7ad376 assets/futhark/models/item/jaffa_jam_block.json 276f160a0d27df492aec9e46ffdc1dc17d7ad376 assets/futhark/models/item/jaffa_jam_block.json
f38e69eb4a4c2e11ce36b08d0223122343bd510f assets/futhark/models/item/rune_block.json f38e69eb4a4c2e11ce36b08d0223122343bd510f assets/futhark/models/item/rune_block.json

View File

@ -1 +1 @@
// 1.20.1 2024-11-16T18:16:03.17777695 futhark/Tags for minecraft:item // 1.20.1 2024-11-16T22:02:16.086387843 futhark/Tags for minecraft:item

View File

@ -1,12 +1,12 @@
{ {
"parent": "minecraft:recipes/root", "parent": "minecraft:recipes/root",
"criteria": { "criteria": {
"has_jaffa_jam_block": { "has_sweet_berries": {
"conditions": { "conditions": {
"items": [ "items": [
{ {
"items": [ "items": [
"futhark:jaffa_jam_block" "minecraft:sweet_berries"
] ]
} }
] ]
@ -22,7 +22,7 @@
}, },
"requirements": [ "requirements": [
[ [
"has_jaffa_jam_block", "has_sweet_berries",
"has_the_recipe" "has_the_recipe"
] ]
], ],

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_from_jaffa_jam_block"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_jaffa_jam_block",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:jaffa_jam_bottle_from_jaffa_jam_block"
]
},
"sends_telemetry_event": false
}

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_cake"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_jaffa_jam",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"minecraft:jaffa_cake"
]
},
"sends_telemetry_event": false
}

View File

@ -0,0 +1,28 @@
{
"type": "minecraft:crafting_shaped",
"category": "equipment",
"key": {
"C": {
"item": "minecraft:cocoa_beans"
},
"J": {
"item": "futhark:jaffa_jam"
},
"M": {
"item": "minecraft:milk_bucket"
},
"W": {
"item": "minecraft:wheat"
}
},
"pattern": [
"CMC",
"JJJ",
"WWW"
],
"result": {
"count": 6,
"item": "futhark:jaffa_cake"
},
"show_notification": true
}

View File

@ -2,24 +2,17 @@
"type": "minecraft:crafting_shapeless", "type": "minecraft:crafting_shapeless",
"category": "misc", "category": "misc",
"ingredients": [ "ingredients": [
{
"item": "futhark:jaffa_jam_block"
},
{ {
"item": "minecraft:glass_bottle" "item": "minecraft:glass_bottle"
}, },
{ {
"item": "minecraft:glass_bottle" "item": "minecraft:sweet_berries"
}, },
{ {
"item": "minecraft:glass_bottle" "item": "minecraft:sugar"
},
{
"item": "minecraft:glass_bottle"
} }
], ],
"result": { "result": {
"count": 4,
"item": "futhark:jaffa_jam" "item": "futhark:jaffa_jam"
} }
} }

View File

@ -0,0 +1,25 @@
{
"type": "minecraft:crafting_shapeless",
"category": "misc",
"ingredients": [
{
"item": "futhark:jaffa_jam_block"
},
{
"item": "minecraft:glass_bottle"
},
{
"item": "minecraft:glass_bottle"
},
{
"item": "minecraft:glass_bottle"
},
{
"item": "minecraft:glass_bottle"
}
],
"result": {
"count": 4,
"item": "futhark:jaffa_jam"
}
}

View File

@ -1,15 +1,9 @@
package com.futhark; package com.futhark;
import com.futhark.block.ModBlocks; import com.futhark.block.FutharkBlocks;
import com.futhark.item.ModItemGroups; import com.futhark.item.FutharkItemGroups;
import com.futhark.item.ModItems; import com.futhark.item.FutharkItems;
import net.fabricmc.api.ModInitializer; import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.fabricmc.fabric.api.object.builder.v1.entity.FabricDefaultAttributeRegistry;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.registry.Registries;
import net.minecraft.util.ActionResult;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -22,15 +16,8 @@ public class Futhark implements ModInitializer {
@Override @Override
public void onInitialize() { public void onInitialize() {
LOGGER.info("Hello from Futhark!"); LOGGER.info("Hello from Futhark!");
ModItems.init(); FutharkItems.init();
ModBlocks.init(); FutharkBlocks.init();
ModItemGroups.init(); FutharkItemGroups.init();
UseBlockCallback.EVENT.register(((player, world, hand, hitResult) -> {
LOGGER.info(hand.toString());
LOGGER.info(hitResult.toString());
return ActionResult.PASS;
}));
} }
} }

View File

@ -0,0 +1,13 @@
package com.futhark;
import com.futhark.block.FutharkBlocks;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.minecraft.client.render.RenderLayer;
public class FutharkClient implements ClientModInitializer{
@Override
public void onInitializeClient() {
BlockRenderLayerMap.INSTANCE.putBlock(FutharkBlocks.JAFFA_JAM_BLOCK, RenderLayer.getTranslucent());
}
}

View File

@ -8,10 +8,10 @@ public class FutharkDataGenerator implements DataGeneratorEntrypoint {
@Override @Override
public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) { public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
FabricDataGenerator.Pack pack = fabricDataGenerator.createPack(); FabricDataGenerator.Pack pack = fabricDataGenerator.createPack();
pack.addProvider(ModBlockTagProvider::new); pack.addProvider(FutharkBlockTagProvider::new);
pack.addProvider(ModItemTagProvider::new); pack.addProvider(FutharkItemTagProvider::new);
pack.addProvider(ModLootTableProvider::new); pack.addProvider(FutharkLootTableProvider::new);
pack.addProvider(ModModelProvider::new); pack.addProvider(FutharkModelProvider::new);
pack.addProvider(ModRecipeProvider::new); pack.addProvider(FutharkRecipeProvider::new);
} }
} }

View File

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

View File

@ -6,7 +6,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.Item; import net.minecraft.item.Item;
public class ModTags { public class FutharkTags {
public static class Blocks { public static class Blocks {
public static final TagKey<Block> RUNE_COMPONENT_BLOCKS = createTag("rune_component_blocks"); public static final TagKey<Block> RUNE_COMPONENT_BLOCKS = createTag("rune_component_blocks");

View File

@ -0,0 +1,47 @@
package com.futhark;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.PersistentState;
import net.minecraft.world.PersistentStateManager;
import net.minecraft.world.World;
public class StateSaverAndLoader extends PersistentState {
public Integer totalNumberOfRunes = 0;
@Override
public NbtCompound writeNbt(NbtCompound nbt) {
nbt.putInt("totalNumberOfRunes", totalNumberOfRunes);
return nbt;
}
public static StateSaverAndLoader createFromNbt(NbtCompound tag) {
StateSaverAndLoader state = new StateSaverAndLoader();
state.totalNumberOfRunes = tag.getInt("totalNumberOfRunes");
return state;
}
/**
* This function gets the 'PersistentStateManager' and creates or returns the filled in 'StateSaveAndLoader'.
* It does this by calling 'StateSaveAndLoader::createFromNbt' passing it the previously saved 'NbtCompound' we wrote in 'writeNbt'.
*/
public static StateSaverAndLoader getServerState(MinecraftServer server) {
PersistentStateManager persistentStateManager = server.getWorld(World.OVERWORLD).getPersistentStateManager();
StateSaverAndLoader state = persistentStateManager.getOrCreate(
StateSaverAndLoader::createFromNbt,
StateSaverAndLoader::new,
Futhark.MOD_ID
);
// If state is not marked dirty, when Minecraft closes, 'writeNbt' won't be called and therefore nothing will be saved.
// Technically it's 'cleaner' if you only mark state as dirty when there was actually a change, but the vast majority
// of mod writers are just going to be confused when their data isn't being saved, and so it's best just to 'markDirty' for them.
// Besides, it's literally just setting a bool to true, and the only time there's a 'cost' is when the file is written to disk when
// there were no actual change to any of the mods state (INCREDIBLY RARE).
state.markDirty();
return state;
}
}

View File

@ -4,16 +4,13 @@ import com.futhark.Futhark;
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.*;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.item.BlockItem; import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.registry.Registries; import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class ModBlocks extends Block { public class FutharkBlocks extends Block {
public ModBlocks(Settings settings) { public FutharkBlocks(Settings settings) {
super(settings); super(settings);
} }

View File

@ -1,10 +1,13 @@
package com.futhark.block; package com.futhark.block;
import com.futhark.StateSaverAndLoader;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.server.MinecraftServer;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.sound.SoundEvents; import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult; import net.minecraft.util.hit.BlockHitResult;
@ -19,7 +22,14 @@ public class RuneBlock extends Block {
@Override @Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) { public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
world.playSound(player, pos, SoundEvents.BLOCK_NOTE_BLOCK_IRON_XYLOPHONE.value(), SoundCategory.BLOCKS, 1f, 1f);
MinecraftServer server = world.getServer();
if (server != null) {
StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server);
player.sendMessage(Text.literal(String.format("Clicked rune at (%d,%d,%d) Total Runes in World: %d", pos.getX(), pos.getY(), pos.getZ(), serverState.totalNumberOfRunes)));
world.playSound(player, pos, SoundEvents.BLOCK_PORTAL_TRIGGER, SoundCategory.BLOCKS, 1f, 1f);
}
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }
} }

View File

@ -1,7 +1,7 @@
package com.futhark.datagen; package com.futhark.datagen;
import com.futhark.ModTags; import com.futhark.FutharkTags;
import com.futhark.block.ModBlocks; import com.futhark.block.FutharkBlocks;
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
@ -12,15 +12,15 @@ import net.minecraft.util.Identifier;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider { public class FutharkBlockTagProvider extends FabricTagProvider.BlockTagProvider {
public ModBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) { public FutharkBlockTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registriesFuture) {
super(output, registriesFuture); super(output, registriesFuture);
} }
@Override @Override
protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) { protected void configure(RegistryWrapper.WrapperLookup wrapperLookup) {
getOrCreateTagBuilder(ModTags.Blocks.RUNE_COMPONENT_BLOCKS).add(Blocks.LAPIS_BLOCK); getOrCreateTagBuilder(FutharkTags.Blocks.RUNE_COMPONENT_BLOCKS).add(Blocks.LAPIS_BLOCK);
getOrCreateTagBuilder(TagKey.of(RegistryKeys.BLOCK, new Identifier("fabric", "needs_tool_level_4"))).add(ModBlocks.RUNE_BLOCK); getOrCreateTagBuilder(TagKey.of(RegistryKeys.BLOCK, new Identifier("fabric", "needs_tool_level_4"))).add(FutharkBlocks.RUNE_BLOCK);
} }
} }

View File

@ -6,8 +6,8 @@ import net.minecraft.registry.RegistryWrapper;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider { public class FutharkItemTagProvider extends FabricTagProvider.ItemTagProvider {
public ModItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) { public FutharkItemTagProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> completableFuture) {
super(output, completableFuture); super(output, completableFuture);
} }

View File

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

View File

@ -0,0 +1,28 @@
package com.futhark.datagen;
import com.futhark.block.FutharkBlocks;
import com.futhark.item.FutharkItems;
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 FutharkModelProvider extends FabricModelProvider {
public FutharkModelProvider(FabricDataOutput output) {
super(output);
}
@Override
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
blockStateModelGenerator.registerSimpleCubeAll(FutharkBlocks.JAFFA_JAM_BLOCK);
blockStateModelGenerator.registerSimpleCubeAll(FutharkBlocks.RUNE_BLOCK);
}
@Override
public void generateItemModels(ItemModelGenerator itemModelGenerator) {
itemModelGenerator.register(FutharkItems.JAFFA_CAKE, Models.GENERATED);
itemModelGenerator.register(FutharkItems.JAFFA_JAM, Models.GENERATED);
itemModelGenerator.register(FutharkItems.RUNIC_CHISEL, Models.GENERATED);
}
}

View File

@ -0,0 +1,67 @@
package com.futhark.datagen;
import com.futhark.block.FutharkBlocks;
import com.futhark.item.FutharkItems;
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 FutharkRecipeProvider extends FabricRecipeProvider {
public FutharkRecipeProvider(FabricDataOutput output) {
super(output);
}
@Override
public void generate(Consumer<RecipeJsonProvider> consumer) {
ShapedRecipeJsonBuilder.create(RecipeCategory.BUILDING_BLOCKS, FutharkBlocks.JAFFA_JAM_BLOCK, 1)
.pattern("##")
.pattern("##")
.input('#', FutharkItems.JAFFA_JAM)
.criterion(hasItem(FutharkItems.JAFFA_JAM), conditionsFromItem(FutharkItems.JAFFA_JAM))
.offerTo(consumer, new Identifier(getRecipeName(FutharkBlocks.JAFFA_JAM_BLOCK)));
ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, FutharkItems.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(FutharkItems.RUNIC_CHISEL)));
ShapedRecipeJsonBuilder.create(RecipeCategory.TOOLS, FutharkItems.JAFFA_CAKE, 6)
.pattern("CMC")
.pattern("JJJ")
.pattern("WWW")
.input('C', Items.COCOA_BEANS)
.input('J', FutharkItems.JAFFA_JAM)
.input('M', Items.MILK_BUCKET)
.input('W', Items.WHEAT)
.criterion(hasItem(FutharkItems.JAFFA_JAM), conditionsFromItem(FutharkItems.JAFFA_JAM))
.offerTo(consumer, new Identifier(getRecipeName(FutharkItems.JAFFA_CAKE)));
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, FutharkItems.JAFFA_JAM, 1)
.input(Items.GLASS_BOTTLE)
.input(Items.SWEET_BERRIES)
.input(Items.SUGAR)
.criterion(hasItem(Items.SWEET_BERRIES), conditionsFromItem(Items.SWEET_BERRIES))
.offerTo(consumer, new Identifier("jaffa_jam_bottle"));
ShapelessRecipeJsonBuilder.create(RecipeCategory.FOOD, FutharkItems.JAFFA_JAM, 4)
.input(FutharkBlocks.JAFFA_JAM_BLOCK)
.input(Items.GLASS_BOTTLE)
.input(Items.GLASS_BOTTLE)
.input(Items.GLASS_BOTTLE)
.input(Items.GLASS_BOTTLE)
.criterion(hasItem(FutharkBlocks.JAFFA_JAM_BLOCK), conditionsFromItem(FutharkBlocks.JAFFA_JAM_BLOCK))
.offerTo(consumer, new Identifier("jaffa_jam_bottle_from_jaffa_jam_block"));
}
}

View File

@ -1,18 +0,0 @@
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

@ -1,28 +0,0 @@
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

@ -1,49 +0,0 @@
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,7 +1,7 @@
package com.futhark.item; package com.futhark.item;
import com.futhark.Futhark; import com.futhark.Futhark;
import com.futhark.block.ModBlocks; import com.futhark.block.FutharkBlocks;
import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -10,18 +10,17 @@ import net.minecraft.registry.Registry;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class ModItemGroups { public class FutharkItemGroups {
public static final ItemGroup FUTHARK_GROUP = Registry.register(Registries.ITEM_GROUP, public static final ItemGroup FUTHARK_GROUP = Registry.register(Registries.ITEM_GROUP,
new Identifier(Futhark.MOD_ID, "jaffa"), new Identifier(Futhark.MOD_ID, "jaffa"),
FabricItemGroup.builder().displayName(Text.translatable("itemgroup.jaffa")) FabricItemGroup.builder().displayName(Text.translatable("itemgroup.jaffa"))
.icon(() -> new ItemStack(ModItems.JAFFA_CAKE)) .icon(() -> new ItemStack(FutharkItems.JAFFA_CAKE))
.entries(((displayContext, entries) -> { .entries(((displayContext, entries) -> {
entries.add(ModBlocks.JAFFA_JAM_BLOCK); entries.add(FutharkBlocks.JAFFA_JAM_BLOCK);
entries.add(ModBlocks.RUNE_BLOCK); entries.add(FutharkBlocks.RUNE_BLOCK);
entries.add(ModItems.JAFFA_SPONGE); entries.add(FutharkItems.JAFFA_JAM);
entries.add(ModItems.JAFFA_JAM); entries.add(FutharkItems.JAFFA_CAKE);
entries.add(ModItems.JAFFA_CAKE); entries.add(FutharkItems.RUNIC_CHISEL);
entries.add(ModItems.RUNIC_CHISEL);
})).build()); })).build());
public static void init() { public static void init() {

View File

@ -14,8 +14,8 @@ import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry; import net.minecraft.registry.Registry;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
public class ModItems extends Item { public class FutharkItems extends Item {
public ModItems(Settings settings) { public FutharkItems(Settings settings) {
super(settings); super(settings);
} }
@ -43,11 +43,6 @@ public class ModItems extends Item {
new Item(new FabricItemSettings().food(UNFINISHED_JAFFA_FOOD_COMPONENT)) new Item(new FabricItemSettings().food(UNFINISHED_JAFFA_FOOD_COMPONENT))
); );
public static final Item JAFFA_SPONGE = register(
"jaffa_sponge",
new Item(new FabricItemSettings().food(UNFINISHED_JAFFA_FOOD_COMPONENT))
);
public static final Item RUNIC_CHISEL = register( public static final Item RUNIC_CHISEL = register(
"runic_chisel", "runic_chisel",
new RunicChiselItem(new FabricItemSettings().maxDamage(64).fireproof()) new RunicChiselItem(new FabricItemSettings().maxDamage(64).fireproof())
@ -59,11 +54,10 @@ public class ModItems extends Item {
public static void init() { public static void init() {
Futhark.LOGGER.info("Registering Items"); Futhark.LOGGER.info("Registering Items");
ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register((itemGroup) -> itemGroup.add(ModItems.JAFFA_CAKE)); ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register((itemGroup) -> itemGroup.add(FutharkItems.JAFFA_CAKE));
CompostingChanceRegistry.INSTANCE.add(ModItems.JAFFA_CAKE, 1.0f); CompostingChanceRegistry.INSTANCE.add(FutharkItems.JAFFA_CAKE, 1.0f);
FuelRegistry.INSTANCE.add(ModItems.JAFFA_CAKE, 30 * 20); FuelRegistry.INSTANCE.add(FutharkItems.JAFFA_CAKE, 30 * 20);
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register((itemGroup) -> itemGroup.add(ModItems.JAFFA_JAM)); ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register((itemGroup) -> itemGroup.add(FutharkItems.JAFFA_JAM));
ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register((itemGroup) -> itemGroup.add(ModItems.JAFFA_SPONGE));
} }
} }

View File

@ -1,15 +1,16 @@
package com.futhark.item; package com.futhark.item;
import net.minecraft.block.Block; import com.futhark.StateSaverAndLoader;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ItemUsageContext;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import static com.futhark.block.ModBlocks.RUNE_BLOCK; import static com.futhark.block.FutharkBlocks.RUNE_BLOCK;
public class RunicChiselItem extends Item { public class RunicChiselItem extends Item {
public RunicChiselItem(Settings settings) { public RunicChiselItem(Settings settings) {
@ -22,10 +23,20 @@ public class RunicChiselItem extends Item {
BlockPos pos = context.getBlockPos(); BlockPos pos = context.getBlockPos();
PlayerEntity player = context.getPlayer(); PlayerEntity player = context.getPlayer();
BlockState state = context.getWorld().getBlockState(pos); BlockState state = context.getWorld().getBlockState(pos);
MinecraftServer server = context.getPlayer().getServer();
if (state.isOf(Blocks.STONE)) { if (state.isOf(Blocks.STONE)) {
context.getWorld().setBlockState(pos, RUNE_BLOCK.getDefaultState()); context.getWorld().setBlockState(pos, RUNE_BLOCK.getDefaultState());
if (server != null) {
StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server);
serverState.totalNumberOfRunes += 1;
}
} else if (state.isOf(RUNE_BLOCK)) { } else if (state.isOf(RUNE_BLOCK)) {
context.getWorld().setBlockState(pos, Blocks.STONE.getDefaultState()); context.getWorld().setBlockState(pos, Blocks.STONE.getDefaultState());
if (server != null) {
StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server);
serverState.totalNumberOfRunes -= 1;
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 259 B

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 259 B

View File

@ -19,7 +19,7 @@
"com.futhark.Futhark" "com.futhark.Futhark"
], ],
"client": [ "client": [
"com.futhark.FutharkModClient" "com.futhark.FutharkClient"
], ],
"fabric-datagen": [ "fabric-datagen": [
"com.futhark.FutharkDataGenerator" "com.futhark.FutharkDataGenerator"