mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-21 11:53:51 +00:00
playsound, sleep ignoring
This commit is contained in:
parent
a5e39efa04
commit
a0be612f48
7 changed files with 294 additions and 9 deletions
|
|
@ -17,6 +17,7 @@ public class Player : HumanEntity, OfflinePlayer, CommandSender
|
|||
private bool _sneaking;
|
||||
private bool _sprinting;
|
||||
private bool _allowFlight;
|
||||
private bool _sleepingIgnored;
|
||||
|
||||
internal bool IsOnline { get; set; }
|
||||
|
||||
|
|
@ -110,6 +111,40 @@ public class Player : HumanEntity, OfflinePlayer, CommandSender
|
|||
/// <returns>True if player is sprinting.</returns>
|
||||
public bool isSprinting() => _sprinting;
|
||||
|
||||
/// <summary>
|
||||
/// Sets whether the player is ignored as not sleeping. If everyone is
|
||||
/// either sleeping or has this flag set, then time will advance to the
|
||||
/// next day. If everyone has this flag set but no one is actually in
|
||||
/// bed, then nothing will happen.
|
||||
/// </summary>
|
||||
/// <param name="isSleeping">Whether to ignore.</param>
|
||||
public void setSleepingIgnored(bool isSleeping)
|
||||
{
|
||||
_sleepingIgnored = isSleeping;
|
||||
NativeBridge.SetSleepingIgnored?.Invoke(getEntityId(), isSleeping ? 1 : 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns whether the player is sleeping ignored.
|
||||
/// </summary>
|
||||
/// <returns>Whether player is ignoring sleep.</returns>
|
||||
public bool isSleepingIgnored() => _sleepingIgnored;
|
||||
|
||||
/// <summary>
|
||||
/// Play a sound for a player at the location.
|
||||
/// This function will fail silently if Location or Sound are null.
|
||||
/// </summary>
|
||||
/// <param name="location">The location to play the sound.</param>
|
||||
/// <param name="sound">The sound to play.</param>
|
||||
/// <param name="volume">The volume of the sound.</param>
|
||||
/// <param name="pitch">The pitch of the sound.</param>
|
||||
public void playSound(Location location, Sound sound, float volume, float pitch)
|
||||
{
|
||||
if (location == null)
|
||||
return;
|
||||
NativeBridge.PlaySound?.Invoke(getEntityId(), (int)sound, location.X, location.Y, location.Z, volume, pitch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the Player is allowed to fly via jump key double-tap
|
||||
/// like in creative mode.
|
||||
|
|
@ -242,4 +277,5 @@ public class Player : HumanEntity, OfflinePlayer, CommandSender
|
|||
internal void SetSneakingInternal(bool sneaking) => _sneaking = sneaking;
|
||||
internal void SetSprintingInternal(bool sprinting) => _sprinting = sprinting;
|
||||
internal void SetAllowFlightInternal(bool allowFlight) => _allowFlight = allowFlight;
|
||||
internal void SetSleepingIgnoredInternal(bool ignored) => _sleepingIgnored = ignored;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue