#How can I make a mob shake similarly to how a Zombie Villager shakes while being cured?

1 messages · Page 1 of 1 (latest)

lone herald
#

Maybe I could modify the mob's rotation each tick, although I'm not sure if it is the right approach since I don't want to mess with the mob's movement

pearl fiber
#

You mean each tick

rain rune
#

Ehh that's stored in NBT and likely rendered client-side

#

just rotate the villager +- 2º each tick

lone herald
rain rune
#

conversion ticks

lone herald
#

Oh yeah, but I'm talking about the shaking animation, not the conversion process

#

I'm looking to make other mobs shake

rain rune
#

Easiest way is to just use NMS a bit

#

and add a pathfinder that just shakes the mob a bit

#

not-so-easy is to just make a bukkit scheduler that rotates the entity a bit

#

With NMS, you can do something like

public class PathfinderGoalShakeEntity extends PathfinderGoal {

  private static final float ROTATION_ANGLE = 2;
  
  private final EntityInsentient entity;
  private final boolean positive = true; // 0 = shake -ang, 1 = shake ang

  public PathfinderGoalShakeEntity(EntityInsentient entity) {
    this.entity = entity;
  }

  @Override
  public boolean a() { // canStart()
    e(); // tick, let's not interrupt other pathfinders
    return false;
  }

  @Override
  public void e() { // tick()
    positive = !positive;
    float angle = (positive ? ROTATION_ANGLE : -ROTATION_ANGLE);
    
    entity.ba = angle; // bukkitYaw
  }
}