#Weird behavior when naming blocks in lang file.
13 messages · Page 1 of 1 (latest)
call the useBlockDescriptionPrefix method on your Item.Properties (moj) when registering the item
(useBlockPrefixedTranslationKey and Item.Settings in yarn)
This goes over my head
which part?
ok, show the part where youre registering the block items
import...
import java.util.function.Function;
public class ModBlocks {
public static final String MOD_ID = "calcium";
public static final Block ANDESITE_BRICKS = register("andesite_bricks", Block::new, Block.Settings.create().mapColor(MapColor.STONE_GRAY).instrument(NoteBlockInstrument.BASEDRUM).requiresTool().strength(1.5F, 6.0F), true);
public static final Block ENDER_GROWTH = register("ender_growth", EndPlantBlock::new, AbstractBlock.Settings.create().mapColor(MapColor.DARK_GREEN).replaceable().noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS).offset(AbstractBlock.OffsetType.XYZ).burnable().pistonBehavior(PistonBehavior.DESTROY), true);
public static void initialize() {
ItemGroupEvents.modifyEntriesEvent(ItemGroups.NATURAL).register((itemgroup) -> {
itemgroup.add(ENDER_GROWTH);
});
ItemGroupEvents.modifyEntriesEvent(ItemGroups.BUILDING_BLOCKS).register((itemgroup) -> {
itemgroup.add(ANDESITE_BRICKS);
});
}
private static Block register(String name, Function<AbstractBlock.Settings, Block> blockFactory, AbstractBlock.Settings settings, boolean registerItem) {
RegistryKey<Block> blockKey = keyOfBlock(name);
Block block = blockFactory.apply(settings.registryKey(blockKey));
if (registerItem) {
RegistryKey<Item> itemKey = keyOfItem(name);
BlockItem blockItem = new BlockItem(block, new Item.Settings().registryKey(itemKey));
Registry.register(Registries.ITEM, itemKey, blockItem);
}
return Registry.register(Registries.BLOCK, blockKey, block);
}
private static RegistryKey<Block> keyOfBlock(String name) {
return RegistryKey.of(RegistryKeys.BLOCK, Identifier.of(MOD_ID, name));
}
private static RegistryKey<Item> keyOfItem(String name) {
return RegistryKey.of(RegistryKeys.ITEM, Identifier.of(MOD_ID, name));
}
}```
Here's the repository, if that is easier:
https://github.com/nicolasneal/Calcium-1.21.7
(i actually mistyped Item.Settings here mb)
but here where you make the item settings and call registryKey on it, you just need to call useBlockPrefixedTranslationKey aswell