make new custom block available only if a specified mod is loaded

Started by Toxxikz on

Topic category: Help with MCreator software

Last seen on 14:55, 7. Aug 2020
Joined Jul 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
make new custom block available only if a specified mod is loaded
Sun, 07/05/2020 - 21:24 (edited)

I am have created a new block in my mod lets call it osmium_cane but i dont want this block to be available unless the mekanism mod is loaded, cant seem to figure out how to do this,

I know it can make the entire mod dependent upon mekanism being loaded, but other elements do not require it, i only want this one block to be removed if mekanism is not loaded.

Edited by Toxxikz on Sun, 07/05/2020 - 21:24
Last seen on 03:10, 19. Feb 2022
Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
yes, this is possible, but…
Sun, 07/05/2020 - 23:52

yes, this is possible, but you would need some coding knowledge.

First, lock the code of your item mod element(using the lock button on the sidebar) and go to its .java file. (using the pencil and lines button).

Then, find the method called "initElements". It should be around line 28. It would look something like this:

	@Override
	public void initElements() {
		elements.items.add(() -> new ItemCustom());
	}

Then, replace the above code with this and run control+w to add all imports.

    @Override
    public void initElements() {
        if(ModList.get().isLoaded("modid of the mod you want")){
            elements.items.add(() -> new ItemCustom());
        }
    }

Essentially what this does is check if a mod is loaded, if so, register this item in the mod element list. This would prevent the mod element being loaded if the mod isn't detected, which will further prevent the item being registered if the mod isn't loaded.

Last seen on 23:53, 23. Apr 2024
Joined Mar 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Wow, thanks, I was really…
Mon, 07/06/2020 - 00:28

Wow, thanks, I was really looking for this, but would you happen to know how to register an item on a tab in another mod's creative?

Last seen on 03:10, 19. Feb 2022
Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't really know, sorry :(
Sun, 07/12/2020 - 13:33

I don't really know, sorry :(