Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • Author

Still trying to figure this out, 1.6.1 seems to have changed how movement speed is set.

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

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

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

  • 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/

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

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.

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.