Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5073

Structure specific Mob Spawning in CustomChunkGenerator

XMLWordPrintable

    • CraftBukkit version git-Spigot-df0eb25-9e95da1 (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
    • Yes

      In Minecraft are several structures that allow spawning only specific type of mobs in it, f.e. in WitchHuts only Witches are allowed to spawn in.

      Unfortunately, this functionality is not working if plugins are using their own chunk generators. (relates to SPIGOT-5072).
      If chunks are generated with CustomChunkGenerator class then it always spawns mobs that are valid in the biome, and it does not check structures at all.

      It is done in method getMobsFor(). In vanilla generator classes there is check for these structures, and I suggest to improve getMobsFor method with:

          @Override
          public List<BiomeBase.BiomeMeta> getMobsFor(EnumCreatureType type, BlockPosition position) {
              if (WorldGenerator.SWAMP_HUT.c(this.a, position)) {
                  // Process mobs in a swamp hut
      
                  if (type == EnumCreatureType.MONSTER) {
                      return WorldGenerator.SWAMP_HUT.e();
                  }
      
                  if (type == EnumCreatureType.CREATURE) {
                      return WorldGenerator.SWAMP_HUT.f();
                  }
              } else if (type == EnumCreatureType.MONSTER) {
                  // Spawn pillagers around Pillager Outpost
                  if (WorldGenerator.PILLAGER_OUTPOST.a(this.a, position)) {
                      return WorldGenerator.PILLAGER_OUTPOST.e();
                  }
      
                  // Spawn guardians around ocean monuments
                  if (WorldGenerator.OCEAN_MONUMENT.a(this.a, position)) {
                      return WorldGenerator.OCEAN_MONUMENT.e();
                  }
      
                  // Spawn nether fortress mobs, like wither skeleton, blaze and magma cube
                  if (WorldGenerator.NETHER_BRIDGE.b(this.a, position)) {
                      return WorldGenerator.NETHER_BRIDGE.e();
                  }
      
                  // Spawn nether fortress mobs, like wither skeleton, blaze and magma cube on nether bricks only
                  if (WorldGenerator.NETHER_BRIDGE.a(this.a, position) && this.a.getType(position.down()).getBlock() == Blocks.NETHER_BRICKS) {
                      return WorldGenerator.NETHER_BRIDGE.e();
                  }
              }
              
              BiomeBase biomebase = world.getBiome(position);
              return biomebase == null ? null : biomebase.getMobs(type);
          }
      

      As CustomChunkGenerator is used in all dimensions, then I added also check on Nether Fortress.

       

            Unassigned Unassigned
            BONNe BONNe
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: