Пример #1
0
        /// <summary>
        /// Should return if supplied entitytype is allowed to spawn on this block
        /// </summary>
        /// <param name="blockAccessor"></param>
        /// <param name="pos"></param>
        /// <param name="type"></param>
        /// <param name="sc"></param>
        /// <param name="handling"></param>
        /// <returns></returns>
        public virtual bool CanCreatureSpawnOn(IBlockAccessor blockAccessor, BlockPos pos, EntityProperties type, BaseSpawnConditions sc, ref EnumHandling handling)
        {
            handling = EnumHandling.PassThrough;

            return(false);
        }
Пример #2
0
        private bool CanSpawnAt(IBlockAccessor blockAccessor, EntityProperties type, BlockPos pos, Vec3d posAsVec, BaseSpawnConditions sc, float rain, float temp, float forestDensity, float shrubsDensity)
        {
            if (!api.World.BlockAccessor.IsValidPos(pos))
            {
                return(false);
            }

            float?lightLevel = blockAccessor.GetLightLevel(pos, EnumLightLevelType.MaxLight);

            if (lightLevel == null)
            {
                return(false);
            }
            if (sc.MinLightLevel > lightLevel || sc.MaxLightLevel < lightLevel)
            {
                return(false);
            }
            if (sc.MinTemp > temp || sc.MaxTemp < temp)
            {
                return(false);
            }
            if (sc.MinRain > rain || sc.MaxRain < rain)
            {
                return(false);
            }
            if (sc.MinForest > forestDensity || sc.MaxForest < forestDensity)
            {
                return(false);
            }
            if (sc.MinShrubs > shrubsDensity || sc.MaxShrubs < shrubsDensity)
            {
                return(false);
            }
            if (sc.MinForestOrShrubs > Math.Max(forestDensity, shrubsDensity))
            {
                return(false);
            }


            Block belowBlock = blockAccessor.GetBlock(pos.X, pos.Y - 1, pos.Z);

            if (!belowBlock.CanCreatureSpawnOn(blockAccessor, pos.DownCopy(), type, sc))
            {
                return(false);
            }

            Block block = blockAccessor.GetBlock(pos);

            if (!block.WildCardMatch(sc.InsideBlockCodes))
            {
                return(false);
            }

            Cuboidf collisionBox = type.SpawnCollisionBox.OmniNotDownGrowBy(0.1f);

            return(!IsColliding(collisionBox, posAsVec));
        }