Posted May 29, 201411 yr Hello! I have another problem: my custom entity does not have attack damage attribute. It is an entity extending EntityWolf, if that causes the problem. Anyway, "this.getEntityAttribute(SharedMonstersAttributes.attackDamage)" returns null. So I decided to investigate and I ran it in debug mode. I F5-ed until I reached the base of it: the class called BaseAttributeMap. And the program was at the function "getAttributeInstance". So I hovered over the 2 variables (attributes and attributesByName) and they had many entries, but not attack damage. They had: - maxHealth - followRange - knockbackResistance - movementSpeed. Why is this happening? I'll try changing from "EntityWolf" to "EntityTameable" to see if it fixes it. Thanks in advance, Mateiaru http://i.imgur.com/LWcDco2.png[/img]
May 29, 201411 yr And ? The thing about attributes is they are optional. If you want it for your entity, register it into the entity attribute map by overriding the entity attribute initialization.
May 29, 201411 yr Author All entities are supposed to have this attribute. Also, when the dog attacks it has the default damage. http://minecraft.gamepedia.com/Attribute#Attributes_Available_on_All_Living_Entities http://i.imgur.com/LWcDco2.png[/img]
May 29, 201411 yr "Available" doesn't mean "used". The wolf damage value is hard-coded in its attack routine. public boolean attackEntityAsMob(Entity par1Entity) { int i = this.isTamed() ? 4 : 2; return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), (float)i); } See EntityLivingBase#applyEntityAttributes() for the attributes actually registered in all "living" entities. EntityLiving only adds the "follow range" attribute. Only EntityMob and EntityPlayer register the "attack damage" attribute.
May 29, 201411 yr All entities are supposed to have this attribute. Also, when the dog attacks it has the default damage. http://minecraft.gamepedia.com/Attribute#Attributes_Available_on_All_Living_Entities That wiki is wrong. I was just working on attributes for my custom entities this morning. EntityLivingBase has the following: protected void applyEntityAttributes() { this.getAttributeMap().registerAttribute(SharedMonsterAttributes.maxHealth); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.knockbackResistance); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.movementSpeed); if (!this.isAIEnabled()) { this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.10000000149011612D); } } And then EntityLiving (which extends EntityLivingBase) has following: protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getAttributeMap().registerAttribute(SharedMonsterAttributes.followRange).setBaseValue(16.0D); } In my custom entities, like GoToLink says, I had to register the additional attack damage attribute and then set it. Note that the full list of built-in attributes available to register are (from ShareMonsterAttributes class): public static final IAttribute [b]maxHealth [/b] = (new RangedAttribute("generic.maxHealth", 20.0D, 0.0D, Double.MAX_VALUE)).setDescription("Max Health").setShouldWatch(true); public static final IAttribute [b]followRange [/b] = (new RangedAttribute("generic.followRange", 32.0D, 0.0D, 2048.0D)).setDescription("Follow Range"); public static final IAttribute [b]knockbackResistance [/b] = (new RangedAttribute("generic.knockbackResistance", 0.0D, 0.0D, 1.0D)).setDescription("Knockback Resistance"); public static final IAttribute [b]movementSpeed [/b] = (new RangedAttribute("generic.movementSpeed", 0.699999988079071D, 0.0D, Double.MAX_VALUE)).setDescription("Movement Speed").setShouldWatch(true); public static final IAttribute [b]attackDamage [/b] = new RangedAttribute("generic.attackDamage", 2.0D, 0.0D, Double.MAX_VALUE); Check out my tutorials here: http://jabelarminecraft.blogspot.com/
May 31, 201411 yr Author Ok, so I register the attack damage on my entity and change the attack function to use the attribute. I'm testing it right now. http://i.imgur.com/LWcDco2.png[/img]
May 31, 201411 yr Author Ok, it is working Changing status to solved http://i.imgur.com/LWcDco2.png[/img]
May 31, 201411 yr By the way, to help others that might come to this thread, I created a tutorial on the topic: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-applying-entity.html Check out my tutorials here: http://jabelarminecraft.blogspot.com/
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.