Posted July 6, 201312 yr A mob that worked fine in 1.5.2 is now moving extremely slow and I can't seem to figure out why. I trimmed my code down to only the very basics, and the mob works in game, but still moves extremely slow. public class Gobbo extends EntityMob { public Gobbo(World par1World) { super(par1World); this.setSize(1.0F, 2.0F); }} I found this part in EntitySpider that appears to set the movement speed: protected void func_110147_ax() { super.func_110147_ax(); this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(16.0D); this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.800000011920929D); } Here's that field in ShareMonsterAttributes: public static final Attribute field_111263_d = (new RangedAttribute("generic.movementSpeed", 0.699999988079071D, 0.0D, Double.MAX_VALUE)).func_111117_a("Movement Speed").func_111112_a(true); But setting it the same way it's done in EntitySpider doesn't seem to do anything.
July 7, 201312 yr Author Still trying to figure this out, 1.6.1 seems to have changed how movement speed is set.
July 7, 201312 yr I'm having the same issue. Increasing the value makes the mobs a little less glacially slow, but nowhere near normal speed. http://www.millenaire.org/img/dynamicsig.png[/img]
July 7, 201312 yr Author Okay, I think I understand how attributes work a little better. Looks like they're set when the mob is first spawned, and unique to each instance of that mob. Changing the code for the mob will not affect the attributes of the mobs already spawned, which means the way I've been testing the changes to my code has been completely flawed. Gonna try again to see if I can get it to work.
July 7, 201312 yr Author Okay, looks like I was correct originally, I just never bothered to spawn new mobs so they'd get the new attributes. You can use the following function to set move speed, damage, health, etc. in the mobs entity class: protected void func_110147_ax() { super.func_110147_ax(); // Max Health - default 20.0D - min 0.0D - max Double.MAX_VALUE this.func_110148_a(SharedMonsterAttributes.field_111267_a).func_111128_a(20.0D); // Follow Range - default 32.0D - min 0.0D - max 2048.0D this.func_110148_a(SharedMonsterAttributes.field_111265_b).func_111128_a(32.0D); // Knockback Resistance - default 0.0D - min 0.0D - max 1.0D this.func_110148_a(SharedMonsterAttributes.field_111266_c).func_111128_a(0.0D); // Movement Speed - default 0.699D - min 0.0D - max Double.MAX_VALUE this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.699D); // Attack Damage - default 2.0D - min 0.0D - max Doubt.MAX_VALUE this.func_110148_a(SharedMonsterAttributes.field_111264_e).func_111128_a(2.0D); }
July 7, 201312 yr You're right, and I was making the same mistake, testing on existing entities. Did you find a way to set it for existing entities though? At least for 1.5 worlds it will be needed. And so far at least I don't really get the point of the new system. If it was just to enable horses with custom attributes there were more straightforward ways of implementing it... http://www.millenaire.org/img/dynamicsig.png[/img]
July 7, 201312 yr Author Looks like you have to go in and edit the NBT data to update existing entities, but exactly how you'd go about doing that I'm not sure. I'm currently using NBTExplorer to check out the structure and I see where the attributes are stored, but I'm not sure how to change them with a mod. I did find this mod, which seems to have all the NBT editing figured out: http://www.minecraftforum.net/topic/1558668-161forgesspsmp-in-game-nbtedit-edit-mob-spawners-attributes-in-game/
July 7, 201312 yr Author On second thought, I'm making things way more difficult than they need to be, just put something like this in the entity's class to update the speed of existing ones: @Override public void onLivingUpdate() { // // Movement Speed - default 0.699D - min 0.0D - max Double.MAX_VALUE this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(0.699D); super.onLivingUpdate(); }
July 9, 201312 yr I solved it that way too, though I put the call in the constructor to avoid doing every tick. Weird system though. http://www.millenaire.org/img/dynamicsig.png[/img]
July 9, 201312 yr Yep. That worked. Odd thing is, it appears to be the ONLY way to get things to move. Somehow, all my entities reset their move speed, so: /** * Called to update the entity's position/logic. */ public void onUpdate() { this.func_110148_a(SharedMonsterAttributes.field_111263_d).func_111128_a(this.moveSpeed); //Movespeed super.onUpdate(); } Is required! Odds are good I've been programming since before you were born. Yeah. I'm OLD school.
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.