Just Another Spawner

Just Another Spawner

665k Downloads

Per mob spawn tag not evaluated during chunk spawning

Mictali opened this issue ยท 3 comments

commented

In the method used for spawning during chunk creation CustomSpawner.performWorldGenSpawning, the only rules that are checked are calls to creatureType.canSpawnAtLocation. If this check is successful then a random mob is pulled from the list and spawned ignoring any creature specific spawn tags. For example, setting spawn tag for creature type CREATURE to wrld.dimension()==0 will prevent any creatures from spawning in overworld either passively or during chunk creation. Putting that tag only on a sheep mob living handler setting will prevent sheep from spawning passively but they will continue to spawn during chunk creation. To correct the issue, inside the performWorldGenSpawning function I changed:

entityliving.setLocationAndAngles(f, f1, f2, random.nextFloat() * 360.0F, 0.0F);
    JASLog.log().logSpawn(
                true,
            (String) EntityList.classToStringMapping.get(entityliving.getClass()),
            spawnListEntry.getLivingHandler().creatureTypeID,
            (int) entityliving.posX,
            (int) entityliving.posY,
            (int) entityliving.posZ,
     BiomeHelper.getPackageName(entityliving.worldObj.getBiomeGenForCoords(
                                         (int) entityliving.posX, (int) entityliving.posZ)));
          world.spawnEntityInWorld(entityliving);
          if (!ForgeEventFactory.doSpecialSpawn(entityliving, world, f, f1, f2)) {
            entitylivingdata = entityliving.onSpawnWithEgg(entitylivingdata);
          }
          spawnListEntry.getLivingHandler().postSpawnEntity(entityliving, spawnListEntry, countInfo);
          countInfo.countSpawn(entityliving, creatureType.typeID);
          flag = true;
        } else {
          JASLog.log().debug(Level.INFO,
                             "Entity not Spawned due to invalid creatureType location. Creature Type was %s",
                             creatureType.typeID);
      }

to

   entityliving.setLocationAndAngles(f, f1, f2, random.nextFloat() * 360.0F, 0.0F);
  /////Additional check for mob level rules
   if(spawnListEntry.getLivingHandler().getCanSpawnHere(entityliving, spawnListEntry, countInfo) ) {
         JASLog.log().logSpawn(
                    true,
                (String) EntityList.classToStringMapping.get(entityliving.getClass()),
                spawnListEntry.getLivingHandler().creatureTypeID,
                (int) entityliving.posX,
                (int) entityliving.posY,
                (int) entityliving.posZ,
    BiomeHelper.getPackageName(entityliving.worldObj.getBiomeGenForCoords(
                                       (int) entityliving.posX, (int) entityliving.posZ)));
          world.spawnEntityInWorld(entityliving);
          if (!ForgeEventFactory.doSpecialSpawn(entityliving, world, f, f1, f2)) {
            entitylivingdata = entityliving.onSpawnWithEgg(entitylivingdata);
          }
          spawnListEntry.getLivingHandler().postSpawnEntity(entityliving, spawnListEntry, countInfo);
          countInfo.countSpawn(entityliving, creatureType.typeID);
          flag = true;
        } else {
          JASLog.log().debug(Level.INFO,
                             "Entity not Spawned due to invalid creatureType location. Creature Type was %s",
                             creatureType.typeID);
        }
      } else {
          JASLog.log().debug(Level.INFO,
                             "Entity not allowed to spawn in chunk. Creature Type was %s",
                             creatureType.typeID);
      }
commented

This is currently working as intended. Vanilla only does a type check and ignores entity specific rules.

This could be changed, but could have considerable effect on default behavior.

commented

It may the way Vanilla works, but I thought the purpose of JAS was to take control away from Vanilla spawning and define it how you want. So the way this is currently written I was unable to achieve the effect I desired.

To explain, I'm working a pack design that makes Overworld mostly peaceful but includes Mystcraft and as you progress through new ages you'll encounter different creatures and mobs. I'm including Project Zulu, EnderZoo and Lycanites to add mobs and creatures.

It was easy enough to define Overworld as "peaceful" by adding a wrld.dimension()==0 check to the monster creature type spawn tag which inhibits both passive and chunk spawning, but I wanted the same for some of the Lycanites creatures. And I defined a new creature type (OVERWORLDMONSTER) that didn't have that setting and put Spider's in there so they would spawn. That works just fine.

But I had also configured the Lycanite Mountain Mob Vale to appear only starting in any age 3 or later that I visited yet Vales were appearing in Overworld because they were spawning during chunk events even though the Vale spawntag was restricting which dimensions. At first I thought it was Lycanites spawner not being disabled, but discovered it was JAS.

So right now my choices are maintain my own build of JAS or look at an alternative. Lycanite's built in spawning supports dimension specific settings per type and EnderZoo offers an ability to control mob spawning as well so I'm trying a combination of those. Not sure if it will achieve the desired results so I may be back to a custom build of JAS.

commented

Thanks, I'll pull your latest and give it a try.