#1.21.5 Error Block id not set

3 messages · Page 1 of 1 (latest)

charred tree
#

good days im trying to create a custom block following kaupenjoe
Caused by: java.lang.NullPointerException: Block id not set

mi BlockInit only has on block for the moment

public static final Block STEEL_BLOCK = registerBlock(
        "steel_block",
        new bloque(AbstractBlock.Settings.copy(Blocks.IRON_BLOCK)) );

private static Block registerBlock(String name, Block block) {
    Identifier key = Ptools.id(name);
    Registry.register(Registries.ITEM, key,
            new BlockItem(block, new Item.Settings()));

    return Registry.register(Registries.BLOCK, key, block);
}

mi Main class

public void onInitialize() {
    // This code runs as soon as Minecraft is in a mod-load-ready state.
    // However, some things (like resources) may still be uninitialized.
    // Proceed with mild caution.
    LOGGER.info("Hello Fabric world!");
    ModComponents.load();
    ItemInit.load();
    BlockInit.load();
    }

public static Identifier id(String path){
    return Identifier.of(MOD_ID, path);
}

Caused by: java.lang.NullPointerException: Block id not set
at java.base/java.util.Objects.requireNonNull(Objects.java:246)
at knot//net.minecraft.block.AbstractBlock$Settings.getLootTableKey(AbstractBlock.java:671)
at knot//net.minecraft.block.AbstractBlock.<init>(AbstractBlock.java:111)
at knot//net.minecraft.block.Block.<init>(Block.java:236)
at knot//kingdom.ptools.blocks.classes.bloque.<init>(bloque.java:41)
at knot//kingdom.ptools.blocks.BlockInit.<clinit>(BlockInit.java:56)

I dont know what i have wrong whit Blocks
mi ItemInit is working fine
..???

glad wren
#

please search that error in this server. it's been answered countless times

charred tree
#

found ya something ai make it work thanks

public static final Block STEEL_BLOCK = registerBlock(
        "steel_block",
        new bloque(
                AbstractBlock.Settings.copy(Blocks.IRON_BLOCK).registryKey(RegistryKey.of(RegistryKeys.BLOCK, Ptools.id("steel_block")) ).requiresTool().strength(16.0F, 12.0F)
        ) );


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

private static void registerBlockItem(String name, Block block) {
    Registry.register(Registries.ITEM, Identifier.of(Ptools.MOD_ID, name),
            new BlockItem(block, new Item.Settings()
                    .registryKey(RegistryKey.of(RegistryKeys.ITEM, Identifier.of(Ptools.MOD_ID, name))).useBlockPrefixedTranslationKey()));
}