Jump to content

[1.7.10][SOLVED]Block Right Click


Wyverndoes

Recommended Posts

So, after deep search into minecraft files I've come up with this :

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int X, float Y, float Z, float f){
	ItemStack itemstack = entityplayer.getCurrentEquippedItem();

			if(entityplayer.inventory.currentItem == 369){


			EntityItem entityitem = new EntityItem(world, x, y, z, new ItemStack(Items.blaze_powder, 4));
			entityitem.delayBeforeCanPickup = 10;
			world.spawnEntityInWorld(entityitem);
}
		return true;
}

but it doesn't work

i want to make so that on right click (with specific item) block drops other item...

i changed inside 'if' statement

if(entityplayer.inventory.hasItem(Items.blaze_rod)){

and it drops blaze powder, as expected, but you can get it from any inventory slot (you must have blaze rod in inventory somewhere) and it spawns two entities(one of them isn't pickable)

also doesn't consumes blaze rod...I don't want to use consumeinventoryitem method because of other items...

 

Any ideas?

Thing I love most in this forum, is that when you ask for help, moderators don't give you ready code, you have to figure it out yourself.

Link to comment
Share on other sites

To remove the ghost item, only spawn the EntityItem only on the server (

!world.isRemote

).

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

				ItemStack itemstack = entityplayer.getCurrentEquippedItem();

			if(entityplayer.inventory.currentItem == 369){

 

So you're getting the current item stack....

 

And then doing nothing with it....

 

And instead, checking the current item versus an ID....

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

figured it out...

Now I just need (!world.isremote) and I'll make so it consumes an item  :D;D;) ~solved~

 

 

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int X, float Y, float Z, float f)
{
	if (entityplayer.getCurrentEquippedItem() != null && entityplayer.getCurrentEquippedItem().getItem() == Items.blaze_rod)
			{
					EntityItem entityitem = new EntityItem(world, x, y, z, new ItemStack(Items.blaze_powder, 4));
						entityitem.delayBeforeCanPickup = 5;
						world.spawnEntityInWorld(entityitem);

			}
			return true;
}

Thing I love most in this forum, is that when you ask for help, moderators don't give you ready code, you have to figure it out yourself.

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.