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.

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

Featured Replies

Posted

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

Bumping this. I've tried to solve it a few times, but I can't find anything that works :(

Edited by bradsk88

  • 2 months later...

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

}

  • Author

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

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.