diff --git a/src/main/java/de/jottyfan/minecraft/Quickly.java b/src/main/java/de/jottyfan/minecraft/Quickly.java index 9dbd1ba..d5afcc1 100644 --- a/src/main/java/de/jottyfan/minecraft/Quickly.java +++ b/src/main/java/de/jottyfan/minecraft/Quickly.java @@ -17,6 +17,6 @@ public class Quickly implements ModInitializer { @Override public void onInitialize() { - LOGGER.info("Hello Fabric world!"); + LOGGER.info("loading {}", MOD_ID); } } \ No newline at end of file diff --git a/src/main/java/de/jottyfan/minecraft/QuicklyClient.java b/src/main/java/de/jottyfan/minecraft/QuicklyClient.java index 40033bf..37a2d4f 100644 --- a/src/main/java/de/jottyfan/minecraft/QuicklyClient.java +++ b/src/main/java/de/jottyfan/minecraft/QuicklyClient.java @@ -1,5 +1,6 @@ package de.jottyfan.minecraft; +import de.jottyfan.minecraft.block.QuicklyBlocks; import de.jottyfan.minecraft.item.QuicklyItems; import net.fabricmc.api.ClientModInitializer; @@ -13,5 +14,6 @@ public class QuicklyClient implements ClientModInitializer { @Override public void onInitializeClient() { QuicklyItems.registerModItems(); + QuicklyBlocks.registerModBlocks(); } } diff --git a/src/main/java/de/jottyfan/minecraft/block/QuicklyBlocks.java b/src/main/java/de/jottyfan/minecraft/block/QuicklyBlocks.java new file mode 100644 index 0000000..d136543 --- /dev/null +++ b/src/main/java/de/jottyfan/minecraft/block/QuicklyBlocks.java @@ -0,0 +1,47 @@ +package de.jottyfan.minecraft.block; + +import java.util.function.Function; + +import de.jottyfan.minecraft.Quickly; +import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents; +import net.minecraft.core.Registry; +import net.minecraft.core.registries.BuiltInRegistries; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.Identifier; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.item.CreativeModeTabs; +import net.minecraft.world.item.Item; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.SoundType; +import net.minecraft.world.level.block.state.BlockBehaviour.Properties; + +/** + * + * @author jotty + * + */ +public class QuicklyBlocks { + public static final Block KELPBUNDLE = registerBlock("kelpbundle", + Properties.of().instabreak().sound(SoundType.WET_GRASS).strength(0.1f).friction(0.95f), p -> new Block(p)); + + private static final Block registerBlock(String name, Properties properties, Function function) { + Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name); + + ResourceKey blockResourceKey = ResourceKey.create(Registries.BLOCK, identifier); + Block block = function.apply(properties.setId(blockResourceKey)); + Registry.register(BuiltInRegistries.BLOCK, identifier, block); + + ResourceKey itemResourceKey = ResourceKey.create(Registries.ITEM, identifier); + BlockItem blockItem = new BlockItem(block, new Item.Properties().setId(itemResourceKey).modelId(identifier).useItemDescriptionPrefix()); + Registry.register(BuiltInRegistries.ITEM, identifier, blockItem); + + return block; + } + + public static void registerModBlocks() { + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.BUILDING_BLOCKS).register(block -> { + block.accept(KELPBUNDLE); + }); + } +} diff --git a/src/main/java/de/jottyfan/minecraft/item/QuicklyItems.java b/src/main/java/de/jottyfan/minecraft/item/QuicklyItems.java index c0bd224..f9b1dbb 100644 --- a/src/main/java/de/jottyfan/minecraft/item/QuicklyItems.java +++ b/src/main/java/de/jottyfan/minecraft/item/QuicklyItems.java @@ -19,18 +19,18 @@ import net.minecraft.world.item.Item.Properties; * */ public class QuicklyItems { - public static final Item MY_ITEM = registerItem("stub", new Item.Properties(), p -> new Stub(p)); + public static final Item STUB = registerItem("stub", new Item.Properties(), p -> new Stub(p)); private static final Item registerItem(String name, Item.Properties properties, Function function) { Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name); - ResourceKey rc = ResourceKey.create(Registries.ITEM, identifier); - Item i = function.apply(properties.setId(rc).modelId(identifier).useItemDescriptionPrefix()); - return Registry.register(BuiltInRegistries.ITEM, identifier, i); + ResourceKey itemResourceKey = ResourceKey.create(Registries.ITEM, identifier); + Item item = function.apply(properties.setId(itemResourceKey).modelId(identifier).useItemDescriptionPrefix()); + return Registry.register(BuiltInRegistries.ITEM, identifier, item); } public static void registerModItems() { - ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(i -> { - i.accept(MY_ITEM); + ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(item -> { + item.accept(STUB); }); } } diff --git a/src/main/java/de/jottyfan/minecraft/item/Stub.java b/src/main/java/de/jottyfan/minecraft/item/Stub.java index 904177f..2f8d6ce 100644 --- a/src/main/java/de/jottyfan/minecraft/item/Stub.java +++ b/src/main/java/de/jottyfan/minecraft/item/Stub.java @@ -3,6 +3,7 @@ package de.jottyfan.minecraft.item; import java.util.Map; import java.util.Random; +import de.jottyfan.minecraft.block.QuicklyBlocks; import net.minecraft.core.BlockPos; import net.minecraft.sounds.SoundEvents; import net.minecraft.sounds.SoundSource; @@ -16,7 +17,19 @@ import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Blocks; -public class Stub extends Item { +/** + * + * @author jotty + * + */ +public class Stub extends Item { + + // @formatter:off + private static final Map SLASH_MAP = Map.of( + Blocks.HAY_BLOCK, Items.WHEAT, + Blocks.DRIED_KELP_BLOCK, Items.DRIED_KELP, + QuicklyBlocks.KELPBUNDLE, Items.KELP); + // @formatter:on public Stub(Properties properties) { super(properties.stacksTo(64)); @@ -24,12 +37,6 @@ public class Stub extends Item { @Override public InteractionResult useOn(UseOnContext context) { - Map SLASH_MAP = Map.of( - Blocks.HAY_BLOCK, Items.WHEAT, - Blocks.DRIED_KELP_BLOCK, Items.DRIED_KELP); -// , -// ModBlocks.BLOCK_KELPSTACK, Items.KELP); - Level level = context.getLevel(); BlockPos pos = context.getClickedPos(); Block clickedBlock = level.getBlockState(pos).getBlock(); @@ -41,9 +48,8 @@ public class Stub extends Item { ItemStack stack = new ItemStack(SLASH_MAP.get(clickedBlock)); float xScatter = new Random().nextFloat(); float yScatter = new Random().nextFloat(); - ItemEntity entity = new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), - stack, xScatter, yScatter, 0.2); - level.addFreshEntity(entity); + ItemEntity entity = new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), stack, xScatter, yScatter, 0.2); + level.addFreshEntity(entity); } } } diff --git a/src/main/resources/assets/quickly/blockstates/kelpbundle.json b/src/main/resources/assets/quickly/blockstates/kelpbundle.json new file mode 100644 index 0000000..96e5e88 --- /dev/null +++ b/src/main/resources/assets/quickly/blockstates/kelpbundle.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "quickly:block/kelpbundle" + } + } +} diff --git a/src/main/resources/assets/quickly/items/kelpbundle.json b/src/main/resources/assets/quickly/items/kelpbundle.json new file mode 100644 index 0000000..2c5fba2 --- /dev/null +++ b/src/main/resources/assets/quickly/items/kelpbundle.json @@ -0,0 +1,6 @@ +{ + "model": { + "type": "minecraft:model", + "model": "quickly:block/kelpbundle" + } +} diff --git a/src/main/resources/assets/quickly/lang/de_de.json b/src/main/resources/assets/quickly/lang/de_de.json index ed41b61..7b0e0a3 100644 --- a/src/main/resources/assets/quickly/lang/de_de.json +++ b/src/main/resources/assets/quickly/lang/de_de.json @@ -1,3 +1,4 @@ { + "item.quickly.kelpbundle": "Seegrassbündel", "item.quickly.stub": "Stummel" } diff --git a/src/main/resources/assets/quickly/lang/en_us.json b/src/main/resources/assets/quickly/lang/en_us.json index b32db46..b49fba4 100644 --- a/src/main/resources/assets/quickly/lang/en_us.json +++ b/src/main/resources/assets/quickly/lang/en_us.json @@ -1,3 +1,4 @@ { + "item.quickly.kelpbundle": "kelp bundle", "item.quickly.stub": "stub" } diff --git a/src/main/resources/assets/quickly/models/block/kelpbundle.json b/src/main/resources/assets/quickly/models/block/kelpbundle.json new file mode 100644 index 0000000..c43e3d9 --- /dev/null +++ b/src/main/resources/assets/quickly/models/block/kelpbundle.json @@ -0,0 +1,25 @@ +{ + "parent": "block/block", + "textures": { + "particle": "quickly:block/kelpbundle_side", + "down": "quickly:block/kelpbundle_bottom", + "up": "quickly:block/kelpbundle_top", + "north": "quickly:block/kelpbundle_side", + "east": "quickly:block/kelpbundle_side", + "south": "quickly:block/kelpbundle_side", + "west": "quickly:block/kelpbundle_side" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#down", "cullface": "down" }, + "up": { "texture": "#up", "cullface": "up" }, + "north": { "texture": "#north", "cullface": "north" }, + "south": { "uv": [16, 0, 0, 16], "texture": "#south", "cullface": "south" }, + "west": { "texture": "#west", "cullface": "west" }, + "east": { "uv": [16, 0, 0, 16], "texture": "#east", "cullface": "east" } + } + } + ] +} diff --git a/src/main/resources/assets/quickly/models/item/kelpbundle.json b/src/main/resources/assets/quickly/models/item/kelpbundle.json new file mode 100644 index 0000000..c43e3d9 --- /dev/null +++ b/src/main/resources/assets/quickly/models/item/kelpbundle.json @@ -0,0 +1,25 @@ +{ + "parent": "block/block", + "textures": { + "particle": "quickly:block/kelpbundle_side", + "down": "quickly:block/kelpbundle_bottom", + "up": "quickly:block/kelpbundle_top", + "north": "quickly:block/kelpbundle_side", + "east": "quickly:block/kelpbundle_side", + "south": "quickly:block/kelpbundle_side", + "west": "quickly:block/kelpbundle_side" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 16, 16 ], + "faces": { + "down": { "texture": "#down", "cullface": "down" }, + "up": { "texture": "#up", "cullface": "up" }, + "north": { "texture": "#north", "cullface": "north" }, + "south": { "uv": [16, 0, 0, 16], "texture": "#south", "cullface": "south" }, + "west": { "texture": "#west", "cullface": "west" }, + "east": { "uv": [16, 0, 0, 16], "texture": "#east", "cullface": "east" } + } + } + ] +} diff --git a/src/main/resources/assets/quickly/textures/block/kelpbundle_bottom.png b/src/main/resources/assets/quickly/textures/block/kelpbundle_bottom.png new file mode 100644 index 0000000..d9b32b5 Binary files /dev/null and b/src/main/resources/assets/quickly/textures/block/kelpbundle_bottom.png differ diff --git a/src/main/resources/assets/quickly/textures/block/kelpbundle_side.png b/src/main/resources/assets/quickly/textures/block/kelpbundle_side.png new file mode 100644 index 0000000..7e60401 Binary files /dev/null and b/src/main/resources/assets/quickly/textures/block/kelpbundle_side.png differ diff --git a/src/main/resources/assets/quickly/textures/block/kelpbundle_top.png b/src/main/resources/assets/quickly/textures/block/kelpbundle_top.png new file mode 100644 index 0000000..cba95e6 Binary files /dev/null and b/src/main/resources/assets/quickly/textures/block/kelpbundle_top.png differ diff --git a/src/main/resources/data/quickly/recipe/campfire_dried_kelpblock.json b/src/main/resources/data/quickly/recipe/campfire_dried_kelpblock.json new file mode 100644 index 0000000..bf66062 --- /dev/null +++ b/src/main/resources/data/quickly/recipe/campfire_dried_kelpblock.json @@ -0,0 +1,9 @@ +{ + "type": "minecraft:campfire_cooking", + "ingredient": "quickly:kelpbundle", + "result": { + "id": "minecraft:dried_kelp_block" + }, + "experience": 0.9, + "cookingtime": 615 +} diff --git a/src/main/resources/data/quickly/recipe/shaped_kelpbundle_from_kelp.json b/src/main/resources/data/quickly/recipe/shaped_kelpbundle_from_kelp.json new file mode 100644 index 0000000..6c1c318 --- /dev/null +++ b/src/main/resources/data/quickly/recipe/shaped_kelpbundle_from_kelp.json @@ -0,0 +1,15 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "kkk", + "kkk", + "kkk" + ], + "key": { + "k": "minecraft:kelp" + }, + "result": { + "id": "quickly:kelpbundle", + "count": 1 + } +} \ No newline at end of file