getData?

Discussion in 'Plugin Development' started by ArthurHoeke, Mar 27, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    ArthurHoeke

    Hello
    How to check the data from hitblock?

    if (hitBlock.getType() == Material.STAINED_CLAY) {
    hitBlock.setData((byte) 4);

    I got this but this is to set, How to get the data?
     
  2. Offline

    ArthurHoeke

    Assist Yes, But how to check if it is data 4?
     
  3. Offline

    Ad237

    ArthurHoeke You should probably learn Java before continuing.
    Code:java
    1. if(hitBlock.getType().getData() == 4) {
    2. //Do stuff
    3. }
     
    MrSnare likes this.
  4. Offline

    ArthurHoeke

    Ad237 Dont works, I need to have this above,
    if (hitBlock.getType() == Material.STAINED_CLAY) {
    And than the check if it is red.
    So i did this;
    hitBlock.getType().getData() == 4);
    But dont works.
     
  5. Offline

    2MBKindiegames

    Your problem is with Bytes.
    "hitBlock.getType().getDate()" returns a Byte but "4" is an integer. You need to do the following:
    Code:
    if (hitBlock.getType.getData == (Byte) 4) {
       //Code
    }
    
     
  6. Offline

    ArthurHoeke

    2MBKindiegames Code doesn't work. Get lot of errors
    getType cannot be resolved or is not a field etc
     
  7. Offline

    2MBKindiegames

    Sorry my fault,
    Code:
    if (hitBlock.getData() == (Byte) 4) {
      //Code
    }
     
  8. Offline

    ArthurHoeke

  9. Offline

    2MBKindiegames

    Try this:
    Code:java
    1. Byte byte = (byte) 4;
    2. if (hitBlock.getData() == byte) {
    3. //Code
    4. }
     
  10. Offline

    ArthurHoeke

  11. Offline

    Wolfey

    ArthurHoeke This should work:
    Code:text
    1.  
    2. if(hitBlock.getData() == (byte) 4) {
    3.  
    4. }
     
  12. Offline

    2MBKindiegames

    ArthurHoeke If something doesn't work, check first if you can find the problem yourself!
    Code:java
    1. byte Byte = (byte) 4;
    2. if (hitBlock.getData() == Byte) {
    3. //Code
    4. }
     
  13. Offline

    ArthurHoeke

  14. Offline

    2MBKindiegames

    You're welcome!

    -If you have no more questions, please help other people and CLOSE THIS TOPIC!
     
Thread Status:
Not open for further replies.

Share This Page