Jump to content

Recommended Posts

Posted

Okay so I'm really new at modding and I was wondering how I would be able to use an item from a different mod in a crafting recipe?

 

I'm not sure how I would reference the item?

 

Thanks in advance

Posted

Well, your mod then would have a dependency on the other mod. So you'll want to make sure you indicate that in your @Mod annotation with something like:

    @Mod(modid = "yourmodid", version="yourversion", dependencies="required-after:othermodid")

 

Of course you need to replace your mod's id and version, and the other mod's id as appropriate for your case.

 

Once you're sure the mod is loaded, you can look up the item using the GameRegistry if you know the mod id and the unlocalized name used to register the item.

 

So you could have code like this whenever you want to the item:

    GameRegistry.findItem(modid, itemUnlocalizedName)

 

Of course you need to replace the modid and itemUnlocalizedName to match the mod.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

I don't remember the exact syntax, but I have this at home.  I'll look it up tonight if you haven't gotten it by then.

 

You can try to get an item by name from another mod by referring to it as something like "modid2.specialsword".

 

You check to see if it was found.  If so, proceed with the recipe and whatever.  If not, abandon.

 

 

Someone else probably knows the syntax by heart and can help you before tonight.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

if you know the mod id and the unlocalized name used to register the item.

This has nothing to do with unlocalized names.

 

Okay, you're right except most modders I've seen use the unlocalized name also as the tag to register their items. But you're right that the string used to register is what is required and it might be different.

 

Anyway, you need to know the string used by the other mod for the item name when it is registered.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Posted

Here is the syntax I mentioned earlier today.

 

Item item = GameRegistry.findItem("dimension_multiplyer", "dimension_multiplyer-firewand");

 

then do a null check on the item before using it.

Long time Bukkit & Forge Programmer

Happy to try and help

Posted

How would I do this for a sub-block? Currently I have something like this

 

GameRegistry.addRecipe(new ItemStack(BMBDoorItem), new Object[] {"##", "##", "##", '#', GameRegistry.findBlock("BiomesOPlenty", "planks")});

 

How would I modify this to work for a specific sub-block, sorry if it's completly wrong and I'm misunderstanding.

Posted

Could you possibly give an example of this? or point me in the direction of a tutorial that uses this method?

 

I'm extremely new to this and this would be my first mod.

 

Thanks in advance.

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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