Repository navigation
API ‐ Player
Apply effect to player. First variable is Effect All possible effect values can be found here Effects.cs, second variable is optional effect duration in ticks variable. Default value is -1 that will apply for infinite time, last variable is bool that to show or hide effect particles. true to show particles, false to hide. Default value is true
This example will apply Fire Resistance effect for 200 ticks or 10 seconds. Player can have multiple different effects at the same time.
player.AddEffect(Effects.FireResistance, 200)
Transfer player to another dimension of the World.
player.ChangeDimension(Dimension.Nether, new Vector3(0, 10, 0))
Transfer player to another World.
player.ChangeWorld("SkyWars", new Vector3(0, 40, 0)) //"SkyWars" is world name for world found in worlds folder "SkyWars.mcworld"
Tip: If you need to switch from one world to another dimension of another world you can do simply use - GetDimension(Dimension) like this:
Player.ChangeWorld(world.GetDimension(Dimension.Nether)); where world is target world.
Clear all on-screen titles and popups.
player.ClearTitle()
Destroy and hide bossbar that was created using ShowBossBar(string, float, float (optional)).
player.HideBossBar()
In case if you just want to update bossbar values you don't need to use ShowBossBar(). Instead you can use these methods:
SetBossBarColor(BossBarColor) - to update bossbar color
SetBossBarTitle(string) - to update bossbar title
SetBossBarValue(float) - to update bossbar value
Disconnect player from the server with message.
player.Kick("You have been kicked");
Move player to specified location. (For longer distances use Teleport(Vector3))
player.MoveTo(new Vector3(10, -20, 15))
Broadcast (Bool - true) or send to only player itself (Bool - false) animation registered by ResourcePackManager RegisterAnimation.
player.PlayAnimation("CustomSpawnAnimation")
todo
todo
Remove effect from player that have been added using AddEffect(Effect, int(optional), bool(optional))) and it's duration is not ended.
Send custom data packet.
SetActorData setActorData = new SetActorData
{
EntityId = 22,
Metadata = new Dictionary<ActorData, Metadata>() { { ActorData.VISIBLE_MOB_EFFECTS, new Metadata(1) } }
};
player.Send(setActorData);
Change player permission levels.
player.SendAbilities(3, 0) //playerPermissions, commandPermissions
Send chat message from specific source.
player.SendChatMessage("hi hi text message", "Bot1")

Send action bar messsage.
player.SendActionBarTitle("hi hi text message");

Send jukebox like message popup.
player.SendJukeboxPopup("hi hi text message");

Send LevelEvent to specified player.
player.SendLevelEvent(new Vector3(10, -50, 20), LevelEvents.ParticlesEvaporate);
Send to player itself (Bool - false) or broadcast (Bool - true) to every player this player updated metadata values.
player.SendMetadata(true);
Send chat message to specified player.
player.SendMessage("hi hi text message");

Send tooltip like message popup.
player.SendPopup("hi hi text message");

Send tooltip message.
player.SendTip("hi hi text message");

Send title and subtitle messages.
player.SendTitle("hi hi text message", "more text");

Set color of the bossbar. Color values can be found in BossBarColor class.
player.SetBossBarColor(BossBarColor.Yellow);
Possible BossBarColor values are:
Pink, Blue, Red, Green, Yellow, Purple, RebeccaPurple, White

Set title of the bossbar.
player.SetBossBarTitle("Current streak");
Set value of the bossbar how full it should be. Minimum value is 0.0f and max value is 1.0f.
player.SetBossBarValue(0.4f);
Enable (Bool - true) or disable (Bool - false) ActorFlags data for the player.
player.SetFlag(ActorFlags.ONFIRE, true);
Change player display name that other players can see.
player.SetNameTag($"Mod {player.username}")
Set custom player permissions using PermissionSet values.
player.SetPermissions(new PermissionSet() { Build = true, Mine = false, AttackMobs = true });
Initialize and show bossbar to the player.
From code below value 10 is telling in how many blocks bossbar should be split. Value 0.3f is percentage value of the bossbar how full it should be. It's minimum value is always 0.0f and max value is 1.0f.
player.ShowBossBar("Current streak", 10, 0.3f);

In case if you just want to update bossbar values you don't need to use HideBossBar(). Instead you can use these methods:
SetBossBarColor(BossBarColor) - to update bossbar color
SetBossBarTitle(string) - to update bossbar title
SetBossBarValue(float) - to update bossbar value
Teleport player to specified location.
player.Teleport(new Vector3(10, -20, 15));
Transfter player to other server.
player.Transfer("mc.cobwebsmp.com", 19132);