Jump to content

[1.6] Mob Movement Speed


SeaBass

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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);
    }

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

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();
    }

Link to comment
Share on other sites

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.

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.