Jump to content

Recommended Posts

Posted

I have a block that is called Password Lock.

I am currently adding a wrench, that when used on this block, it dismantles it(sets it to air and drops it).

But I don't know how to get Item, that is currently held by player. I will use it at onBlockActivated when It is held (and the current player is it's owner), don't open the gui, but dismantle.

When I used player.inventory.getCurrentItem().equals(ItemWrench.item) it always returned false.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

ItemStack will never equal Item.

 

Also, as soon as the player's hand is empty and that code runs, the game will crash with a Null Pointer Exception.

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.

Posted

Sorry, I made a mistake in first post. It was player.inventory.getCurrentItem().equals(new ItemStack(ItemWrench.item)).

But I solved it another way.

I converted them from ItemStack to Item.

 

Item currentItem = player.inventory.getCurrentItem().getItem();
boolean hasWrench = currentItem.equals(ItemWrench.item)

 

And, I have a tile entity for this block. I want to get owner(that is set when is block placed) and compare it with player, who is trying to dismantle the block.

I used:

TileEntityPasswordLock tile = (TileEntityPasswordLock)world.getTileEntity(bX, bY, bZ);

	String playerName = new String(player.getCommandSenderName());
	String owner = tile.owner;
	boolean isOwner = owner == playerName;

And it always returned false.

 

When I used .equal(something) insteaded of == it throws an error.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

Called it.

 

the game will crash with a Null Pointer Exception.

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.

Posted

And, how can I set player's air level (small bubbles displayed when player si in water)

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

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.

Posted

Ok. All problems solved.

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

Posted

And, simple question about forums.

Must I delete my topic when it was solved or I can simply leave it for other users?

Sorry, if you find mistaches in my posts.

I am not EN.

And when I post anything on Modder support, it means, I can't help myself and I need your help. And when you decide to delete my topic, just PM me with the reason, please.

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.