diff --git a/src/main/generated/.cache/3743cfb9e65f2b657ac65498bc831b6b38ee5be6 b/src/main/generated/.cache/3743cfb9e65f2b657ac65498bc831b6b38ee5be6 index 682c77d..9dd1d21 100644 --- a/src/main/generated/.cache/3743cfb9e65f2b657ac65498bc831b6b38ee5be6 +++ b/src/main/generated/.cache/3743cfb9e65f2b657ac65498bc831b6b38ee5be6 @@ -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 a9b55e67ddbec4f60d16ca1cbece69abb4c1b045 data/futhark/tags/blocks/rune_component_blocks.json diff --git a/src/main/generated/.cache/6ad491f09a14073fc707dd96e0033acdcc341bef b/src/main/generated/.cache/6ad491f09a14073fc707dd96e0033acdcc341bef index 62ff134..ccd75d2 100644 --- a/src/main/generated/.cache/6ad491f09a14073fc707dd96e0033acdcc341bef +++ b/src/main/generated/.cache/6ad491f09a14073fc707dd96e0033acdcc341bef @@ -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 9e1a8f29e55a3641f089d9793addae4f5d7e6531 data/futhark/loot_tables/blocks/jaffa_jam_block.json diff --git a/src/main/generated/.cache/b232ab6c579490507d83eff6f4f4ac8670e75f26 b/src/main/generated/.cache/b232ab6c579490507d83eff6f4f4ac8670e75f26 index 2684a1c..b67982e 100644 --- a/src/main/generated/.cache/b232ab6c579490507d83eff6f4f4ac8670e75f26 +++ b/src/main/generated/.cache/b232ab6c579490507d83eff6f4f4ac8670e75f26 @@ -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 -af261655798bc6798f072eefbd173c094976d5d2 data/futhark/recipes/jaffa_jam_bottle.json +af895c0e364ad231c6a56fbf0c90d8724a422f48 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 +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 +f3be38c90dfb6294dd866d9a5dee87f019e3965a data/futhark/advancements/recipes/tools/jaffa_cake.json diff --git a/src/main/generated/.cache/ba502c7b70814b3d51c711e12b126c9ee58ec766 b/src/main/generated/.cache/ba502c7b70814b3d51c711e12b126c9ee58ec766 index 474b1bd..84e590c 100644 --- a/src/main/generated/.cache/ba502c7b70814b3d51c711e12b126c9ee58ec766 +++ b/src/main/generated/.cache/ba502c7b70814b3d51c711e12b126c9ee58ec766 @@ -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 276f160a0d27df492aec9e46ffdc1dc17d7ad376 assets/futhark/models/item/jaffa_jam_block.json f38e69eb4a4c2e11ce36b08d0223122343bd510f assets/futhark/models/item/rune_block.json diff --git a/src/main/generated/.cache/f6136e830cd7b6dfc4a01f57d31f667862b2eb6a b/src/main/generated/.cache/f6136e830cd7b6dfc4a01f57d31f667862b2eb6a index 48f5645..9ec01ab 100644 --- a/src/main/generated/.cache/f6136e830cd7b6dfc4a01f57d31f667862b2eb6a +++ b/src/main/generated/.cache/f6136e830cd7b6dfc4a01f57d31f667862b2eb6a @@ -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 diff --git a/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle.json b/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle.json index 534e509..9202f36 100644 --- a/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle.json +++ b/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle.json @@ -1,12 +1,12 @@ { "parent": "minecraft:recipes/root", "criteria": { - "has_jaffa_jam_block": { + "has_sweet_berries": { "conditions": { "items": [ { "items": [ - "futhark:jaffa_jam_block" + "minecraft:sweet_berries" ] } ] @@ -22,7 +22,7 @@ }, "requirements": [ [ - "has_jaffa_jam_block", + "has_sweet_berries", "has_the_recipe" ] ], diff --git a/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle_from_jaffa_jam_block.json b/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle_from_jaffa_jam_block.json new file mode 100644 index 0000000..ffe85ae --- /dev/null +++ b/src/main/generated/data/futhark/advancements/recipes/food/jaffa_jam_bottle_from_jaffa_jam_block.json @@ -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 +} \ No newline at end of file diff --git a/src/main/generated/data/futhark/advancements/recipes/tools/jaffa_cake.json b/src/main/generated/data/futhark/advancements/recipes/tools/jaffa_cake.json new file mode 100644 index 0000000..45f3191 --- /dev/null +++ b/src/main/generated/data/futhark/advancements/recipes/tools/jaffa_cake.json @@ -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 +} \ No newline at end of file diff --git a/src/main/generated/data/futhark/recipes/jaffa_cake.json b/src/main/generated/data/futhark/recipes/jaffa_cake.json new file mode 100644 index 0000000..2a1e5b6 --- /dev/null +++ b/src/main/generated/data/futhark/recipes/jaffa_cake.json @@ -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 +} \ No newline at end of file diff --git a/src/main/generated/data/futhark/recipes/jaffa_jam_bottle.json b/src/main/generated/data/futhark/recipes/jaffa_jam_bottle.json index a54e8c7..a731c73 100644 --- a/src/main/generated/data/futhark/recipes/jaffa_jam_bottle.json +++ b/src/main/generated/data/futhark/recipes/jaffa_jam_bottle.json @@ -2,24 +2,17 @@ "type": "minecraft:crafting_shapeless", "category": "misc", "ingredients": [ - { - "item": "futhark:jaffa_jam_block" - }, { "item": "minecraft:glass_bottle" }, { - "item": "minecraft:glass_bottle" + "item": "minecraft:sweet_berries" }, { - "item": "minecraft:glass_bottle" - }, - { - "item": "minecraft:glass_bottle" + "item": "minecraft:sugar" } ], "result": { - "count": 4, "item": "futhark:jaffa_jam" } } \ No newline at end of file diff --git a/src/main/generated/data/futhark/recipes/jaffa_jam_bottle_from_jaffa_jam_block.json b/src/main/generated/data/futhark/recipes/jaffa_jam_bottle_from_jaffa_jam_block.json new file mode 100644 index 0000000..a54e8c7 --- /dev/null +++ b/src/main/generated/data/futhark/recipes/jaffa_jam_bottle_from_jaffa_jam_block.json @@ -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" + } +} \ No newline at end of file diff --git a/src/main/java/com/futhark/Futhark.java b/src/main/java/com/futhark/Futhark.java index c4f744b..3cadba6 100644 --- a/src/main/java/com/futhark/Futhark.java +++ b/src/main/java/com/futhark/Futhark.java @@ -1,15 +1,9 @@ package com.futhark; -import com.futhark.block.ModBlocks; -import com.futhark.item.ModItemGroups; -import com.futhark.item.ModItems; +import com.futhark.block.FutharkBlocks; +import com.futhark.item.FutharkItemGroups; +import com.futhark.item.FutharkItems; 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.LoggerFactory; @@ -22,15 +16,8 @@ public class Futhark implements ModInitializer { @Override public void onInitialize() { LOGGER.info("Hello from Futhark!"); - ModItems.init(); - ModBlocks.init(); - ModItemGroups.init(); - - UseBlockCallback.EVENT.register(((player, world, hand, hitResult) -> { - LOGGER.info(hand.toString()); - LOGGER.info(hitResult.toString()); - - return ActionResult.PASS; - })); + FutharkItems.init(); + FutharkBlocks.init(); + FutharkItemGroups.init(); } } \ No newline at end of file diff --git a/src/main/java/com/futhark/FutharkClient.java b/src/main/java/com/futhark/FutharkClient.java new file mode 100644 index 0000000..7f6d0f2 --- /dev/null +++ b/src/main/java/com/futhark/FutharkClient.java @@ -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()); + } +} diff --git a/src/main/java/com/futhark/FutharkDataGenerator.java b/src/main/java/com/futhark/FutharkDataGenerator.java index 452a528..2bc3df2 100644 --- a/src/main/java/com/futhark/FutharkDataGenerator.java +++ b/src/main/java/com/futhark/FutharkDataGenerator.java @@ -8,10 +8,10 @@ public class FutharkDataGenerator implements DataGeneratorEntrypoint { @Override 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); + pack.addProvider(FutharkBlockTagProvider::new); + pack.addProvider(FutharkItemTagProvider::new); + pack.addProvider(FutharkLootTableProvider::new); + pack.addProvider(FutharkModelProvider::new); + pack.addProvider(FutharkRecipeProvider::new); } } diff --git a/src/main/java/com/futhark/FutharkModClient.java b/src/main/java/com/futhark/FutharkModClient.java deleted file mode 100644 index 057c5a1..0000000 --- a/src/main/java/com/futhark/FutharkModClient.java +++ /dev/null @@ -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()); - } -} diff --git a/src/main/java/com/futhark/ModTags.java b/src/main/java/com/futhark/FutharkTags.java similarity index 96% rename from src/main/java/com/futhark/ModTags.java rename to src/main/java/com/futhark/FutharkTags.java index 0ea2406..af66fab 100644 --- a/src/main/java/com/futhark/ModTags.java +++ b/src/main/java/com/futhark/FutharkTags.java @@ -6,7 +6,7 @@ import net.minecraft.util.Identifier; import net.minecraft.block.Block; import net.minecraft.item.Item; -public class ModTags { +public class FutharkTags { public static class Blocks { public static final TagKey RUNE_COMPONENT_BLOCKS = createTag("rune_component_blocks"); diff --git a/src/main/java/com/futhark/StateSaverAndLoader.java b/src/main/java/com/futhark/StateSaverAndLoader.java new file mode 100644 index 0000000..f88c626 --- /dev/null +++ b/src/main/java/com/futhark/StateSaverAndLoader.java @@ -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; + } +} \ No newline at end of file diff --git a/src/main/java/com/futhark/block/ModBlocks.java b/src/main/java/com/futhark/block/FutharkBlocks.java similarity index 84% rename from src/main/java/com/futhark/block/ModBlocks.java rename to src/main/java/com/futhark/block/FutharkBlocks.java index beb41c6..4dad834 100644 --- a/src/main/java/com/futhark/block/ModBlocks.java +++ b/src/main/java/com/futhark/block/FutharkBlocks.java @@ -4,16 +4,13 @@ import com.futhark.Futhark; import net.fabricmc.fabric.api.item.v1.FabricItemSettings; import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; import net.minecraft.block.*; -import net.minecraft.client.render.RenderLayer; import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; -import net.minecraft.sound.BlockSoundGroup; import net.minecraft.util.Identifier; -public class ModBlocks extends Block { - public ModBlocks(Settings settings) { +public class FutharkBlocks extends Block { + public FutharkBlocks(Settings settings) { super(settings); } diff --git a/src/main/java/com/futhark/block/RuneBlock.java b/src/main/java/com/futhark/block/RuneBlock.java index 7be1f63..1e1d54f 100644 --- a/src/main/java/com/futhark/block/RuneBlock.java +++ b/src/main/java/com/futhark/block/RuneBlock.java @@ -1,10 +1,13 @@ package com.futhark.block; +import com.futhark.StateSaverAndLoader; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.server.MinecraftServer; import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundEvents; +import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Hand; import net.minecraft.util.hit.BlockHitResult; @@ -19,7 +22,14 @@ public class RuneBlock extends Block { @Override 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; } } diff --git a/src/main/java/com/futhark/datagen/ModBlockTagProvider.java b/src/main/java/com/futhark/datagen/FutharkBlockTagProvider.java similarity index 57% rename from src/main/java/com/futhark/datagen/ModBlockTagProvider.java rename to src/main/java/com/futhark/datagen/FutharkBlockTagProvider.java index 2491851..e1a2085 100644 --- a/src/main/java/com/futhark/datagen/ModBlockTagProvider.java +++ b/src/main/java/com/futhark/datagen/FutharkBlockTagProvider.java @@ -1,7 +1,7 @@ package com.futhark.datagen; -import com.futhark.ModTags; -import com.futhark.block.ModBlocks; +import com.futhark.FutharkTags; +import com.futhark.block.FutharkBlocks; import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; import net.fabricmc.fabric.api.datagen.v1.provider.FabricTagProvider; import net.minecraft.block.Blocks; @@ -12,15 +12,15 @@ import net.minecraft.util.Identifier; import java.util.concurrent.CompletableFuture; -public class ModBlockTagProvider extends FabricTagProvider.BlockTagProvider { - public ModBlockTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { +public class FutharkBlockTagProvider extends FabricTagProvider.BlockTagProvider { + public FutharkBlockTagProvider(FabricDataOutput output, CompletableFuture registriesFuture) { super(output, registriesFuture); } @Override 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); } } diff --git a/src/main/java/com/futhark/datagen/ModItemTagProvider.java b/src/main/java/com/futhark/datagen/FutharkItemTagProvider.java similarity index 65% rename from src/main/java/com/futhark/datagen/ModItemTagProvider.java rename to src/main/java/com/futhark/datagen/FutharkItemTagProvider.java index a2c1a29..c2160b0 100644 --- a/src/main/java/com/futhark/datagen/ModItemTagProvider.java +++ b/src/main/java/com/futhark/datagen/FutharkItemTagProvider.java @@ -6,8 +6,8 @@ import net.minecraft.registry.RegistryWrapper; import java.util.concurrent.CompletableFuture; -public class ModItemTagProvider extends FabricTagProvider.ItemTagProvider { - public ModItemTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { +public class FutharkItemTagProvider extends FabricTagProvider.ItemTagProvider { + public FutharkItemTagProvider(FabricDataOutput output, CompletableFuture completableFuture) { super(output, completableFuture); } diff --git a/src/main/java/com/futhark/datagen/FutharkLootTableProvider.java b/src/main/java/com/futhark/datagen/FutharkLootTableProvider.java new file mode 100644 index 0000000..910b107 --- /dev/null +++ b/src/main/java/com/futhark/datagen/FutharkLootTableProvider.java @@ -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); + } +} diff --git a/src/main/java/com/futhark/datagen/FutharkModelProvider.java b/src/main/java/com/futhark/datagen/FutharkModelProvider.java new file mode 100644 index 0000000..b9dc027 --- /dev/null +++ b/src/main/java/com/futhark/datagen/FutharkModelProvider.java @@ -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); + } +} diff --git a/src/main/java/com/futhark/datagen/FutharkRecipeProvider.java b/src/main/java/com/futhark/datagen/FutharkRecipeProvider.java new file mode 100644 index 0000000..7c01a57 --- /dev/null +++ b/src/main/java/com/futhark/datagen/FutharkRecipeProvider.java @@ -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 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")); + } +} diff --git a/src/main/java/com/futhark/datagen/ModLootTableProvider.java b/src/main/java/com/futhark/datagen/ModLootTableProvider.java deleted file mode 100644 index ca00991..0000000 --- a/src/main/java/com/futhark/datagen/ModLootTableProvider.java +++ /dev/null @@ -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); - } -} diff --git a/src/main/java/com/futhark/datagen/ModModelProvider.java b/src/main/java/com/futhark/datagen/ModModelProvider.java deleted file mode 100644 index 65b8c45..0000000 --- a/src/main/java/com/futhark/datagen/ModModelProvider.java +++ /dev/null @@ -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); - } -} diff --git a/src/main/java/com/futhark/datagen/ModRecipeProvider.java b/src/main/java/com/futhark/datagen/ModRecipeProvider.java deleted file mode 100644 index 9f7ad81..0000000 --- a/src/main/java/com/futhark/datagen/ModRecipeProvider.java +++ /dev/null @@ -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 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")); - } -} diff --git a/src/main/java/com/futhark/item/ModItemGroups.java b/src/main/java/com/futhark/item/FutharkItemGroups.java similarity index 63% rename from src/main/java/com/futhark/item/ModItemGroups.java rename to src/main/java/com/futhark/item/FutharkItemGroups.java index 9135a56..86b07a2 100644 --- a/src/main/java/com/futhark/item/ModItemGroups.java +++ b/src/main/java/com/futhark/item/FutharkItemGroups.java @@ -1,7 +1,7 @@ package com.futhark.item; import com.futhark.Futhark; -import com.futhark.block.ModBlocks; +import com.futhark.block.FutharkBlocks; import net.fabricmc.fabric.api.itemgroup.v1.FabricItemGroup; import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemStack; @@ -10,18 +10,17 @@ import net.minecraft.registry.Registry; import net.minecraft.text.Text; import net.minecraft.util.Identifier; -public class ModItemGroups { +public class FutharkItemGroups { public static final ItemGroup FUTHARK_GROUP = Registry.register(Registries.ITEM_GROUP, new Identifier(Futhark.MOD_ID, "jaffa"), FabricItemGroup.builder().displayName(Text.translatable("itemgroup.jaffa")) - .icon(() -> new ItemStack(ModItems.JAFFA_CAKE)) + .icon(() -> new ItemStack(FutharkItems.JAFFA_CAKE)) .entries(((displayContext, entries) -> { - entries.add(ModBlocks.JAFFA_JAM_BLOCK); - entries.add(ModBlocks.RUNE_BLOCK); - entries.add(ModItems.JAFFA_SPONGE); - entries.add(ModItems.JAFFA_JAM); - entries.add(ModItems.JAFFA_CAKE); - entries.add(ModItems.RUNIC_CHISEL); + entries.add(FutharkBlocks.JAFFA_JAM_BLOCK); + entries.add(FutharkBlocks.RUNE_BLOCK); + entries.add(FutharkItems.JAFFA_JAM); + entries.add(FutharkItems.JAFFA_CAKE); + entries.add(FutharkItems.RUNIC_CHISEL); })).build()); public static void init() { diff --git a/src/main/java/com/futhark/item/ModItems.java b/src/main/java/com/futhark/item/FutharkItems.java similarity index 76% rename from src/main/java/com/futhark/item/ModItems.java rename to src/main/java/com/futhark/item/FutharkItems.java index c1c104c..99cfcbf 100644 --- a/src/main/java/com/futhark/item/ModItems.java +++ b/src/main/java/com/futhark/item/FutharkItems.java @@ -14,8 +14,8 @@ import net.minecraft.registry.Registries; import net.minecraft.registry.Registry; import net.minecraft.util.Identifier; -public class ModItems extends Item { - public ModItems(Settings settings) { +public class FutharkItems extends Item { + public FutharkItems(Settings settings) { super(settings); } @@ -43,11 +43,6 @@ public class ModItems extends Item { 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( "runic_chisel", new RunicChiselItem(new FabricItemSettings().maxDamage(64).fireproof()) @@ -59,11 +54,10 @@ public class ModItems extends Item { public static void init() { Futhark.LOGGER.info("Registering Items"); - ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register((itemGroup) -> itemGroup.add(ModItems.JAFFA_CAKE)); - CompostingChanceRegistry.INSTANCE.add(ModItems.JAFFA_CAKE, 1.0f); - FuelRegistry.INSTANCE.add(ModItems.JAFFA_CAKE, 30 * 20); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.FOOD_AND_DRINK).register((itemGroup) -> itemGroup.add(FutharkItems.JAFFA_CAKE)); + CompostingChanceRegistry.INSTANCE.add(FutharkItems.JAFFA_CAKE, 1.0f); + 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(ModItems.JAFFA_SPONGE)); + ItemGroupEvents.modifyEntriesEvent(ItemGroups.INGREDIENTS).register((itemGroup) -> itemGroup.add(FutharkItems.JAFFA_JAM)); } } diff --git a/src/main/java/com/futhark/item/RunicChiselItem.java b/src/main/java/com/futhark/item/RunicChiselItem.java index b310eed..902ea77 100644 --- a/src/main/java/com/futhark/item/RunicChiselItem.java +++ b/src/main/java/com/futhark/item/RunicChiselItem.java @@ -1,15 +1,16 @@ package com.futhark.item; -import net.minecraft.block.Block; +import com.futhark.StateSaverAndLoader; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.Item; import net.minecraft.item.ItemUsageContext; +import net.minecraft.server.MinecraftServer; import net.minecraft.util.ActionResult; 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 RunicChiselItem(Settings settings) { @@ -22,10 +23,20 @@ public class RunicChiselItem extends Item { BlockPos pos = context.getBlockPos(); PlayerEntity player = context.getPlayer(); BlockState state = context.getWorld().getBlockState(pos); + MinecraftServer server = context.getPlayer().getServer(); + if (state.isOf(Blocks.STONE)) { context.getWorld().setBlockState(pos, RUNE_BLOCK.getDefaultState()); + if (server != null) { + StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server); + serverState.totalNumberOfRunes += 1; + } } else if (state.isOf(RUNE_BLOCK)) { context.getWorld().setBlockState(pos, Blocks.STONE.getDefaultState()); + if (server != null) { + StateSaverAndLoader serverState = StateSaverAndLoader.getServerState(server); + serverState.totalNumberOfRunes -= 1; + } } } diff --git a/src/main/resources/assets/futhark/textures/block/jaffa_jam_block_old.png b/src/main/resources/assets/futhark/textures/block/jaffa_jam_block_old.png deleted file mode 100644 index 880b316..0000000 Binary files a/src/main/resources/assets/futhark/textures/block/jaffa_jam_block_old.png and /dev/null differ diff --git a/src/main/resources/assets/futhark/textures/block/rune_block.png b/src/main/resources/assets/futhark/textures/block/rune_block.png index 855df6c..86504c5 100644 Binary files a/src/main/resources/assets/futhark/textures/block/rune_block.png and b/src/main/resources/assets/futhark/textures/block/rune_block.png differ diff --git a/src/main/resources/assets/futhark/textures/block/rune_block.png~ b/src/main/resources/assets/futhark/textures/block/rune_block.png~ new file mode 100644 index 0000000..855df6c Binary files /dev/null and b/src/main/resources/assets/futhark/textures/block/rune_block.png~ differ diff --git a/src/main/resources/assets/futhark/textures/item/runic_chisel.png b/src/main/resources/assets/futhark/textures/item/runic_chisel.png index b037ab1..1ba9b71 100644 Binary files a/src/main/resources/assets/futhark/textures/item/runic_chisel.png and b/src/main/resources/assets/futhark/textures/item/runic_chisel.png differ diff --git a/src/main/resources/assets/futhark/textures/item/runic_chisel.png~ b/src/main/resources/assets/futhark/textures/item/runic_chisel.png~ new file mode 100644 index 0000000..b037ab1 Binary files /dev/null and b/src/main/resources/assets/futhark/textures/item/runic_chisel.png~ differ diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 1102096..9286702 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -19,7 +19,7 @@ "com.futhark.Futhark" ], "client": [ - "com.futhark.FutharkModClient" + "com.futhark.FutharkClient" ], "fabric-datagen": [ "com.futhark.FutharkDataGenerator"