Posted January 31, 201411 yr 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); }
January 31, 201411 yr Since you are using the tamed flag, this.setTamed(true); you can use it to check if you already used an apple on the mob.
January 31, 201411 yr Author Since you are using the tamed flag, this.setTamed(true); you can use it to check if you already used an apple on the mob. How? Please tell me how it can be used.
February 1, 201411 yr Author Look at the EntityWolf interaction code. Well, you mean i can use setSitting? Thats an idea, thanks.
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.