#How to properly implement block into creative menu and in item list?

1 messages · Page 1 of 1 (latest)

worldly sable
#

Starting with the basis.

package net.evilnotch.neomusic.block;

import net.evilnotch.neomusic.NeoMusic;
import net.fabricmc.fabric.api.itemgroup.v1.ItemGroupEvents;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroups;
import net.minecraft.item.PickaxeItem;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier;

public class ModBlocks {
public static final Block RUBY_BLOCK = registerBlock("ruby_block",
new Block(AbstractBlock.Settings.create().strength(4f)
.requiresTool().sounds(BlockSoundGroup.AMETHYST_BLOCK)));

private static Block registerBlock(String name, Block block){
    return Registry.register(Registries.BLOCK, Identifier.of(NeoMusic.MOD_ID, name), block);
}

private static void RegisterBlockItem(String name, Block block) {
    Registry.register(Registries.ITEM, Identifier.of(NeoMusic.MOD_ID, name),
            new BlockItem(block, new Item.Settings()));
}

public static void registerModBlocks() {
    NeoMusic.LOGGER.info("Registering Mod blocks for " + NeoMusic.MOD_ID);

    ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register(fabricItemGroupEntries -> {
        fabricItemGroupEntries.add(ModBlocks.RUBY_BLOCK);
    });
}

}

rotund pewterBOT
#

<@&987246652869971988> please have a look, thanks.

rotund pewterBOT
#

Please use this format for posting code:

```java
// Example java program
int value = 5;
System.out.println(value);
```

Which results in:

// Example java program
int value = 5;
System.out.println(value);

For syntax highlighting, you have to add the name of the language after the three backticks, like ```java. Please make sure to use exactly this format, so no space between the backticks and the language name, and a newline before the code starts. If done right, the syntax highlighting will even be applied to your text as you type, before sending.

valid lance
worldly sable
#

Yeah, but it appears not

valid lance