Jump to content

Recommended Posts

Posted

Hello all! :D

 

Before updating, I had my mob call an event when its health reached a certain point. However, "this.gethealth();" and "this.getMaxhealth();" are no longer useable. My question is, how do I recreate this functionality in 1.6.2? Here is my entity class, and thank you in advance! :D

 

EntityRiot_Zombie:

http://pastebin.com/4K69nMyL

 

Thanks to everyone who helps, and sorry if this is a bit noobish. :P

 

--Tenyar97

Posted

I haven't looked at your block yet, but I believe these are the functions you want for your mob.

 

func_110143_aJ()  should replace gethealth()

func_110138_aP() should be getMaxhealth()

 

EDIT:

Fixed your block,

the dispenser face uses the block icon name, there is two places to easily fix this.

 

when you set up your block make sure you have .func_111022_d("dispenser")

example:

dispenser = (new Dispenser(2000)).setHardness(3.5F).setStepSound(soundStoneFootstep).setUnlocalizedName("dispenser").func_111022_d("dispenser");

 

or add it here:

 

protected Dispenser(int par1)

{

    super(par1);

    func_111022_d("dispenser");

    this.setCreativeTab(null);

}

 

Posted

Thank you! My dispenser works properly now.  ;D

 

However, the functions you gave me don't seem to be doing anything. :( Below is my new code

 

public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
    {
        if (par1DamageSource.isFireDamage())
        {
            par2 = 0;
        }

        if (super.attackEntityFrom(par1DamageSource, par2))
        {
            if (par1DamageSource.getEntity() != null)
            {
                Entity par1Entity = par1DamageSource.getEntity();
                int j = 0;
                if (par1Entity instanceof EntityLiving)
                {
                    j += EnchantmentHelper.getKnockbackModifier((EntityLiving) par1Entity, this);

                    if (j > 0)
                    {
                        this.motionX /= 0.6D;
                        this.motionZ /= 0.6D;
                        this.addVelocity((double) (MathHelper.sin(par1Entity.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F), -0.1D,
                                (double) (-MathHelper.cos(par1Entity.rotationYaw * (float) Math.PI / 180.0F) * (float) j * 0.5F));
                    }
                }

            }
    
    if (this.func_110143_aJ() < this.func_110138_aP() * 0.75)
    {
        stage++;
        System.out.println("Stage advanced!");
    } else if (stage == 1 && this.func_110143_aJ() < this.func_110138_aP() * 0.5)
    {
    	stage++;
        System.out.println("Stage advanced, again!");
    } else if (stage == 2 && this.func_110143_aJ() < this.func_110138_aP() * 0.25)
    {
        stage++;
    }
    return true;
}

return false;
}

 

I have a feeling that it is my fault, and the health values are messed up, because I'm not familiar with this new system, but before I get myself anymore confused, I'm asking. :P

 

Thanks! :D

 

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.