Jump to content

How intercept the convertToVillager method


sidben

Recommended Posts

Hello, I'm working on a mod to add small tweaks to the game, one of those would be to give a villager a special trade when he is cured from being a zombie.

 

I figured out that the best place for my code would be inside the "EntityZombie.convertToVillager()" method, but I did not find any hooks for it.

 

    protected void convertToVillager()
    {
        EntityVillager entityvillager = new EntityVillager(this.worldObj);
        entityvillager.copyLocationAndAnglesFrom(this);
        entityvillager.func_110161_a((EntityLivingData)null);
        entityvillager.func_82187_q();

        if (this.isChild())
        {
            entityvillager.setGrowingAge(-24000);
        }

        // HERE IS WHERE I WOULD LIKE MY CODE

        this.worldObj.removeEntity(this);
        this.worldObj.spawnEntityInWorld(entityvillager);
        entityvillager.addPotionEffect(new PotionEffect(Potion.confusion.id, 200, 0));
        this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1017, (int)this.posX, (int)this.posY, (int)this.posZ, 0);
    }

 

 

Does anyone know of a hook I could use?

 

Thanks

Link to comment
Share on other sites

Thanks, I forked the repo, I'll look into how I can do that.

 

I think I could achieve what I want tracking "EntityJoinWorldEvent" and "onLivingDeath" or "onUpdate", but it would be a half-assed way for what I want  ;D

 

I'll see if I can crate a "EntityTransform(Entity old, Entity new)" hook, it could be used for other transformations like Pig -> Zombie Pigman.

Link to comment
Share on other sites

checking that EVERY tick would be overkill

 

kinda like always looking at the windows in case there's someone coming instead of waiting til you hear the door knock

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

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.