Jump to content

Recommended Posts

Posted

Well, I know there's some function called "hitEntity" which has 3 parameters: ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving.

1st one is the ItemStack that is being leftclicked, 2nd one is the entity that gets hit and the 3rd one is the entity that does all this.

 

Now my question is: is there some function that has the same parameters but is being used for rightclicking?

 

 

Greetings.

Posted

From what you have said, i believe you are trying to make something happen when an entity is right-clicked with a certain item. I don't think there is a specific function for doing this, but try putting this in the target entity's code:

 

public boolean interact(EntityPlayer par1)
{
	if(par1.getCurrentEquippedItem().getItem().shiftedIndex == <your item>.shiftedIndex)
	{

	<your code here>

	return true;
	}
	else
	{
	return false;
	}

 

Basically, this is called when you right-click an entity. Then, it compares the players currently equipped item to the one you want them to use. if they are holding that item, it executes your code, otherwise it does nothing.

 

hope this helped :D

Posted

Put this in your item code, you don't need to edit anything with the entity, just put this in the code for your item

public boolean itemInteractionForEntity(ItemStack itemstack, EntityLiving entity)
    { 
	if (entity.worldObj.isRemote)
	{
		return false;
	}

                //stuff to do on right click

	return true;
    }

 

that's all you need to do.

Hope I helped

 

[EDIT]

the entity is the entity being clicked, not the clicker.

 

[EDIT #2]

if you want to change stuff about the entity with this, look in the code for the sheers.

Posted

Not sure what you mean? there is the EntityLiving, which is the thing being clicked, if you want something to happen when this is clicked on a player simply cast this as EntityPlayer. If you want the entity holding it then i'm not sure, may post an edit if i figure out how to do this.

 

P.S. sorry for the late post, I've not been able to get to my computer due to school work

Posted

Hello all! I'm actually wanting to do this exact thing. I'd like to make chickens pluckable using the shears. :)

 

I'm completely new to Minecraft modding, but I've done a fair amount of C/C++ programming in the past and have a general concept of how programming works. But with regards to Minecraft and modding I'm pretty much at square one. I've downloaded the Java JDK, Forge setup, and a copy of Eclipse. And I've finished that first tutorial about setting up a base mod.

 

If I understand correctly, the idea here is that I have to write a class that replaces the default functionality in Minecraft. One of the replies here suggests changing the item, Shears, and one suggests the mob, Chicken. Either way, I'm still a bit confused. I assume my code goes under Init, but how do I write it so it's modifying the existing class? What is the syntax/layout?

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.