Jump to content

[1.7.10] Check If Birch Is In Hand?


Bugzoo

Recommended Posts

hand.getItemDamage() == 1

 

?

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

Describe how it doesn't work.  What seems to be the issue?

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

Describe how it doesn't work.  What seems to be the issue?

 

I just noticed something. That line of code does work. So if I did

 

 if(hand.getItemDamage() == 0)

 

The if statement would run, only if the block is Spruce or Dark Oak. Though if I do this

 

 if(hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 0)

 

It runs no-matter what log it is.

Link to comment
Share on other sites

Just above that if statement, put this:

 

System.out.println("Right clicked with: " + hand.getItem() + ":" + hand.getItemDamage());
System.out.println(hand.getItem() == Item.getItemFromBlock(Blocks.log));
System.out.println(hand.getItemDamage() == 0);
System.out.println((hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 0));

 

Then tell me what it prints out when you use various blocks.

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

For the love of god, why not just simply use java correctly?

 

if(entityplayer.getCurrentEquippedItem() != null && (entityplayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.log) && entityplayer.getCurrentEquippedItem().getItemDamage() == 2))

 

Bugzoo i see you are new to this so i just give you a simple advice. Use the vanilla src!

 

Link to comment
Share on other sites

Just above that if statement, put this:

 

System.out.println("Right clicked with: " + hand.getItem() + ":" + hand.getItemDamage());
System.out.println(hand.getItem() == Item.getItemFromBlock(Blocks.log));
System.out.println(hand.getItemDamage() == 0);
System.out.println((hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 0));

 

Then tell me what it prints out when you use various blocks.

 

When I right click with oak it prints this

 

[com.bugzoo.GranterMod.BlockGranter:onBlockActivated:50]: Right clicked with: net.minecraft.item.ItemMultiTexture@1c29de2:0
true
true
true

 

When I right click with any other type of log it prints out this

 

[com.bugzoo.GranterMod.BlockGranter:onBlockActivated:50]: Right clicked with: net.minecraft.item.ItemMultiTexture@1c29de2:3
true
false
false

 

 

Link to comment
Share on other sites

Ok, now make your code look like this:

 

System.out.println("Right clicked with: " + hand.getItem() + ":" + hand.getItemDamage());
System.out.println(hand.getItem() == Item.getItemFromBlock(Blocks.log));
System.out.println(hand.getItemDamage() == 0);
System.out.println((hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 0));
if(hand.getItem() == Item.getItemFromBlock(Blocks.log) && hand.getItemDamage() == 0) {
    System.out.println("Right clicked with the right block!");//this is the only new line

 

And give me the output again.

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

For the love of god, why not just simply use java correctly?

 

if(entityplayer.getCurrentEquippedItem() != null && (entityplayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.log) && entityplayer.getCurrentEquippedItem().getItemDamage() == 2))

 

Bugzoo i see you are new to this so i just give you a simple advice. Use the vanilla src!

 

OMFG! I just realized I was running another if statement somewhere in the method which checked if the block was a log, and if it was it ran some code. That was the problem. But, on a sidenote, i'm not new to this. I have been programming in java for 4 years, programming minecraft mods for 2 years. Published 3 mods. So, i'm not really new to this.

Link to comment
Share on other sites

And now you know why we use trace statements.  They tell you what the program is doing as it does it, and lets you locate the problem area of code rather than BLINDLY GUESSING.

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

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.