CreeperHost Presents Chickens

CreeperHost Presents Chickens

2M Downloads

Nether based chickens not spawning

merriama opened this issue ยท 1 comments

commented

Updated because I saw nether chickens were supposed to be fixed but Nether Quartz and Soul Sand chickens are still not spawning.

Minecraft 1.19.2
Forge 43.2.8
chickensmod-1.19.2-1.0.32

commented

I also did some digging and I think it could be a logic error in the checkAnimalSpawnRules(...).
It could be the the first if statement always returns false for the Nether. Because in the net.minecraft.tags.BlockTags a lot of the Nether blocks or even the Nether in general is listed as BlockTags.ANIMALS_SPAWNABLE_ON. To circumvent this you could probably move the SpawnType.HELL if statement before the BlockTags.ANIMALS_SPAWNABLE_ON.
But I am no minecraft mod dev so im just guessing.

Original:

    public static boolean checkAnimalSpawnRules(EntityType<? extends Animal> entityType, LevelAccessor levelAccessor, MobSpawnType mobSpawnType, BlockPos blockPos, Random random, ChickensRegistryItem chickensRegistryItem)
    {
        if(!levelAccessor.getBlockState(blockPos.below()).is(BlockTags.ANIMALS_SPAWNABLE_ON)) return false;
        if(!isBrightEnoughToSpawn(levelAccessor, blockPos)) return false;
        if(!chickensRegistryItem.canSpawn()) return false;
        if(chickensRegistryItem.getSpawnType() == SpawnType.NORMAL)
        {
            return levelAccessor.dimensionType().natural();
        }
        if(chickensRegistryItem.getSpawnType() == SpawnType.HELL)
        {
            return levelAccessor.dimensionType().piglinSafe();
        }
        return true;
    }

Example implementation:

public static boolean checkAnimalSpawnRules(EntityType<? extends Animal> entityType, LevelAccessor levelAccessor, MobSpawnType mobSpawnType, BlockPos blockPos, Random random, ChickensRegistryItem chickensRegistryItem)
{
    if(!chickensRegistryItem.canSpawn()) return false;

    if(chickensRegistryItem.getSpawnType() == SpawnType.HELL)
    {
        if(levelAccessor.dimensionType().piglinSafe())
        {
            return true; // We might not care about light level or the block below in the Nether.
        }
        return false;
    }

    // Checks that are relevant mainly for Overworld spawns.
    if(!levelAccessor.getBlockState(blockPos.below()).is(BlockTags.ANIMALS_SPAWNABLE_ON)) return false;
    if(!isBrightEnoughToSpawn(levelAccessor, blockPos)) return false;
    if(chickensRegistryItem.getSpawnType() == SpawnType.NORMAL)
    {
        return levelAccessor.dimensionType().natural();
    }
    
    return true;
}