Issues Setting Sign Text and Direction

Discussion in 'Plugin Development' started by hskrasek, Mar 5, 2012.

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

    hskrasek

    When I try to change a block to a sign, set the text, and change its facing, I get this error followed by a server crash:

    Code:
    20:05:15 [SEVERE] java.lang.NullPointerException
    20:05:15 [SEVERE]    at net.minecraft.server.TileEntitySign.d(TileEntitySign.java:38)
    20:05:15 [SEVERE]    at net.minecraft.server.PlayerInstance.sendTileEntity(PlayerInstance.java:150)
    20:05:15 [SEVERE]    at net.minecraft.server.PlayerInstance.a(PlayerInstance.java:109)
    20:05:15 [SEVERE]    at net.minecraft.server.PlayerManager.flush(PlayerManager.java:34)
    20:05:15 [SEVERE]    at net.minecraft.server.ServerConfigurationManager.tick(ServerConfigurationManager.java:409)
    20:05:15 [SEVERE]    at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:555)
    20:05:15 [SEVERE]    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
    20:05:15 [SEVERE]    at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    20:05:15 [SEVERE] Unexpected exception
    java.lang.NullPointerException
        at net.minecraft.server.TileEntitySign.d(TileEntitySign.java:38)
        at net.minecraft.server.PlayerInstance.sendTileEntity(PlayerInstance.java:150)
        at net.minecraft.server.PlayerInstance.a(PlayerInstance.java:109)
        at net.minecraft.server.PlayerManager.flush(PlayerManager.java:34)
        at net.minecraft.server.ServerConfigurationManager.tick(ServerConfigurationManager.java:409)
        at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:555)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:452)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:490)
    >
    
    Heres the code that handles all the sign stuff:

    Code:
    public void placeSign(String plotOwnerPrefix, String plotOwner, Block theBlock, BlockFace facingDirection)
    {
    theBlock.setType(Material.SIGN_POST);
    Sign theSign = (Sign)theBlock.getState();
    theSign.setLine(1, plotOwnerPrefix);
    theSign.setLine(2, plotOwner);
     
    if(facingDirection == BlockFace.SOUTH_WEST)
    {
    theSign.setRawData((byte) 0xE);
    }
    theSign.update();
    }
    
    I have search and searched but I couldnt seem to find anything to help me, I may have missed it though. If anyone could tell me what it is thats causing the problem let me know cause I cant make heads or tails of it
     
  2. Offline

    Usche

    Looks quite alright for me so far... are you giving the right parameter to this func?
     
  3. Offline

    hskrasek

    Here is how I am calling the method, I would laugh if I called my own method incorrectly.

    Code:
    Location bottomRightTest = new Location(w, bottomRight.getX() - 1, bottomRight.getY(), bottomRight.getZ() -1);
                    Block brBlock = bottomRightTest.getBlock();
                    placeSign("", plotName, brBlock, BlockFace.SOUTH_WEST);
    
     
  4. Offline

    Usche

    You would laugh where mistakes sometimes hide :)

    Your stackstrace says:
    So whatever "d" is its a NullPointer

    In my CodeExample your function seems to work alright.

    Cheers Usche
     
  5. Offline

    hskrasek

    The problem is I don't know what d is, I don't have a variable d floating around anywhere :/ could this be because I am trying to change a block of air to a sign, and then change its text? Because the changing the block to a sign part works, aswell as its positioning, but as soon as the setLine's come into play, explosion and crash.
     
Thread Status:
Not open for further replies.

Share This Page