.getBlock(); not returning properly.

Discussion in 'Plugin Development' started by PurelySatanic, Mar 9, 2011.

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

    PurelySatanic

    I've seen some posts suggesting similar issues to what I am about to explain so I'm sorry if this is a dead horse I'm beating.

    .getBlock(); normally returns properly however lately I've noticed if I walk into another chunk - or just far away from spawn the .getBlock(); method starts returning random blocks.

    SIDE NOTE: I didn't think to check if the .getBlock(); was returning the same location as the block I was trying to get, I'll check this shortly after and return my findings.

    Example code:
    Code:
    Player player = e.getPlayer();
    Block block = e.getBlock();
    ItemStack item = new ItemStack(Material.DIAMOND_PICKAXE,1);
    ItemStack itemToDrop = new ItemStack(Material.OBSIDIAN,1);
    
    Code:
    if(block.getType().equals(Material.OBSIDIAN)) {
      if(player.getItemInHand().equals(item)) {
        block.setType(Material.AIR);
        player.getWorld().dropItemNaturally(block.getLocation(), itemToDrop);
      }
    }
    
    Will return correctly when I'm standing near where I first login, but after a while of walking, or simply moving to another chunk it'll start returning incorrectly.

    It's not fantastically written or anything but it should work...?

    Do you see anything wrong, or is this a bug?
     
  2. Offline

    Cheesier

    No errors ? Not walking too far away from that position it so that chunk is unloaded ?
    What block does it return and what block should it be ??
     
  3. Offline

    Raphfrk

    This is presumably linked to the break block event?
     
  4. Offline

    Myers Carpenter

  5. Offline

    PurelySatanic

    Myers thanks for the link that seems similar to my issue if not exactly the same.

    The two blocks types I've had it returned were sand and air.

    I am calling that through the blockDamaged event, not the blockBreak event.
     
  6. Offline

    SycoPrime

    Oh thank god, I'm not the only one.
     
  7. Offline

    PurelySatanic

    I've noticed when I reset the server (completely shut it down, boot it back up) it starts returning the correct block.

    But then after a while other areas start returning the wrong block type.

    Does this hold true for you too?
     
  8. Offline

    NathanWolf

    I have what I think is this issue, from time to time. It breaks most of my spells and portaling in NetherGate :(

    From what I can tell, it seems like mcserver loses track of time, either specific to a player, or in general, I'm not sure.

    The end result is that getBlock() returns blocks seemingly at random, or (I think) as if the world was in its original unmodified state.

    In any case, you're definitely not the only one....
     
  9. Offline

    Afforess

    Yeah - really annoying. Having hordes of complaints about it. Worst - when that happens to a sign block. The game knows it's a sign, but when you try to get a line of the sign, it throws errors from deep inside CB.
     
  10. Offline

    Raphfrk

    @Afforess
    @PurelySatanic
    @SycoPrime

    I have implemented a possible fix for this. I haven't sent it in as a pull request yet. If any of your guys can quickly trigger the bug, it would be nice to have verification that it helps/fixes it.

    The is the commit
     
  11. Offline

    Greylocke

    Wow-- you could be onto something there, Raphfrk. I just did a quick teleport test, and some of the bugs I was seeing with [493] are gone. I did not do any extensive testing, but usually one teleport was enough to break things. This time things were still working! I can't wait to hear back from the other devs...
     
  12. Offline

    NathanWolf

    Raphrk, I find this frustratingly easy to reproduce with Spells and NetherGate- I will definitely test out your fix and report back ASAP. Thanks!!
    [MERGETIME="1299874465"][/MERGETIME]
    Ok, I threw it up on my server:

    mine.elmakers.com

    I don't have time to play around right now- but if you can portal back and forth while still using the pillar spell effectively, then things are better than they were :)
     
  13. Offline

    Raphfrk

    Yay :)

    Btw, it was Pepijn Schmitz who found the potential problem, I just coded it (all 6-7 lines).

    I also added handling for chunks which are unloaded using the API (rather than chunks which "naturally" unload due to player movement)
     
  14. Offline

    NathanWolf

    @Raphfrk, we got an NPE - I'm downloading my screen log now, but apparently it's been a while since I rotated- its' like 6MB :p

    Lots of "can't keep ups" in there... I should run that through grep or something...

    Anyway, I'm going to copy+pastebin the relevant bits- will link in a moment.
     
  15. Offline

    Raphfrk

    Cool. Probably only need the last few lines :)
     
  16. Offline

    NathanWolf

  17. Offline

    Raphfrk

    Well, at least from the point I logged in.
     
  18. Offline

    NathanWolf

    Yeah, or maybe just this:

    at net.minecraft.server.BlockBloodStone.a(BlockBloodStone.java:15)

    And this:

    at net.minecraft.server.BlockFlowing.a(BlockFlowing.java:87)

    ?
    [MERGETIME="1299876440"][/MERGETIME]
    I can give you that, but it's just us chatting briefly and a lot of "can't keep ups" ;)

    Nothing else interesting in there until this NPE.

    Hrm, well, this:
    Code:
    12:39:56 [INFO] raphfrk [/78.16.120.240:49921] logged in with entity id 489
    >
    12:39:56 [INFO] Persistence: loaded 3 profiles from permissions.yml
    >
    12:39:58 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?
    >
    12:40:01 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?
    >
    12:40:14 [INFO] NG: TP'ing Player raphfrk from (88, 70, -360) to (88, 71, -360)
    >
    12:40:14 [INFO] NG: Clearing area around 88, 71, -360
    >
    12:40:14 [INFO] NG: Building a platform at 88, 71, -360
    >
    12:40:17 [WARNING] raphfrk moved wrongly!
    >
    12:40:17 [INFO] Got position 88.0, 72.0, -360.0
    >
    12:40:17 [INFO] Expected 88.30000001192093, 70.20000004768372, -359.69999998807907
    >
    12:40:20 [INFO] NathanWolf [/192.168.1.9:60416] logged in with entity id 1218
    And then here's the NPE so you don't have to go to pastebin, while I'm at it :)

    Code:
    >
    12:41:24 [WARNING] Can't keep up! Did the system time change, or is the server overloaded?
    >
    12:41:30 [SEVERE] java.lang.NullPointerException
    >
    12:41:30 [SEVERE]       at net.minecraft.server.BlockBloodStone.a(BlockBloodStone.java:15)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.World.k(World.java:369)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.World.h(World.java:344)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.World.f(World.java:317)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.World.e(World.java:293)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.BlockFlowing.a(BlockFlowing.java:87)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.World.a(World.java:1534)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.World.g(World.java:1433)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
    >
    12:41:30 [SEVERE]       at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    >
    12:41:30 [SEVERE] Unexpected exception
    java.lang.NullPointerException
            at net.minecraft.server.BlockBloodStone.a(BlockBloodStone.java:15)
            at net.minecraft.server.World.k(World.java:369)
            at net.minecraft.server.World.h(World.java:344)
            at net.minecraft.server.World.f(World.java:317)
            at net.minecraft.server.World.e(World.java:293)
            at net.minecraft.server.BlockFlowing.a(BlockFlowing.java:87)
            at net.minecraft.server.World.a(World.java:1534)
            at net.minecraft.server.World.g(World.java:1433)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    >
    [MERGETIME="1299876493"][/MERGETIME]
    BTW, that "moved wrongly" thing also sucks. My next step with NG is to use bukkitsched to postpone TP'ing players- I think doing it in onChunkLoad is... bad... sometimes... or something .... ?

    Anyway, I'm hoping that gets rid of the "moved wrongly" bug- that message comes from somewhere inside bukkit, not from nethergate.
     
  19. Offline

    Raphfrk

    Hmm, that looks like it is related to redstone activity. There was a red stone commit previously.

    I vote we blame this commit :).
     
  20. Offline

    NathanWolf

    Oh, and your particular "moved wrongly" was not a severe case- only a couple blocks off in Y. Sometimes X and Z are off by many blocks, and you get a lava bath in the nether, or you get suffocated, etc- it's lame.
    [MERGETIME="1299876600"][/MERGETIME]
    LOL- well, it seems to have crashed my server hard :p

    Restarting- maybe we can apply your fix to an earlier CB? ;)
    [MERGETIME="1299876620"][/MERGETIME]
    Always strange when the server console is responsive but I can't log in...
    [MERGETIME="1299876674"][/MERGETIME]
    Ok, I'm going to play for a bit- didn't really get to test before it crashed.

    Also, not really sure where, in that world, lava is flowing over redstone!
     
  21. Offline

    Raphfrk

    One sec will recompile
     
  22. Offline

    NathanWolf

    Oooohhh... wait, BLOODstone! This isn't redstone.... wtf?

    Also, it happens on login now :(
    [MERGETIME="1299876756"][/MERGETIME]
    It seems to be related to lava flowing over/near bloodstone (netherrak)- which is why it crashed when I portalled to nether spawn, and why it now crashes when I log in :(
     
  23. Offline

    Raphfrk

    Ok, done. The jar file is at the same link.

    The problem is that when you go back with CraftBukkit, you have to find a matching Bukkit version.
    [MERGETIME="1299877417"][/MERGETIME]
    I think the commit adds lots more redstone change events.
    [MERGETIME="1299877470"][/MERGETIME]
    Btw is the exception always with the same block type?
     
  24. Offline

    NathanWolf

    Thanks! It's up now- I'll log in in a sec.

    Ugh, so true....

    Yeah, but, still- this isn't redstone, right? Am I reading that wrong?
    [MERGETIME="1299877557"][/MERGETIME]
    Well, I'm happy to report that I don't get it anymore so I can't say :p

    Going to try and do some getBlock testing now ;)
     
  25. Offline

    Raphfrk

    In this commit, they add a check. I think they need it for all blocks:

    Code:
    Block.byId[l].c()
    
    is replaced by

    Code:
    Block.byId[l] != null && Block.byId[l].c()
    
    [MERGETIME="1299877731"][/MERGETIME]
    They are events related to the block being powered by redstone.
     
  26. Offline

    NathanWolf

    Bah, I lied- just took a bit I guess :p

    Code:
    13:06:14 [SEVERE] java.lang.NullPointerException
    13:06:14 [SEVERE]       at net.minecraft.server.BlockBloodStone.a(BlockBloodStone.java:15)
    13:06:14 [SEVERE]       at net.minecraft.server.World.k(World.java:369)
    13:06:14 [SEVERE]       at net.minecraft.server.World.h(World.java:346)
    13:06:14 [SEVERE]       at net.minecraft.server.World.f(World.java:317)
    13:06:14 [SEVERE]       at net.minecraft.server.World.e(World.java:293)
    13:06:14 [SEVERE]       at net.minecraft.server.BlockFlowing.a(BlockFlowing.java:87)
    13:06:14 [SEVERE]       at net.minecraft.server.World.a(World.java:1534)
    13:06:14 [SEVERE]       at net.minecraft.server.World.g(World.java:1433)
    13:06:14 [SEVERE]       at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348)
    13:06:14 [SEVERE]       at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
    13:06:14 [SEVERE]       at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    13:06:14 [SEVERE] Unexpected exception
    java.lang.NullPointerException
            at net.minecraft.server.BlockBloodStone.a(BlockBloodStone.java:15)
            at net.minecraft.server.World.k(World.java:369)
            at net.minecraft.server.World.h(World.java:346)
            at net.minecraft.server.World.f(World.java:317)
            at net.minecraft.server.World.e(World.java:293)
            at net.minecraft.server.BlockFlowing.a(BlockFlowing.java:87)
            at net.minecraft.server.World.a(World.java:1534)
            at net.minecraft.server.World.g(World.java:1433)
            at net.minecraft.server.MinecraftServer.h(MinecraftServer.java:348)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:272)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    
    [MERGETIME="1299877823"][/MERGETIME]
    It does seem to always be the same block, but maybe that's related to where I am more than anything? Would lava flowing over any block trigger this, I wonder?

    Easy enough to test if you want- I'll start up the server, you log in. It should work, in theory, right?

    If so, you can use the "lava" spell to try and crash it.
     
  27. Offline

    Raphfrk

    I assume you aren't seeing this with the standard server?
    [MERGETIME="1299877913"][/MERGETIME]
    Also, I just tried to login there a second ago, wonder if it is caused by having 2 people on the server
     
  28. Offline

    NathanWolf

    Not the stuff bukkit changed- the stuff that's crashing. It's just a flowing event- is that used for redstone, too?

    I haven't look at the internals of redstone much, to be honest.

    In any case, I think this is just lava over netherrak- you want to test with the lava spell? If I login it crashes, if you login it should be ok if my theory is sound.
    [MERGETIME="1299878012"][/MERGETIME]
    Hrm- interesting... you want to try it again with me not logged in?
     
  29. Offline

    Raphfrk

    So how do I trigger lava?
    [MERGETIME="1299878094"][/MERGETIME]
    Also, are you logged into IRC, might be better than flooding the thread :)
     
  30. Offline

    NathanWolf

    If it was just now, then I was already gone and restarted- I see you in the logs, you were the first one to log in

    I saw your testing message, then saw you try "lava".

    Did it crash on its own in some way, 'cause you seem to be gone now? Or did you figure out the lava spell and break it? :D
     
Thread Status:
Not open for further replies.

Share This Page