Posted March 3, 201510 yr 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.
March 3, 201510 yr 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.
March 3, 201510 yr You could also just use the onItemRightClick from the wrench, which might be a better solution
March 3, 201510 yr Author 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.
March 3, 201510 yr You could also check if its != null and then check if its equals.. That way you wont get a NPE
March 3, 201510 yr 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.
March 3, 201510 yr Author 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.
March 3, 201510 yr And, how can I set player's air level (small bubbles displayed when player si in water) You can't. http://www.minecraftforge.net/forum/index.php/topic,27370.0.html http://www.minecraftforge.net/forum/index.php?topic=27608.0.html http://www.minecraftforge.net/forum/index.php?topic=14587.0.html 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.
March 3, 201510 yr Author 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.
March 3, 201510 yr Author 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.