added first block kelpbundle

This commit is contained in:
Jottyfan
2025-12-23 11:19:41 +01:00
parent 6b8cf2a56e
commit 5676994b93
16 changed files with 161 additions and 17 deletions

View File

@@ -17,6 +17,6 @@ public class Quickly implements ModInitializer {
@Override
public void onInitialize() {
LOGGER.info("Hello Fabric world!");
LOGGER.info("loading {}", MOD_ID);
}
}

View File

@@ -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();
}
}

View File

@@ -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<Properties, Block> function) {
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
ResourceKey<Block> blockResourceKey = ResourceKey.create(Registries.BLOCK, identifier);
Block block = function.apply(properties.setId(blockResourceKey));
Registry.register(BuiltInRegistries.BLOCK, identifier, block);
ResourceKey<Item> 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);
});
}
}

View File

@@ -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<Properties, Item> function) {
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
ResourceKey<Item> rc = ResourceKey.create(Registries.ITEM, identifier);
Item i = function.apply(properties.setId(rc).modelId(identifier).useItemDescriptionPrefix());
return Registry.register(BuiltInRegistries.ITEM, identifier, i);
ResourceKey<Item> 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);
});
}
}

View File

@@ -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<Block, Item> 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<Block, Item> 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);
}
}
}

View File

@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "quickly:block/kelpbundle"
}
}
}

View File

@@ -0,0 +1,6 @@
{
"model": {
"type": "minecraft:model",
"model": "quickly:block/kelpbundle"
}
}

View File

@@ -1,3 +1,4 @@
{
"item.quickly.kelpbundle": "Seegrassbündel",
"item.quickly.stub": "Stummel"
}

View File

@@ -1,3 +1,4 @@
{
"item.quickly.kelpbundle": "kelp bundle",
"item.quickly.stub": "stub"
}

View File

@@ -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" }
}
}
]
}

View File

@@ -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" }
}
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@@ -0,0 +1,9 @@
{
"type": "minecraft:campfire_cooking",
"ingredient": "quickly:kelpbundle",
"result": {
"id": "minecraft:dried_kelp_block"
},
"experience": 0.9,
"cookingtime": 615
}

View File

@@ -0,0 +1,15 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"kkk",
"kkk",
"kkk"
],
"key": {
"k": "minecraft:kelp"
},
"result": {
"id": "quickly:kelpbundle",
"count": 1
}
}