added first block kelpbundle
This commit is contained in:
@@ -17,6 +17,6 @@ public class Quickly implements ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
LOGGER.info("Hello Fabric world!");
|
LOGGER.info("loading {}", MOD_ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
package de.jottyfan.minecraft;
|
package de.jottyfan.minecraft;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.block.QuicklyBlocks;
|
||||||
import de.jottyfan.minecraft.item.QuicklyItems;
|
import de.jottyfan.minecraft.item.QuicklyItems;
|
||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
|
|
||||||
@@ -13,5 +14,6 @@ public class QuicklyClient implements ClientModInitializer {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
QuicklyItems.registerModItems();
|
QuicklyItems.registerModItems();
|
||||||
|
QuicklyBlocks.registerModBlocks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
47
src/main/java/de/jottyfan/minecraft/block/QuicklyBlocks.java
Normal file
47
src/main/java/de/jottyfan/minecraft/block/QuicklyBlocks.java
Normal 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);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,18 +19,18 @@ import net.minecraft.world.item.Item.Properties;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class QuicklyItems {
|
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) {
|
private static final Item registerItem(String name, Item.Properties properties, Function<Properties, Item> function) {
|
||||||
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
|
Identifier identifier = Identifier.fromNamespaceAndPath(Quickly.MOD_ID, name);
|
||||||
ResourceKey<Item> rc = ResourceKey.create(Registries.ITEM, identifier);
|
ResourceKey<Item> itemResourceKey = ResourceKey.create(Registries.ITEM, identifier);
|
||||||
Item i = function.apply(properties.setId(rc).modelId(identifier).useItemDescriptionPrefix());
|
Item item = function.apply(properties.setId(itemResourceKey).modelId(identifier).useItemDescriptionPrefix());
|
||||||
return Registry.register(BuiltInRegistries.ITEM, identifier, i);
|
return Registry.register(BuiltInRegistries.ITEM, identifier, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerModItems() {
|
public static void registerModItems() {
|
||||||
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(i -> {
|
ItemGroupEvents.modifyEntriesEvent(CreativeModeTabs.TOOLS_AND_UTILITIES).register(item -> {
|
||||||
i.accept(MY_ITEM);
|
item.accept(STUB);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package de.jottyfan.minecraft.item;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import de.jottyfan.minecraft.block.QuicklyBlocks;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.sounds.SoundEvents;
|
import net.minecraft.sounds.SoundEvents;
|
||||||
import net.minecraft.sounds.SoundSource;
|
import net.minecraft.sounds.SoundSource;
|
||||||
@@ -16,20 +17,26 @@ import net.minecraft.world.level.Level;
|
|||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
import net.minecraft.world.level.block.Blocks;
|
import net.minecraft.world.level.block.Blocks;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author jotty
|
||||||
|
*
|
||||||
|
*/
|
||||||
public class Stub extends Item {
|
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) {
|
public Stub(Properties properties) {
|
||||||
super(properties.stacksTo(64));
|
super(properties.stacksTo(64));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InteractionResult useOn(UseOnContext context) {
|
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();
|
Level level = context.getLevel();
|
||||||
BlockPos pos = context.getClickedPos();
|
BlockPos pos = context.getClickedPos();
|
||||||
Block clickedBlock = level.getBlockState(pos).getBlock();
|
Block clickedBlock = level.getBlockState(pos).getBlock();
|
||||||
@@ -41,8 +48,7 @@ public class Stub extends Item {
|
|||||||
ItemStack stack = new ItemStack(SLASH_MAP.get(clickedBlock));
|
ItemStack stack = new ItemStack(SLASH_MAP.get(clickedBlock));
|
||||||
float xScatter = new Random().nextFloat();
|
float xScatter = new Random().nextFloat();
|
||||||
float yScatter = new Random().nextFloat();
|
float yScatter = new Random().nextFloat();
|
||||||
ItemEntity entity = new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(),
|
ItemEntity entity = new ItemEntity(level, pos.getX(), pos.getY(), pos.getZ(), stack, xScatter, yScatter, 0.2);
|
||||||
stack, xScatter, yScatter, 0.2);
|
|
||||||
level.addFreshEntity(entity);
|
level.addFreshEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"": {
|
||||||
|
"model": "quickly:block/kelpbundle"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
6
src/main/resources/assets/quickly/items/kelpbundle.json
Normal file
6
src/main/resources/assets/quickly/items/kelpbundle.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"model": {
|
||||||
|
"type": "minecraft:model",
|
||||||
|
"model": "quickly:block/kelpbundle"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
"item.quickly.kelpbundle": "Seegrassbündel",
|
||||||
"item.quickly.stub": "Stummel"
|
"item.quickly.stub": "Stummel"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
"item.quickly.kelpbundle": "kelp bundle",
|
||||||
"item.quickly.stub": "stub"
|
"item.quickly.stub": "stub"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -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 |
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:campfire_cooking",
|
||||||
|
"ingredient": "quickly:kelpbundle",
|
||||||
|
"result": {
|
||||||
|
"id": "minecraft:dried_kelp_block"
|
||||||
|
},
|
||||||
|
"experience": 0.9,
|
||||||
|
"cookingtime": 615
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"kkk",
|
||||||
|
"kkk",
|
||||||
|
"kkk"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"k": "minecraft:kelp"
|
||||||
|
},
|
||||||
|
"result": {
|
||||||
|
"id": "quickly:kelpbundle",
|
||||||
|
"count": 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user