Jump to content

Recommended Posts

Posted

Hello everybody. I have a little problem in a modding. So basiclly, i've made my mob follow me if i push right click on him with redApple. So it works fine, but i want to change a code a littlebit. I want my mob to stop if i rightclick with apple on him again. So if i rightclick with apple on mob once, he will follow me, if i rightclick another time he will stop. How can i do that? Here is the code:

 

public boolean interact(EntityPlayer par1EntityPlayer)
    {
    	ItemStack itemstack = par1EntityPlayer.inventory.getCurrentItem();
    
    	if (itemstack == null)
        {
       
    	this.playSound("scientist.sci_busy", 0.5F, 1.0F);
        }
        
    	else if (itemstack.itemID == Item.appleRed.itemID)
    	{
    		this.playSound("scientist.sci_follow", 0.5F, 1.0F);
    		this.setTamed(true);
            this.setEntityHealth(20);
            this.setOwner(par1EntityPlayer.username);
            this.worldObj.setEntityState(this, (byte)7);
            this.tasks.addTask(7, new EntityAIFollowCalled(this, this.moveSpeed, 3.0F, 0.3F));
            this.moveSpeed = 0.3F;
     }
    	
     return super.interact(par1EntityPlayer);
    }

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.