O'Reilly logo

Minecraft™ Mod Development in 24 Hours, Sams Teach Yourself by Jimmy Koene

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Custom AI

If you have a mob, you want it to be unique. An easy way to make your mob unique is to add some custom AI for it. This can either be completely custom, which can be quite difficult, or adaptations of already existing AI. You will now see two examples of custom AI code, which can be used in quite a few situations. This should give you an insight in how to make your own AI as well as two useful AIs you could use.

Fleeing When Hurt

The following piece of AI in Listing A.17 will make a mob fly when it is hurt, which is, in this case, set to two hearts.

LISTING A.17 EntityAIFleeOnHurt

package com.wuppy.samsmod.ai;import net.minecraft.entity.EntityCreature;import net.minecraft.entity.ai.EntityAIBase;import ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required