Solved Making an area behave like a vanilla structure

Discussion in 'Spigot Plugin Development' started by Hex_27, Jan 13, 2020.

  1. For example, I want to generate a custom Sea Temple. How do I tell minecraft to start spawning guardians in it?
  2. #3 Hex_27, Jan 13, 2020
    Last edited: Jan 13, 2020
  3. How about generate an actual temple and change the blocks?
  4. ...okay how do I do that?
  5. md_5

    Administrator Developer

    It's not currently possible with the API
  6. There's no way to hook into nms to do it either?

    EDIT: As in to make an area behave like a vanilla structure, not spawn a vanilla structure. That sounds awfully inefficient
    #8 Hex_27, Jan 15, 2020
    Last edited: Jan 15, 2020
  7. You either have to mimic the behavior yourself or need to dig around in NMS and find out how they populate the area...
    Edit: I found some bread crumbs in the WorldGenMonument class.
    #9 7smile7, Jan 15, 2020
    Last edited: Jan 15, 2020
  8. Hmmm inside biome meta...
  9. Ok i made some progress and found out how the chunks get ticked and populated.
    Just not quite sure when to change the values. The class BiomeBase has a
    EnumMap<EnumCreatureType, List<BiomeMeta>> v;
    however its private final. It gets populated while constructing the chunk. The class BiomeBase.BiomeMeta looks like this:

    And is used to get the entityTypes that should spawn on chunk ticks. (looks like they even ignore the spawn limit somehow? Not quite sure on that)
    So getting a BiomBase instance of your chunk and accessing the Field 'v' via reflections would be an idea...
    Oh nvm the Map gets populated with all EnumTypes and an empty List. There is a getter for every List:
    The method 'a' is used to add BiomeMetas but is protected. (BiomeBase.class)
    So you can get the BiomeBase instance of your chunk while generating and either calling
    Code (Text):
    BiomeBase#a(EnumCreatureType, BiomeMeta)
    where BiomeMeta should be constructed like in the WorldGenMonument.class:
    Code (Text):
    new BiomeBase.BiomeMeta(EntityTypes.GUARDIAN, 1, 2, 4);
    Or you can call
    Code (Text):
    This will return a MobList:

    Where you again can just call add
    Code (Text):
    new BiomeBase.BiomeMeta(EntityTypes.GUARDIAN, 1, 2, 4);
    • Winner Winner x 1
    • Informative Informative x 1
  10. So i would do:
    Code (Java):

        // Get BiomeBase instance of chunk (somehow)
        BiomeBase baseInstance;
        BiomeBase.BiomeMeta spawnMeta = new BiomeBase.BiomeMeta(EntityTypes.GUARDIAN, 1, 2, 4);

    Edit i found:
    Code (Text):
    ((CraftChunk)chunk).getHandle().getBiomeIndex().getBiome(x, y ,z)
    Which returns the BiomeBases :D
    #12 7smile7, Jan 15, 2020
    Last edited: Jan 15, 2020
    • Informative Informative x 2