World.getBlockAt( int x, int y, int z) returning a block with type AIR when the chunk isn't loaded

Discussion in 'Plugin Development' started by WillPall, Sep 28, 2011.

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

    WillPall

    I have a plugin (MobRepellent) that checks a block stored in a file when the plugin is loaded using [world].getBlockAt(x,y,z). When the plugin is loaded (with no players on the server), the block returns the correct block with the correct type. However, if a player enters the chunk that contains the block (thus the chunk gets loaded in memory), and then the player leaves the chunk (and it gets unloaded) [world].getBlockAt() returns an empty block with type AIR.

    Is this a bug? Is this the desired functionality? If so, how can I get information about a block using its x, y, z coordinates if it's in a chunk that isn't loaded in memory?

    Edit: Alright, so some other developers seem to think this is a bug (#656). So any ideas of how I can get around it? I definitely need the Block object at the x/y/z location.
     
  2. I do not know much in coding yet, but is there a function to load a chunk ?
    If it exist you could first load the chunk and then check the desired block...

    Does getBlockTypeIdAt() works ? Don't know if you could use it instead.
     
  3. Offline

    WillPall

    Yes, getBlockTypeIdAt() does work. However, getBlockTypeIdAt() is a function that is more directly tied to the original Minecraft server. The World.getBlockAt() function seems to be a newer Bukkit function, and it doesn't behave the same way the getBlockTypeIdAt() function does. The problem is, I need more than just the type for several features that my plugin provides.

    I didn't think about it, but it may be possible for me to call the chunk functions that Bukkit uses when calling getBlockTypeIdAt(). Thanks.


    Anybody else have any ideas about why getBlockAt() wouldn't be working? I'm thinking of making a pull request on git to fix the bug, but I'm afraid I'll mess something up ;).
     
Thread Status:
Not open for further replies.

Share This Page