Detecting natural generated structures (Mineshafts)

Discussion in 'Spigot Plugin Development' started by Alex_qp, Jul 24, 2018.

  1. Hey there,

    after a bit of searching I could not find anything to accomplish my goal. So first of all my goal is to add TNT blocks at the end of some mineshafts generated by the default world generator.

    Is there any way to accomplish this without interfering into the vanilla world generation? I do not want to create my own world generator or stuff like that because it would just make no sense to put in that much effort for such a small change. But there is maybe a way to just change the behavior of it a little bit..?

    Thanks for any help in advance!
    Alex
     
  2. Heyo,
    I won't be able to fully answer your question, but I can give you a place to start looking.
    I couldn't find any events that are fired when a structure is spawned, but you could check into the ChunkPopulateEvent and test the chunk for mineshaft's blocks like wood and rails.

    The way that mineshafts are generated is using the WorldGenMineshaft class, which comes from StructureGenerator, and ultimately WorldGenBase. If you look into it enough you might be able to find a way to inject your own StructurePiece class which contains your custom TNT placements.

    Sorry I'm not able to give you any more info ;/
     
    • Like Like x 2
  3. Thanks for the reply. I think you might be on to something. I even ran around a mineshaft for a little bit now and hopefully I am correct that the thingy that supports the ceiling is always within one chunk.

    But before jumping into this: I think it stresses the cpu pretty hard if someone is generating new terrain cause it will scan every new generated chunk for a fence for example...? Even if I limit the y values from 10-20 this will still mean scanning 2560 blocks for every chunk or is a material check very efficient written..? :D

    /e After reconsidering it will only take me 1280 blocks but this still seems a lot to me (cause I am fine with just checking every second y value)
     
  4. bump because I may have another solution to it:

    Is there any way to access values of the /local command via plugin?
     
  5. WorldServer#a(String s, BlockPosition blockposition, boolean flag) returns a BlockPosition of the nearest structure. You can get the WorldServer class for any world by using:
    ((CraftWorld) world).getHandle().a(String s, BlockPosition blockposition, boolean flag);

    Hope I could help ^-^

    Edit: "s" is the structure type which are the following:
    "Stronghold", "Monument", "Village", "Mansion", "EndCity", "Fortress", "Temple", "Mineshaft"
     
    • Useful Useful x 1