Updating a sign on left click:

Discussion in 'Plugin Development' started by Empire92, May 25, 2014.

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

    Empire92

    The problem I am having is that updating a sign on left click causes an "Unable to locate sign" message (which is client side) if the block is broken.

    Even if the block is protected and is instantly replaced, the client still creates the unable to locate sign message.

    I am trying to figure out how to tell if the PlayerInteractEvent leads to a BlockBreakEvent (which is called after the InteractEvent).

    Code:
    @EventHandler(ignoreCancelled=true,priority=EventPriority.MONITOR)
        private void onPlayerInteract(final PlayerInteractEvent event)
        { 
            if (event.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
           Block block = event.getClickedBlock();
           if (block!=null) {
           BlockState state = block.getState();
           if (state instanceof Sign) {
           player.sendSignChange(...)
           }
           }
            }
        }
    
    Thanks.
     
  2. Offline

    mine-care

    Mabe if you check if item that interacted is sign and then
    Sign s = (sign) e.getclickedblock();
    s.update // not sure if that's the method
     
  3. Offline

    Empire92

    mine-care
    I'm already doing that in the example code I posted.
     
  4. Offline

    nlthijs48

    Empire92 What are you trying to do? If you just call .update() on a sign nothing will change, you have to change some line of it first. When you say what you want to do I can try to provide a solution.
     
  5. Offline

    PreFiXAUT

    Did you read the first entry? He said he wanted to solve the Bug when a Player is breaking the Sign but still cancels it with the BlockBreakEvent, it will still be sended to the Player/Client. Thats the issue he has.
     
  6. Offline

    xize

    Empire92

    Unable to locate sign could mean 2 things.

    1. the chunk is not loaded

    2. the sign really doesn't exist.

    this message comes from the client btw ;-)

    since sendSignChange is actually the same as sendBlockChange its special for signs to manipulate text client sided on that sign rather than for everyone.

    so my question is was this intended or did you actually wanted to be changed for everyone?
     
  7. Offline

    Empire92

    xize
    I know how player.sendSignChange(Location loc, String[] lines) works.
    It doesn't seem like you understood my post.

    Apart from that, you may have given me an idea. If I accompany the player.sendSignChange(loc, lines) with a sendBlockChange(...) beforehand, it may force the client to see the sign before the sign text update so that it doesn't lead to the "Unable to locate sign at X Y Z" message.

    I'll test this out...
     
Thread Status:
Not open for further replies.

Share This Page