Started by
Kane
on
Topic category: Help with Minecraft modding (Java Edition)
I was trying to make a pre-enchanted armor piece (have it already enchanted when you get it in creative) , like for the items/tools, but it doesn't work.
I know it's more or less the same thing but I can't make it work D:
I came out with this ugly thing: [spoiler]
@SideOnly(Side.CLIENT)
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
Item boots = new ItemStack(itemIn, 1, 0);
boots.addEnchantment(Enchantments.DEPTH_STRIDER, 3);
subItems.add(boots);
[/spoiler]
just no errors but not enchantment too obviously
I can just wonder why it doesn't work D:
Do you have it correctly in the instance/class of the item?
@#2 I guess it, it is right after
static { ItemArmor.ArmorMaterial etc..;
boots = etc... {
If in your version the item is instance of custom class that extends ItemArmor , simply it is supossed to be in the inner class , if the item is directly instance of ItemArmor , you need add after new ItemArmor(...) bracket and your method.
@#3 it's directly instance of itemAmor and in fact First I put it right after
boots = (new ItemArmor(enuma, armorPreffix, EntityEquipmentSlot.FEET) {
Hmmm...try:
[spoiler]
@SideOnly(Side.CLIENT)
@Override
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
Item boots = new ItemStack(itemIn, 1, 0);
boots.addEnchantment(Enchantments.DEPTH_STRIDER, 3);
subItems.add(boots);}
[/spoiler]
@#4 It works! (just had to change Item boots into ItemStack boots) thx a lot!
But now there's another little problem... when I craft them, I get not enchantment (obviously, I didn't think about it).
Where do I have to write the recipe? I've added it automatically with mcreator but it's at the top of the code
Just put after the previous method:
[spoiler]
@Override
public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn)
{
stack.addEnchantment(Enchantments.DEPTH_STRIDER, 3);
}
[/spoiler]
@#5 That was easy! thx a lot!
I was thinking I wrote something wrong (and really dumb) with the boots enchantment code.
It's thanks to you if I'm starting to understand this stuff :D