Solved Searching for DIAMOND_BLOCK in a map(chunk)

Discussion in 'Plugin Development' started by MGlolenstine, May 28, 2017.

Thread Status:
Not open for further replies.
  1. What is the best way to search for diamond_block? It would help to search for signs as well.
     
  2. @MGlolenstine
    You could obviously loop through every block in the chunk, but that's slow and inefficient. Can you tell us what you're actually doing? Maybe there's another way (like using BlockPlaceEvent)?
     
  3. well... I have generators. Sadly there are no events connected to them. I think that I could detect all of the signs with following code:
    Code:
      World world = Bukkit.getServer().getWorld("World");
        for (Chunk chunk : world.getLoadedChunks())
        {
        for (BlockState blockState : chunk.getTileEntities())
        {
        if (blockState instanceof Sign)
        {
        Sign sign = (Sign) blockState;
        if(sign.getLine(1).equalsIgnoreCase("smth") || sign.getLine(2).equalsIgnoreCase("smth") || sign.getLine(3).equalsIgnoreCase("smth") || sign.getLine(4).equalsIgnoreCase("smth")){
    
    //do smth
    
    }
        }
        }
        }
     
  4. @MGlolenstine
    Right, and what does this generator do? Does it just need to do a thing every at a regular interval?
     
  5. Yes, It spawns an Item on top of the block, varying on the sign that's on the block.
     
  6. @MGlolenstine
    Why don't you just save the location of the generator when it's created, and then loop through that list in a task and spawn the item?
     
  7. I was thinking of that, and I think that it's the best idea, I just didn't want to make someone running around and manually setting the generators in the config(with a command ofc), I'd just like to do something like
    Code:
    /ew reload
    and everything would set up.

    I might try combined forces... First automatic detection for coordinates and then setting the locations in the config.yml and then reading from it.

    Is there a way for me not to have to store in config.yml, but to store in another file?
     
  8. MGlolenstine likes this.
  9. Thank you!

    I forgot to ask... How can I save this "alternate" config? I can't seem to be able to save it with data.saveConfig().

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 28, 2017
Thread Status:
Not open for further replies.

Share This Page