Is it possible to hide item/block from creative tab, if specific mod is not loaded?

Started by Toma400 on Sun, 07/25/2021 - 22:43

Topic category: Help with modding (Java Edition)

Last seen on 06:19, 20. Sep 2021
Joined Dec 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Is it possible to hide item/block from creative tab, if specific mod is not loaded?
Mon, 07/26/2021 - 08:15 (edited)

Hello!
As in topic title, I'd love to add integration features to my mod, using other mods' woods. The thing is, even if I create custom crafting recipes requiring other mod to exist, blocks will still exist in creative Tab. And that's great, I really want to have integrated blocks in creative Tab! 
The thing is, I'd like to have them appear only if that other mod is installed, so author won't feel like I'm just giving people option to avoid his mod by adding similar features in mine, available without even installing it. And if I use other mods' textures, it would also help me avoid showing broken textures in case this mod isn't installed.

If it's possible only by code, could someone guide me through it? It will be really appreciated.

Edited by Toma400 on Mon, 07/26/2021 - 08:15
Last seen on 06:19, 20. Sep 2021
Joined Dec 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Quick bump! Sorry for that,…
Mon, 08/09/2021 - 09:23

Quick bump! Sorry for that, but it would help soo much with my current mod development!

I'm assuming this part of code is related to what I wrote here:

    @Override
    public void initElements() {
        elements.blocks.add(() -> new CustomBlock());
        elements.items.add(
                () -> new BlockItem(block, new Item.Properties().group(WoBIntegrationsTabItemGroup.tab)).setRegistryName(block.getRegistryName()));

And I suppose it should contain if somewhere within this "elements.items.add" part. Like "if mod_id:block is loaded[*]" -> "newBlockItem.group (...)".
I'm not sure though how to make that since I'm not (yet) familiar with Java syntax and I don't even have any idea where to start.

---

[*] - I think checking loading block will be better than checking loading of whole mod, since if I try to make cross-version integration, some blocks from Biomes o Plenty from 1.16 won't be available in 1.14, so it would mean showing blocks not possible to craft and with broken textures (I was requested to use BoP textures directly from his mod, not to add ones to my own)