The Meaning of Life, the Universe, and Everything.
Join Date:
4/7/2011
Posts:
233
Member Details
So, I made this weapon, Frostmourne, and I made it from a toolMaterial with decent damage. The problem is that I want both Frostmourne and the armor to have stats like strength, that increases the left click attack damage. Is there any way to do this, that also increases the damage displayed on the tooltip?
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
Make a custom class that extends ItemSword. In the constructor, set the damage the same way ItemSword usually does, but add a little more than the tool material's damage instead.
Look at ItemSword for details/examples.
Rollback Post to RevisionRollBack
Click this banner for a list of illegal mod distributors -- only download from legal sites!
Make a custom class that extends ItemSword. In the constructor, set the damage the same way ItemSword usually does, but add a little more than the tool material's damage instead.
Look at ItemSword for details/examples.
I think the OP is wanting to raise the attack damage of anything while the particular armour is being worn, although I may be wrong.
You are correct, testing the code you sent me right now. Thanks!
I'm correct about changing anything's attack damage? Because if so, that code might not help. That code was for just changing the attack damage of that particular item.
The Meaning of Life, the Universe, and Everything.
Join Date:
4/7/2011
Posts:
233
Member Details
You are correct about how I want to dynamically change the damage. Your second suggestion could work, but it would not display the damage correctly on the tooltip :s
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
You are correct about how I want to dynamically change the damage. Your second suggestion could work, but it would not display the damage correctly on the tooltip :s
Hmm well I've dug into the vanilla code again, and the damage displayed on the item is the item's attack damage from that attack attribute, plus the player's base attack damage attribute (damage dealt by punching with bare hands). What you might be able to do is add the extra damage to the player's attack damage attribute when you have the armour equipped. Take a look at the way EntityLivingBase#setSprinting works - you could possibly do something similar to set the attack damage yourself.
If you want to see where the tooltip attack damage is calculated, have a look at the ItemStack class at about line 787 onwards.
Hmm well I've dug into the vanilla code again, and the damage displayed on the item is the item's attack damage from that attack attribute, plus the player's base attack damage attribute (damage dealt by punching with bare hands). What you might be able to do is add the extra damage to the player's attack damage attribute when you have the armour equipped. Take a look at the way EntityLivingBase#setSprinting works - you could possibly do something similar to set the attack damage yourself.
If you want to see where the tooltip attack damage is calculated, have a look at the ItemStack class at about line 787 onwards.
Setting player base damage would be the best for sure! I assume that would update the damage on all weapons in the game, not just this particular weapon?
Setting player base damage would be the best for sure! I assume that would update the damage on all weapons in the game, not just this particular weapon?
Yes since the player's attack damage attribute is added to the current held item's one when attacking.
By the way, do you know about a deobfuscated source library?
If you're using Forge then you should be able to locate the vanilla code using the project view on the left side of your IDE. I'm using Idea, and the vanilla code is located in: Libraries -> net -> minecraft
You can see it in the screenshot I've attached.
Yes since the player's attack damage attribute is added to the current held item's one when attacking.
If you're using Forge then you should be able to locate the vanilla code using the project view on the left side of your IDE. I'm using Idea, and the vanilla code is located in: Libraries -> net -> minecraft
You can see it in the screenshot I've attached.
All right, I managed to get the attribute updated, and the damage is increased. However, it does not change on the tooltip. Plz halp xD
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
If you do this, you could get a Multimap from getAttributeModifiers() in the ItemArmor class and add those traits to the multimap. It should display that the player has increased health and strength from attacking.
I suspect that I must modify the tooltip generator to make it update the actual damage
Would probably be best to move this sort of code into the armour's onArmorTick() method. The world, player and item stack is given as parameters for this method.
Hmm modifying the tooltip just sounds like a lot of effort :/ I'm sure this will work, we just haven't got it right yet.
If you do this, you could get a Multimap from getAttributeModifiers() in the ItemArmor class and add those traits to the multimap. It should display that the player has increased health and strength from attacking.
Gonna try this, thanks!
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
Would probably be best to move this sort of code into the armour's onArmorTick() method. The world, player and item stack is given as parameters for this method.
Hmm modifying the tooltip just sounds like a lot of effort :/ I'm sure this will work, we just haven't got it right yet.
That might be benefitical, but I smell some issue with adding the stats together tho. Also, this has the benefit that no matter what items you are using with strength or stamina, equiped or in the action bar, it will always give damage and health. Should I still move it to onArmorTick()?
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
That might be benefitical, but I smell some issue with adding the stats together tho. Also, this has the benefit that no matter what items you are using with strength or stamina, equiped or in the action bar, it will always give damage and health. Should I still move it to onArmorTick()?
You should be able to still add the stats the same as you were, since you have the player instance.
Yeah this should work too - the onArmorTick will get called every tick for that piece of armour while it is worn, so you can apply your stat increases regardless of what the player is holding. It should be more efficient than using the tick handler as this will only get called if you're wearing the armour, whereas the tick handler method will still get called. I know it's not much, but it's there, and it just helps that tiny little bit
I think you should move it there. Just make sure you only run it once if you're wearing multiple pieces of the armour! You might want to only run the code if you're wearing a full set, which in that case you should choose one piece as the one to do all the processing (use an if statement), and it should check for the other pieces of armour being worn before running the code.
You should be able to still add the stats the same as you were, since you have the player instance.
Yeah this should work too - the onArmorTick will get called every tick for that piece of armour while it is worn, so you can apply your stat increases regardless of what the player is holding. It should be more efficient than using the tick handler as this will only get called if you're wearing the armour, whereas the tick handler method will still get called. I know it's not much, but it's there, and it just helps that tiny little bit
This makes very much sense, the second part seems a bit clumsy. If I understand you right, you want the stat changes to be a part of for instance the chest plates onTick, which would mean that chest plates would be a key to get stat benefits in general. I dont like that... However, part I quoted is worth considering! Thanks again man, take another +1 from me
Rollback Post to RevisionRollBack
Whomsoever takes up this mod shall wield power eternal.
So, I made this weapon, Frostmourne, and I made it from a toolMaterial with decent damage. The problem is that I want both Frostmourne and the armor to have stats like strength, that increases the left click attack damage. Is there any way to do this, that also increases the damage displayed on the tooltip?
Make a custom class that extends ItemSword. In the constructor, set the damage the same way ItemSword usually does, but add a little more than the tool material's damage instead.
Look at ItemSword for details/examples.
I think the OP is wanting to raise the attack damage of anything while the particular armour is being worn, although I may be wrong.
However if that is what is wanted, I have an example of a sword's attack damage being dynamically changed depending on the sword's durability:
https://github.com/alxnns1/MobHunter/blob/master/src/main/java/com/alxnns1/mobhunter/item/ItemMHSword.java#L88-L97
You are correct, testing the code you sent me right now. Thanks!
Is this for forge 1.7.10? I cannot import EntityEquipmentSlot :/
I'm correct about changing anything's attack damage? Because if so, that code might not help. That code was for just changing the attack damage of that particular item.
I've had a thought though, you might be able to use the LivingAttackEvent to increase the damage dealt depending on the armour. You can check out a little about it here:
http://www.minecraftforge.net/wiki/Event_Reference#LivingAttackEvent
You are correct about how I want to dynamically change the damage. Your second suggestion could work, but it would not display the damage correctly on the tooltip :s
Hmm well I've dug into the vanilla code again, and the damage displayed on the item is the item's attack damage from that attack attribute, plus the player's base attack damage attribute (damage dealt by punching with bare hands). What you might be able to do is add the extra damage to the player's attack damage attribute when you have the armour equipped. Take a look at the way EntityLivingBase#setSprinting works - you could possibly do something similar to set the attack damage yourself.
If you want to see where the tooltip attack damage is calculated, have a look at the ItemStack class at about line 787 onwards.
Setting player base damage would be the best for sure! I assume that would update the damage on all weapons in the game, not just this particular weapon?
By the way, do you know about a deobfuscated source library?
Yes since the player's attack damage attribute is added to the current held item's one when attacking.
If you're using Forge then you should be able to locate the vanilla code using the project view on the left side of your IDE. I'm using Idea, and the vanilla code is located in: Libraries -> net -> minecraft
You can see it in the screenshot I've attached.
All right, I managed to get the attribute updated, and the damage is increased. However, it does not change on the tooltip. Plz halp xD
Post your code and let's see what you've got so far.
I suspect that I must modify the tooltip generator to make it update the actual damage
If you do this, you could get a Multimap from getAttributeModifiers() in the ItemArmor class and add those traits to the multimap. It should display that the player has increased health and strength from attacking.
Would probably be best to move this sort of code into the armour's onArmorTick() method. The world, player and item stack is given as parameters for this method.
Hmm modifying the tooltip just sounds like a lot of effort :/ I'm sure this will work, we just haven't got it right yet.
Gonna try this, thanks!
That might be benefitical, but I smell some issue with adding the stats together tho. Also, this has the benefit that no matter what items you are using with strength or stamina, equiped or in the action bar, it will always give damage and health. Should I still move it to onArmorTick()?
You should be able to still add the stats the same as you were, since you have the player instance.
Yeah this should work too - the onArmorTick will get called every tick for that piece of armour while it is worn, so you can apply your stat increases regardless of what the player is holding. It should be more efficient than using the tick handler as this will only get called if you're wearing the armour, whereas the tick handler method will still get called. I know it's not much, but it's there, and it just helps that tiny little bit
I think you should move it there. Just make sure you only run it once if you're wearing multiple pieces of the armour! You might want to only run the code if you're wearing a full set, which in that case you should choose one piece as the one to do all the processing (use an if statement), and it should check for the other pieces of armour being worn before running the code.
This makes very much sense, the second part seems a bit clumsy. If I understand you right, you want the stat changes to be a part of for instance the chest plates onTick, which would mean that chest plates would be a key to get stat benefits in general. I dont like that... However, part I quoted is worth considering! Thanks again man, take another +1 from me