Best Way to Change Mob Behavior?

Discussion in 'Plugin Development' started by loganwm, Jul 28, 2011.

Thread Status:
Not open for further replies.
  1. Offline

    loganwm

    I'm currently working out the logistics for the mob customization for my mod (ApocalypseCraft), and I'm running through different possible methodologies for adapting mob behavior. I've seen systems where mobs with alternate characteristics are tacked by a code module which with the help of some listeners dictates what happens next in the mob's behavior chain.

    I'm curious though about what the most "proper" way to go about altering a mob's behavior is, however. Hypothetically, if I wanted to write a non-hostile flaming (albeit fire-proof) creeper that follows the player and doesn't explode, then what would be the best approach to do this? I'm in no way expecting anyone to write the code for me since I'm more than capable of doing so myself, but I'm at a loss for deciphering the most appropriate (non-fragile) way of customizing mob behavior in Bukkit.
     
  2. You can do setTarget(LivingEntity) for the creeper to have him follow the player.
    However, since it's an hostile mob, it will just attack him and try to explode - and not run around like a wolf. There is not really an easy way to alter that.
    To stop the creeper from exploding, just cancel the EntityExplode- or ExplosionPrime- event (not sure which one is the way to go).

    For setting it on fire: Use creeper.setFireTicks(creeper.getMaxFireTicks()) and cancel the EntityDamage-event if it matches (FIRE_TICK, FIRE or LAVA as the cause). To have it burn infinitely, I would call setFireTicks when you cancel the event. Thus you don't have to create an own scheduled task only for that.
     
Thread Status:
Not open for further replies.

Share This Page