public void SetCookingSoundVolume(float volume)
 {
     if (volume > 0)
     {
         if (cookingSound == null)
         {
             cookingSound = capi.World.LoadSound(new SoundParams()
             {
                 Location        = new AssetLocation("sounds/effect/cooking.ogg"),
                 ShouldLoop      = true,
                 Position        = pos.ToVec3f().Add(0.5f, 0.25f, 0.5f),
                 DisposeOnFinish = false,
                 Volume          = volume
             });
             cookingSound.Start();
         }
         else
         {
             cookingSound.SetVolume(volume);
         }
     }
     else
     {
         if (cookingSound != null)
         {
             cookingSound.Stop();
             cookingSound.Dispose();
             cookingSound = null;
         }
     }
 }
        private void initSoundsAndTicking()
        {
            fuelBlock = Api.World.BlockAccessor.GetBlock(FuelPos);

            l1 = Blockentity.RegisterGameTickListener(OnTick, 25);
            if (Api.Side == EnumAppSide.Server)
            {
                l2 = Blockentity.RegisterGameTickListener(OnSlowServerTick, 1000);
            }

            wsys = Api.ModLoader.GetModSystem <WeatherSystemBase>();

            if (ambientSound == null && Api.Side == EnumAppSide.Client)
            {
                ambientSound = ((IClientWorldAccessor)Api.World).LoadSound(new SoundParams()
                {
                    Location        = new AssetLocation("sounds/environment/fire.ogg"),
                    ShouldLoop      = true,
                    Position        = FirePos.ToVec3f().Add(0.5f, 0.25f, 0.5f),
                    DisposeOnFinish = false,
                    Volume          = 1f
                });

                if (ambientSound != null)
                {
                    ambientSound.PlaybackPosition = ambientSound.SoundLengthSeconds * (float)Api.World.Rand.NextDouble();
                    ambientSound.Start();
                }
            }

            particleFacing = BlockFacing.FromNormal(new Vec3i(FirePos.X - FuelPos.X, FirePos.Y - FuelPos.Y, FirePos.Z - FuelPos.Z));
        }
Esempio n. 3
0
        public Vec3f[] GetVec3s()
        {
            IPlayer  player = capi.World.Player;
            BlockPos lPos   = player.CurrentBlockSelection != null ? player.CurrentBlockSelection.Position : new BlockPos(0, -1, 0);

            return(new Vec3f[]
            {
                capi.World.Calendar.SunPosition,
                capi.World.Calendar.MoonPosition,
                player.Entity.LocalPos.XYZ.ToVec3f(),
                lPos != new BlockPos(0, -1, 0) ? lPos.ToVec3f().Add(0.5f, 0.5f, 0.5f) : new Vec3f(),
                player.CurrentEntitySelection != null ? player.CurrentEntitySelection.Entity.Pos.XYZFloat : new Vec3f(),
            });
        }