Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How to change attribute of item stack? 1.12.2
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 1
AntonBespoiasov

How to change attribute of item stack? 1.12.2

By AntonBespoiasov, November 5 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

AntonBespoiasov    0

AntonBespoiasov

AntonBespoiasov    0

  • Tree Puncher
  • AntonBespoiasov
  • Members
  • 0
  • 25 posts
Posted November 5 (edited)

I want to make sword that increases and decreases its attack damage. To do that I use attributes of item stack. To change attack damage I need to change amount of attribute generic.attackDamage. How can I do that in hitEntity method of ItemStack?

Edited November 11 by AntonBespoiasov
  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 6

You need to store whatever data you need in the ItemStack. Either through raw NBT (ItemStack#getTag and friends, make sure to include your ModID in your keys to avoid conflicts) or using a capability.

Then you can override IForgeItem#getAttributeModifiers(EquipmentSlotType, ItemStack), get the data from the stack and return the appropraite modifiers. To then change the modifiers, you just have to change the data in the ItemStack.

  • Quote

Share this post


Link to post
Share on other sites

AntonBespoiasov    0

AntonBespoiasov

AntonBespoiasov    0

  • Tree Puncher
  • AntonBespoiasov
  • Members
  • 0
  • 25 posts
Posted November 13 (edited)
On ‎11‎/‎6‎/‎2019 at 11:32 AM, diesieben07 said:

You need to store whatever data you need in the ItemStack. Either through raw NBT (ItemStack#getTag and friends, make sure to include your ModID in your keys to avoid conflicts) or using a capability.

Then you can override IForgeItem#getAttributeModifiers(EquipmentSlotType, ItemStack), get the data from the stack and return the appropraite modifiers. To then change the modifiers, you just have to change the data in the ItemStack.

 

How can I override IForgeItem#getAttributeModifiers(EquipmentSlotType, ItemStack) if Minecraft will still return common ItemStack. And I didn't find IForgeItem in Forge with C+SHIFT+H.
Edited November 13 by AntonBespoiasov
  • Quote

Share this post


Link to post
Share on other sites

Draco18s    2093

Draco18s

Draco18s    2093

  • Reality Controller
  • Draco18s
  • Members
  • 2093
  • 14027 posts
Posted November 13
52 minutes ago, AntonBespoiasov said:

And I didn't find IForgeItem in Forge with C+SHIFT+H.

Its what Forge does in 1.14 instead of the /* === FORGE START === */ chunks.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6684

diesieben07

diesieben07    6684

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6684
  • 45696 posts
Posted November 14

In 1.12.2 it's just a method of Item.

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • thevortex
      Minecraft v1.15 - Supported by Forge?

      By thevortex · Posted 58 minutes ago

      seems obvious, no Forge on this site, you are using the wrong version of minecraft, of course it wont work 
    • EmerProd
      Forge 1.12.2 Crash

      By EmerProd · Posted 1 hour ago

      It worked by removing the 1.7.10 and 1.8.9 Optifine from mods folder, thank you.
    • J3sq
      Minecraft v1.15 - Supported by Forge?

      By J3sq · Posted 1 hour ago

      I have just re-installed Minecraft Java Edition onto a new Windows 10 PC, after a while of not playing. I haven't had many issues with modding (that I couldn't solve through reading) in the past, however this time I can't seem to get Forge to recognise any mods. I'm fairly sure my issue is that I'm running version 1.15 of Minecraft and version 1.14.4 of Forge - I have searched and searched for Forge 1.15 and have found a couple of dodgy links (which I did not click), however as Forge version 1.15 is not on the official site I was wondering if anyone can advise me on what to do? Is there a current fix for this or do I just wait for a compatible version?   debug.log: https://pastebin.com/6HzEwf0K    
    • bandofbros20
      1.12.2 Forge isnt working, are these the logs you need?

      By bandofbros20 · Posted 1 hour ago

      [1211/164737.130:WARNING:angle_platform_impl.cc(41)] rx::HLSLCompiler::compileToBinary(224):  C:\fakepath(37,8-56): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them C:\fakepath(43,8-26): warning X3571: pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them
    • Draco18s
      Distinguish singleplayer vs. multiplayer

      By Draco18s · Posted 2 hours ago

      Items are not proxies. Proxies are proxies, Items are Items. The Item is supposed to call a method in the proxy, it is not the proxy itself.
  • Topics

    • J3sq
      1
      Minecraft v1.15 - Supported by Forge?

      By J3sq
      Started 1 hour ago

    • EmerProd
      4
      Forge 1.12.2 Crash

      By EmerProd
      Started Sunday at 06:23 PM

    • bandofbros20
      0
      1.12.2 Forge isnt working, are these the logs you need?

      By bandofbros20
      Started 1 hour ago

    • solitone
      15
      Distinguish singleplayer vs. multiplayer

      By solitone
      Started December 5

    • vMystic
      0
      [1.12.2] plugin with id 'net.minecraftforge.gradle.forge' not found

      By vMystic
      Started 2 hours ago

  • Who's Online (See full list)

    • stepsword
    • thedarkcolour
    • coolsim
    • poopoodice
    • Casual
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • How to change attribute of item stack? 1.12.2
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community