Pre-Enchanted Armor Piece Help

Started by Kane on Fri, 09/02/2016 - 21:49

Topic category: Help with modding (Java Edition)

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Pre-Enchanted Armor Piece Help
Fri, 09/02/2016 - 21:49

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:

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
I came out with this ugly
Sat, 09/03/2016 - 22:07

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:

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Do you have it correctly in
Sat, 09/03/2016 - 22:55

Do you have it correctly in the instance/class of the item?

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
RE:Do you have it correctly in
Sat, 09/03/2016 - 23:37

@#2 I guess it, it is right after 

static { ItemArmor.ArmorMaterial etc..;

boots = etc... {

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
If in your version the item
Sun, 09/04/2016 - 09:54

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.

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
RE:If in your version the item
Sun, 09/04/2016 - 10:20

@#3 it's directly instance of itemAmor and in fact First I put it right after 

boots = (new ItemArmor(enuma, armorPreffix, EntityEquipmentSlot.FEET) {

 

 

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Hmmm...try:
Sun, 09/04/2016 - 19:05

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]

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
RE:Hmmm...try:
Sun, 09/04/2016 - 19:16

@#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

Last seen on 00:21, 11. Aug 2019
Joined Aug 2013
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Just put after the previous
Sun, 09/04/2016 - 19:24

Just put after the previous method:

[spoiler]
@Override
 public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn)
    {
stack.addEnchantment(Enchantments.DEPTH_STRIDER, 3);

}

[/spoiler]

Last seen on 12:58, 23. Sep 2019
Joined Aug 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
RE:Just put after the previous
Sun, 09/04/2016 - 19:35

@#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