Topic category: Help with modding (Java Edition)
Hello!
I wanted to ask quick question which will be crazy useful for my mod's add-on/compatibility features, yet I do not see that option in MCreator per se. And though I asked Klemen for that feature, I'm a bit afraid it won't go through 2021.2 dev process, since devs have already a lot of work on Gradle cache problem and.. other features, of course.
Question is: how can I apply Forge item Tag for enchantment? This way enchantment would not only work for items from my mod, but also for all add-ons and mods that will use my mod's Forge Tag to create their own guns.
From investigating code, I found that part of enchantment which is - I'm pretty sure - this part deciding on what kind of items enchantment applies to. It is currently using item, just for reference. How should it look like if I would like use Forge item Tag instead?
(Forge item Tag is "forge:wobr_firearms", if it's needed)
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack) {
if (stack.getItem() == new ItemStack(GoldenShotRevolverItem.block, (int) (1)).getItem())
return true;
return false;
}
Thanks in advance ^^
Hey there Toma400,
After trying some code I have found the solution to do this.
At least, this code worked for me:
Just replace the "tagname" after forge: with the name of your tag. (so in your case it should be "forge:wobr_firearms").
I do want to point out that at first, it might give an error message, but if you rewrite "ItemTags" and "ResourceLocation" it works.
It's so funny, I learned code a bit lately and came back to this idea, making working code... which is exactly what you suggested me, probably in the same day I added that feature without knowing about such kind person trying to help me ^^
But thank you nevertheless for the help, if I didn't start learning lately, you would save my life with this!
If you do not have anything against it, I can link this topic with your answer to my compatibility guide, so if anyone is wondering how to make that feature, it will be helpful for them too ^^
That's totally fine, Since you posted this a while back I did think you might've found a solution to it, but I wasn't sure and still wanted to help. Linking it to your compatibility guide sounds like a great idea.
I linked it, thank you so much ^^
By the way, I also made a code storaging gist, so if anyone wants to have correct code for any post-1.12 version, it can be found here.
For now it supports 1.14-1.18 code, but I will try to support it for newer versions, as long as I actively make mods (if new version is out and gist isn't updated, just contact me).
What should i rewrite in the place of RecourseLocation?