#[SOLVED?] 1.21.5 GetBlock() of Block Item returns null

9 messages · Page 1 of 1 (latest)

jagged sage
#
Caused by: java.lang.NullPointerException: Cannot invoke "net.minecraft.block.Block.getRequiredFeatures()" because the return value of "net.minecraft.item.BlockItem.getBlock()" is null

I've never run into this issue before. I've declared a crop block according to Kaupenjoe's tutorial and Fabric docs.

I've just implemented World Gen and Tree Generators and now this issue has risen and I'm not sure why.

#
    public static final Item CHORUS_ROOT = registerItem(
            "chorus_root",
            (settings) -> new BlockItem(
                    ModBlocks.CHORUS_ROOT_CROP,
                    settings.food(ModFoodComponents.CHORUS_ROOT_FOOD_COMPONENT,
                            ModFoodComponents.CHORUS_ROOT_CONSUMABLE_COMPONENT)
            ),
            new Item.Settings().food(ModFoodComponents.CHORUS_ROOT_FOOD_COMPONENT,
                    ModFoodComponents.CHORUS_ROOT_CONSUMABLE_COMPONENT)
    );

This is the item in question

wise vortex
#

post the full code of your mod initializer, ModBlocks and ModItem (i guess)

jagged sage
#

So...

#

I just kept rebuilding a bunch of times

#

And then it fixed itself

#

I think what caused it is that I tried running Datagen that would also give the crop item and item model, while the crop block already does that for it

#

And I think that muddled up my json files

#

So rerunning my datagen a few times and peering into the jsom folders seemed to fix it