CraftBlockState cannot be cast to a Sign

Discussion in 'Plugin Development' started by nicholasntp, Dec 9, 2011.

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

    nicholasntp

    Heres my code:
    Code:java
    1. Sign sign = (Sign) block.getState();

    Heres my error:
    Code:
    Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.block.CraftBlockState cannot be cast to org.bukkit.block.Sign
    
    This is right. Why is it doing this?
     
  2. Offline

    nisovin

    Are you sure that block is actually a sign?
     
  3. Offline

    nicholasntp

    Yeah, does it matter if it is a sign post?
     
  4. Offline

    nicholasntp

    so it won't work if it is a sign post? Then how do i do it?
     
  5. Offline

    nisovin

    It can be a sign post. But the block you're trying to check isn't one.
     
  6. Offline

    nicholasntp

    Alright. Ill check my coding once more. Does it matter if it doesn't get the x, y, or z decimals?
     
  7. Offline

    Timberjaw

    @nicholasntp you can check the BlockState via:
    Code:
    if(theBlockState instanceof Sign)
    If that returns false, the block isn't a sign. And yes, double check your XYZ coordinates.
     
    nicholasntp likes this.
  8. Offline

    nicholasntp

    Great. Thats perfect. Thank you so much @Timberjaw
     
Thread Status:
Not open for further replies.

Share This Page