#How to register items only if certain other mods or items exist

14 messages · Page 1 of 1 (latest)

wary turret
#

I was curious, how could I add new items/blocks if the player has a certain mod installed or if there is a certain item (or item with a c: tag)

fair perch
#

you can't really access tags that early

wary turret
#

Hmm, I've seen forge mods that add certain items if an item with a forge: tag exists (for example, adding a tin sword if an item with forge:ingots/tin exists. Is there a way to do this in fabric?

fair perch
#

they probably read the raw data from all of the jars

#

but tags are not loaded or even initialized at that point normally

wary turret
#

Alright, is there a way to do it with specific items or mods, instead of items with a certain tag?

fair perch
#

just add some conditions to your registration code

#

but be aware that once that conditions aren’t true anymore, your content will disappear from the world

clear hazel
#

conditional registration should probably be avoided if possible. instead you should register them always and use minecraft's "feature toggles" system. it is used by all experimental features (such as bundles) and is quite simple & safe as your content won't just vanish from worlds if the dependency mod is unloaded

wary turret
#

How can I check if a mod is loaded? In forge its something like ModList.get().isLoaded()

clear hazel
#

FabricLoader.getInstance().isModLoaded(...)

wary turret
#

Thanks

clear hazel
#

not sure how it works for recipes, if it just handles it or you need to do something. in any case check bundles or the 1.21 experimental datapack for reference

wary turret
#

Just to check, there is no way of checking if an item that has a certain tag exists (say c:tin_ore). Instead, the code has to look for some mod that adds that item (tin ore for example), right?