Jump to content

[1.6.4]Making a mob not take fall damage?


T3ctonic

Recommended Posts

Well the title basically says it all

 

 

Entity Class

 

 

package Eclipse7.MysticEnergies.mobs.entity;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.item.Item;

import net.minecraft.world.World;

import Eclipse7.MysticEnergies.common.MysticEnergies;

 

public class EntityDarkEnergyGolem extends EntityMob{

 

public EntityDarkEnergyGolem(World par1World) {

super(par1World);

this.setHealth(this.getHealth());

        this.isImmuneToFire = true;

   

}

protected void applyEntityAttributes()

    {

        super.applyEntityAttributes();

        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(250.0D);

        this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(100.0D);

        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setAttribute(5.0D);

        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.2D);

        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(5.0D);

       

}

public int getAttackStength(Entity par1Entity) {

return 5;

}

public boolean getCanSpawnHere() {

return this.worldObj.difficultySetting > 0 && this.isValidLightLevel() && super.getCanSpawnHere();

}

protected String getLivingSound() {

return "none";

}

protected String getHurtSound() {

return "mob.irongolem.hit";

}

protected String getDeathSound() {

return "mob.irongolem.death";

}

protected void dropRareDrop(int par1)

    {

        switch (this.rand.nextInt(3))

        {

            case 0:

                this.dropItem(MysticEnergies.DarkEnergy.itemID, 1);

                break;

   

        }

        {

       

        }

    }

}

 

 

Link to comment
Share on other sites

Use LivingFallEvent.

Check if the event that gets hurt is "your entity" or "the entity you want" that takes fall damage.

 

Change the "distance" to 0.

 

Example:

@SubscribeEvent
public void livingFall(LivingFallEvent event)
{
    if (event.entityLiving instanceof EntityPlayer)
    EntityPlayer player = (EntityPlayer) event.entityLiving;
    event.distance = 0F;
}

Link to comment
Share on other sites

Well I assume what I have done is wrong if you could try and correct me using my code it would be appreciated or just point out where I went wrong thanks :)

P.S its 2 AM for me :P

 

 

 

package Eclipse7.MysticEnergies.mobs.entity;

 

import net.minecraft.entity.Entity;

import net.minecraft.entity.SharedMonsterAttributes;

import net.minecraft.entity.monster.EntityMob;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.world.World;

import net.minecraftforge.event.entity.living.LivingFallEvent;

import Eclipse7.MysticEnergies.common.MysticEnergies;

 

public class EntityDarkEnergyGolem extends EntityMob{

 

public EntityDarkEnergyGolem(World par1World) {

super(par1World);

this.setHealth(this.getHealth());

        this.isImmuneToFire = true;

       

        @SubscribeEvent

        public void livingFall(LivingFallEvent event)

        {

            if (event.entityLiving instanceof EntityDarkEnergyGolem)

            EntityMob entityToAttack = (EntityMob) event.entityLiving;

            event.distance = 0F;

        }

}

protected void applyEntityAttributes()

    {

        super.applyEntityAttributes();

        this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(250.0D);

        this.getEntityAttribute(SharedMonsterAttributes.followRange).setAttribute(100.0D);

        this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setAttribute(5.0D);

        this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.2D);

        this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(5.0D);

       

}

public int getAttackStength(Entity par1Entity) {

return 5;

}

public boolean getCanSpawnHere() {

return this.worldObj.difficultySetting > 0 && this.isValidLightLevel() && super.getCanSpawnHere();

}

protected String getLivingSound() {

return "none";

}

protected String getHurtSound() {

return "mob.irongolem.hit";

}

protected String getDeathSound() {

return "mob.irongolem.death";

}

protected void dropRareDrop(int par1)

    {

        switch (this.rand.nextInt(3))

        {

            case 0:

                this.dropItem(MysticEnergies.DarkEnergy.itemID, 1);

                break;

               

        }

    }

}

 

 

Link to comment
Share on other sites

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.