Jump to content

[Solved]Text repeated over and over in hotbar 1.6.4 mod


Glistre

Recommended Posts

I added a method .smiteaspect onUpdate enchantment to my custom sword.

 

Oddly the text "Smiteaspect 22 " repeats and shows itself over and over and over when hovering over the hotbar

 

Any ideas?

 

 @Override
/** Makes your Item Enchanted on startup */
   public void onUpdate(ItemStack stack, World worldIn, Entity entityIn,
         int itemSlot, boolean isSelected) {
      stack.addEnchantment(Enchantment.smite, 22);
      super.onUpdate(stack, worldIn, entityIn, itemSlot, isSelected);
   }
            // Replace the "." after "Enchantment" to see options
            // The number is the Enchantment Level 

 

 

Link to comment
Share on other sites

I don't think I understood you in best possible manner.

Item#onUpdate(...) is (I think) called EVERY tick when item is inside player's inventory (desn't matter slot) and MAYBE in some other cases (idk, never was a fan of this method, so never checked).

 

Basically what you are doing is adding enchantment over and over again. That isn't your goal, is it?

You can check is ench was added and then if not - add it.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

To do that you will need to override:

    @SideOnly(Side.CLIENT)
    public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)
    {
        subItems.add(new ItemStack(itemIn, 1, 0));
    }

And add any kind of ItemStack with alredy set NBT tag you want.

 

EDIT

To give you wider look:

onCrafted (or Created, don't remember) is called when you pull item result from crafting grid. There you could add NBT when crafting.

Mentioned above getSubItems() allows you to add any number of custom ItemStacks into given tab.

If you would like to have custom crafting for this item: e.g: when you put stick + stone you get bolt with NBT "stone" and if stick + iron you get bolt (same item), but with NBT "iron" you will need to make new IRecipy and handle your ItemStack creation.

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

""To do that you will need to override:

Code: [select]

    @SideOnly(Side.CLIENT)

    public void getSubItems(Item itemIn, CreativeTabs tab, List subItems)

    {

        subItems.add(new ItemStack(itemIn, 1, 0));

    }

And add any kind of ItemStack with alredy set NBT tag you want.""

 

 

Sorry I do not really understand ....I am very new at this ..is that code in the Item file and I override it?  I can see that the onUpdate keeps updating every so many ticks or something

 

 

Link to comment
Share on other sites

Yes, override the method in your custom Item class.

And the onUpdate method you used is bad for pre-enchanting purpose.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

  • 2 weeks later...

I do not really get the NBT stuff but here's what did work for me:

 

 @Override
    public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List list)
    {
    //super (par1, par2CreativeTabs, list, EnumEnchantmentType.weapon);
//    list.add(new ItemStack(par1, 1, 0));}

   // list.add(new ItemStack(Main.Glistre_Sword, 1, 0));
            //Adds string with smite level 22 
        ItemStack string = new ItemStack(Main.Glistre_Sword);
        string.addEnchantment(Enchantment.smite, 22);
        list.add(string);
    }

 

Didnot need the super constructor even though eclipse says it needs it

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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