MC Modding
Please register and join the community!


Join the forum, it's quick and easy

MC Modding
Please register and join the community!
MC Modding
Would you like to react to this message? Create an account in a few clicks or log in to continue.

[Answered/Solved] Making custom mobs fly

3 posters

Go down

[Answered/Solved] Making custom mobs fly Empty [Answered/Solved] Making custom mobs fly

Post by Ranga179 Sun Oct 23, 2011 10:36 am

a lot of people (including me) do not know the code to throw in the entity file to make a mob be a flying mob Razz therefore it will be really useful Razz


Last edited by Ranga179 on Sat Nov 26, 2011 7:56 am; edited 1 time in total

Ranga179
Member

Posts : 9
Join date : 2011-10-19
Age : 28

Back to top Go down

[Answered/Solved] Making custom mobs fly Empty Re: [Answered/Solved] Making custom mobs fly

Post by megahostile123 Mon Nov 07, 2011 9:24 pm

yes someone plz help him (and me)

megahostile123
Member

Posts : 4
Join date : 2011-11-06

Back to top Go down

[Answered/Solved] Making custom mobs fly Empty Re: [Answered/Solved] Making custom mobs fly

Post by ikke009 Mon Nov 07, 2011 9:48 pm

and me
ikke009
ikke009
Member

Posts : 65
Join date : 2011-10-24
Age : 30
Location : The netherlands

Back to top Go down

[Answered/Solved] Making custom mobs fly Empty Re: [Answered/Solved] Making custom mobs fly

Post by Ranga179 Sat Nov 26, 2011 7:55 am

i have figured it out, i don't know how to explain too well, i just had a look at the code from another mod and searched for the correct part but anyways: here is my full files code:
Spoiler:

and the part the makes it fly and do damage when you are close is this bit:

Code:
        public void onLivingUpdate()
        {
            super.onLivingUpdate();
            groundDistance = distanceToGround();
            if(isEntityAlive())
            {
                if(!flying)
                {
                    if(groundDistance > 5)
                    {
                        motionY = -0.01D;
                    }
                    flyTime = rand.nextInt(100) + 100;
                    if(posY < 110D && entityToAttack == null)
                    {
                        motionY = 0.02D;
                    }
                } else
                {
                    flyTime--;
                    motionY = 0.02D;
                    if(posY > 128D)
                    {
                        flying = false;
                    }
                    if(flyTime <= 0)
                    {
                        flying = false;
                    }
                }
                if(rand.nextInt(30) == 0)
                {
                    flying = true;
                }
                if(groundDistance < 5)
                {
                    motionY = 0.20000000000000001D;
                }
                moveEntityWithHeading(moveSpeed, moveSpeed);
            }
            if(entityToAttack != null)
            {
                motionY = -0.01D;
                flying = false;
                if(groundDistance < 2)
                {
                    motionY = 0.001D;
                }
            }
        }

        protected void attackEntity(Entity entity, float f)
        {
            if(f < 4F && rand.nextInt(20) == 0)
            {
                entity.attackEntityFrom(DamageSource.causeMobDamage(this), 6);
                entity.motionY = 0.080000000000000002D;
            }
        }

        protected void fall(float f)
        {
        }

        public int distanceToGround()
        {
            int i = (int)posX;
            int j = (int)posY;
            int k = (int)posZ;
            int l = 0;
            for(int i1 = 0; i1 <= 20; i1++)
            {
                if(worldObj.isAirBlock(i, j - 1, k))
                {
                    l++;
                    j--;
                }
            }

            return l;
        }

        public int groundDistance;
        public int flyTime;
        public boolean flying;

you guys should be able to figureout what the rest does. and if you use this code you will need to change some names of course Razz

Ranga179
Member

Posts : 9
Join date : 2011-10-19
Age : 28

Back to top Go down

[Answered/Solved] Making custom mobs fly Empty Re: [Answered/Solved] Making custom mobs fly

Post by Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum