Jump to content

[1.16.5] Registering BlockItem - might be null


FaaatPotato

Recommended Posts

Thats what ive done so far and i dont know why it isnt working at all...
Should create an Item in the Redstone group for every block created in BlockInit with the RegistryName
 

    @SubscribeEvent
    public static void onRegisterItems(final RegistryEvent.Register<Item> event) {
    BlockInit.BLOCKS.getEntries().stream().map(RegistryObject::get).forEach(block -> {
        event.getRegistry().register(new BlockItem(block, new Item.Properties().group(ItemGroup.REDSTONE)).setRegistryName(block.getRegistryName()));
    });
    }

That last part

.setRegistryName(block.getRegistryName()));

isnt working i guess. Throws:
 

this = {RegistryEvent$Register@11809} Object is being initialized
name = {ResourceLocation@11810} "minecraft:block"
registry = {ForgeRegistry@11811} 
this.registry = null
this.name = null

when i debug and i get this warning when i hover over that part:


image.png

any ideas?

Edited by FaaatPotato
added image for better understanding of my issue
Link to comment
Share on other sites

1. Yes, that is the error message i get when im looking at the debug tab while debugging.

2. I dont know, seemed like a clean and fast way to create an item for every block and put it in one tab.


image.png


Also this is where the client starts loading and just stops as soon as this error appears with no response (only happens when debugging, when starting normally the item just isnt showing up.)

Link to comment
Share on other sites

Sorry, maybe i wasnt clear enough. I wanted to create an item for every block i created in a BlockInit or "ModBlocks", however you want to call it, and put it into the redstone tab for now. But that isnt working - the BlockItem isnt showing up in the Redstone Tab. Thats the problem im facing right now.

Link to comment
Share on other sites

here:

@Mod.EventBusSubscriber(modid = Modlearning.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)

@SubscribeEvent
public static void onRegisterItems....

 

and thats in the public main()
 

    public Modlearning() {
        IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus();

        BlockInit.BLOCKS.register(bus);
        ItemInit.ITEMS.register(bus);

        MinecraftForge.EVENT_BUS.register(this);
    }

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.