Jump to content

[SOLVED] Mob with HumanoidMobRenderer - how to render attack arm swing? [1.18.2]


Recommended Posts

Posted (edited)

I have a mob that uses the HumanoidMobRenderer. It is meant to look like another player.

public class VisitorMobRenderer extends HumanoidMobRenderer<VisitorMobEntity, PlayerModel<VisitorMobEntity>> {

I have basically no custom rendering code. Just some logic for loading custom skins.

https://github.com/bradsk88/Questown/blob/0d913c9bf06bb6b2de981717d2a38e182d9669ca/src/main/java/ca/bradj/questown/mobs/visitor/VisitorMobRenderer.java#L14

I've tried to call the "swing" method from the server side, which should publish a message to the client side. But I'm not seeing any animation.

((LivingEntity)mcExtra.entity()).swing(InteractionHand.MAIN_HAND);

https://github.com/bradsk88/Questown/blob/0770d0d161a92d69f0749832552671b781360a64/src/main/java/ca/bradj/questown/jobs/declarative/RealtimeWorldInteraction.java#L284

 

Any suggestions to get my mob's arm swinging?

Edited by bradsk88
  • 6 months later...
  • 2 months later...
Posted

I managed to do it by overriding the "doHurtTarget" method.

@Override

public boolean doHurtTarget(Entity target) {

    this.swing(InteractionHand.MAIN_HAND);

    return super.doHurtTarget(target);

}

Posted (edited)

Finally solved this after looking a bit closer at the `Monster` class.

I needed to override the `aiStep` method, adding a call to `updateSwingTime`. This makes `entity.swing()` trigger an animation.



    @Override
    public void aiStep() {
        this.updateSwingTime();
        super.aiStep();
    }

 

Edited by bradsk88
  • bradsk88 changed the title to [SOLVED] Mob with HumanoidMobRenderer - how to render attack arm swing? [1.18.2]

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.