1.17.x Read sign lines on a Chest

Discussion in 'Spigot Plugin Development' started by TheFischPlayz, Jun 18, 2021.

Thread Status:
Not open for further replies.
  1. Hey everybody

    I try to code a simple chest lock plugin with a Sign.
    but how can i let the chest read the sign?
    Because something like e.getClickedBlock doesn't work because clicked block is the chest not the sign..

    Code and error message here: https://hastebin.com/utugukokin.properties

    Thanks for help :)
     
  2. SteelPhoenix

    Moderator

    so just check for and get the sign attached to the block?
     
  3. It do a check if there is a sign on chest but how can i get the lines from the sign on chest i searched but doesnt find anything helpful
     
  4. In your code, you're getting the state of the block that's clicked(the chest), not the sign you just checked for(in a questionable manner, I might add). Hence why you're getting the error that you can't cast a chest to a sign.
     
  5. Okay.. yea its a "questionable manner" because i dont know how i should get all the wall signs in a simple code because there are many other than oak signs

    And how can i get the state of the sign ?
     
  6. The same way you already doing it, except with the correct block.
     
  7. PlayerInteractEvent.getBlock() ?
     
  8. p.s.
    Code (Java):
                    if (block.getRelative(BlockFace.valueOf(faces[i])).getType().toString().toLowerCase().contains("sign")) {
    This is dum af
    Code (Java):
                    if (block.getRelative(BlockFace.valueOf(faces[i])).getState() instanceof Sign) {
     
  9. ?
     
  10. Thanks, one problem less :)
     
  11. I think it´s nice of you to help him improve his code but you could be a little more polite while doing so
     
  12. Omg.. thanks now i get it

    Thanks to all :)
     
Thread Status:
Not open for further replies.