public PlayerInventory(Player player) { Player = player; Slots = Enumerable.Repeat(new ItemStack(), 35).ToList(); //int c = 0; //Slots[++c] = new ItemStack(new ItemBow(0), 3); //Slots[++c] = new ItemStack(262, 64); //Slots[++c] = new ItemStack(new ItemSteak(), 1); //Slots[++c] = new ItemStack(new ItemApple(), 1); //Slots[++c] = new ItemStack(new ItemBakedPotato(), 1); //Slots[++c] = new ItemStack(new ItemBakedPotato(), 1); //Slots[++c] = new ItemStack(new ItemBakedPotato(), 1); ItemHotbar = new int[6]; InHandSlot = 0; //Boots = new ItemDiamondBoots(0); //Leggings = new ItemDiamondLeggings(0); //Chest = new ItemDiamondChestplate(0); //Helmet = new ItemDiamondHelmet(0); Boots = new Item(0, 0); Leggings = new Item(0, 0); Chest = new Item(0, 0); Helmet = new Item(0, 0); for (byte i = 0; i < 6; i++) { ItemHotbar[i] = i; } }
public Player() { _chunksUsed = new Dictionary<Tuple<int, int>, ChunkColumn>(); HealthManager = new PCHealthManager(this); if (PlayerEntity == null) PlayerEntity = new MiNET.Player(null, null, PluginGlobals.Level[0], null, -1); PlayerInventory = new PlayerInventory(this); }
public void RegisterCommand(Player player, string password) { var userManager = Context.Server.UserManager; var user = userManager.FindByNameAsync(player.Username).Result; if (user == null) { if (password == null && password.IndexOf(' ') > -1) { player.SendMessage($"Do not add any space in your password!"); return; } user = new User(player.Username); Context.Server.UserManager.CreateAsync(user, password); user.IsAuthenticated = true; userManager.UpdateAsync(user); } else if (user.IsAuthenticated) { player.SendMessage($"{ChatColors.Red}You has been Login!"); } else if (Context.Server.UserManager.HasPasswordAsync(user.Id).Result) { player.SendMessage($"You has been register,Plz Type your password to login"); } }
public override bool PlaceBlock(Level world, MiNET.Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { switch (face) { case BlockFace.South: // ok Metadata = 0; break; case BlockFace.North: Metadata = 1; break; case BlockFace.West: Metadata = 2; break; case BlockFace.East: // ok Metadata = 3; break; } world.SetBlock(this); return(true); }
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { byte direction = player.GetDirection(); switch (face) { case BlockFace.South: // ok Metadata = 0; break; case BlockFace.North: Metadata = 1; break; case BlockFace.West: Metadata = 2; break; case BlockFace.East: // ok Metadata = 3; break; } Log.Warn($"Direction={direction}, face={face}, metadata={Metadata}"); world.SetBlock(this); return true; }
public override void PlaceBlock(Level world, MiNET.Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords) { var coor = GetNewCoordinatesFromFace(blockCoordinates, face); ItemFrameBlockEntity itemFrameBlockEntity = new ItemFrameBlockEntity { Coordinates = coor }; FullyLuminousItemFrame itemFrame = new FullyLuminousItemFrame(_frame, itemFrameBlockEntity, world) { Coordinates = coor, }; if (!itemFrame.CanPlace(world, blockCoordinates, face)) { return; } itemFrame.PlaceBlock(world, player, coor, face, faceCoords); // Then we create and set the block entity that has all the intersting data world.SetBlockEntity(itemFrameBlockEntity); }
public static void SendCenteredSubtitle(MiNET.Player player, string content, bool centreText, int fadein, int fadeOut, int stayTime) { string subtitleString = ""; int i = 0; while (i++ < 3) { subtitleString += "§r\n"; } if (centreText) { i += content.Split('\n').Length; subtitleString += TextUtils.Center(content); } while (i++ < 11) //Push Up { subtitleString += "§f\n"; } player.SendTitle("§f", TitleType.AnimationTimes, fadein, fadeOut, stayTime); player.SendTitle(subtitleString, TitleType.SubTitle); player.SendTitle("§f", TitleType.Title); }
public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face) { Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign; if (signEntity == null) return false; string world = signEntity.Text1; if (player.Level.LevelId.Equals(world)) return true; if (!Worlds.ContainsKey(player.Level.LevelId)) { Worlds.Add(player.Level.LevelId, player.Level); } if (!Worlds.ContainsKey(world)) { var mobHuntLevel = new MobHuntLevel(world, new FlatlandWorldProvider()); mobHuntLevel.Initialize(); Worlds.Add(world, mobHuntLevel); } Level level = Worlds[world]; player.SpawnLevel(level); level.BroadcastTextMessage(string.Format("{0} teleported to world <{1}>.", player.Username, level.LevelId)); return true; }
public new virtual void RemovePlayer(MiNET.Player player, bool removeFromWorld = false) { //SkyUtil.log($"Attempting to remove {player.Username} from {GameId}"); if (((SkyPlayer)player).GameTeam == null || player.Level != this) { //Run base MiNET code even if our code shouldn't run. base.RemovePlayer(player, removeFromWorld); return; //Shouldn't be in the/any game. } CurrentState.HandleLeave(this, (SkyPlayer)player); if (PlayerTeamDict.TryGetValue(player.Username, out var gameTeam)) { PlayerTeamDict.Remove(player.Username); TeamPlayerDict[gameTeam].Remove((SkyPlayer)player); } //Enforce removing the attached team ((SkyPlayer)player).GameTeam = null; player.RemoveAllEffects(); base.RemovePlayer(player, removeFromWorld); //Remove player from the 'world' }
/* public override void AddEntity(Entity entity) * { * if (Entities == null) return; * * lock (Entities) * { * EntityManager.AddEntity(entity); * * if (Entities.TryAdd(entity.EntityId, entity)) * { * if (entity.HealthManager is HealthManager) * { * * } * LevelEntityAddedEvent addedEvent = new LevelEntityAddedEvent(this, entity); * EventDispatcher.DispatchEvent(addedEvent); * * entity.SpawnToPlayers(GetAllPlayers()); * } * else * { * throw new Exception("Entity existed in the players list when it should not"); * } * } * } * * public override void RemoveEntity(Entity entity) * { * if (Entities == null) return; * * lock (Entities) * { * if (!Entities.TryRemove(entity.EntityId, out entity)) return; // It's ok. Holograms destroy this play.. * * LevelEntityRemovedEvent removedEvent = new LevelEntityRemovedEvent(this, entity); * EventDispatcher.DispatchEvent(removedEvent); * * entity.DespawnFromPlayers(GetAllPlayers()); * } * }*/ public override void AddPlayer(MiNET.Player newPlayer, bool spawn) { if (newPlayer.Skin == null) { newPlayer.Skin = new Skin() { Animations = new List <Animation>(), Cape = new Cape() { Data = new byte[0] }, Data = ArrayOf <byte> .Create(8192, 0xFF), Height = 64, Width = 32, IsPremiumSkin = false, IsPersonaSkin = false, Slim = false }; } base.AddPlayer(newPlayer, spawn); if (Players.TryGetValue(newPlayer.EntityId, out MiNET.Player p)) { LevelEntityAddedEvent addedEvent = new LevelEntityAddedEvent(this, p); EventDispatcher.DispatchEventAsync(addedEvent); } }
public void PM(Player source, string[] arguments) { if (arguments.Length >= 2) { Player target = getPlayer(arguments[0], source); if (target != source) { string message = string.Empty; for (int i = 1; i < arguments.Length; i++) { message += arguments[i]; } target.SendMessage("[MailPE] " + source.Username + ": " + message); source.SendMessage("[MailPE] Message to " + target.Username + " was sent!"); } else { source.SendMessage("[MailPE] Player not found!"); } } else { source.SendMessage("[MailPE] Wrong command usage!"); } }
protected override void BroadCastMovement(Player[] players, Player[] updatedPlayers) { if (updatedPlayers.Length == 0) return; var moveEntity = McpeMoveEntity.CreateObject(players.Count()); moveEntity.entities = new EntityLocations(); //var rotateHead = McpeRotateHead.CreateObject(players.Count()); //rotateHead.entities = new EntityHeadRotations(); foreach (var player in updatedPlayers) { Entity entity; if (!_playerEntities.TryGetValue(player, out entity)) continue; entity.KnownPosition = (PlayerLocation) player.KnownPosition.Clone(); if (entity.EntityTypeId == 10) { //BUG: Duck has it's value reversed entity.KnownPosition.Pitch = -player.KnownPosition.Pitch; } moveEntity.entities.Add(entity.EntityId, entity.KnownPosition); //rotateHead.entities.Add(entity.EntityId, entity.KnownPosition); } moveEntity.Encode(); //rotateHead.Encode(); new Task(() => RelayBroadcast(moveEntity)).Start(); //new Task(() => RelayBroadcast(rotateHead)).Start(); }
public override Level GetLevel(MiNET.Player player, string levelId) { OpenLevel level; if (_levels.TryGetValue(levelId, out level)) { return(level); } string newLevelid; if (levelId.Equals(_defaultLevel, StringComparison.InvariantCultureIgnoreCase)) { newLevelid = levelId; } else { newLevelid = GetLevelId(levelId); } var worldProvider = new AnvilWorldProvider(); var openLevel = new OpenLevel(Api, this, newLevelid, worldProvider, EntityManager, _gameMode, _difficulty, _viewDistance) { EnableBlockTicking = _enableBlockTicking, EnableChunkTicking = _enableChunkTicking }; LoadLevel(openLevel); return(openLevel); }
public Package PlayerJoin(McpeLogin package, Player player) { if (!_notdefaultlevel) { player.Level.BlockBreak += OnBreak; player.Level.BlockPlace += OnPlace; _notdefaultlevel = true; } if (!(_registerlist.Contains(player.User))) { player.AddPopup(new Popup() { Message = "Используй /reg [пароль] для регистрации", MessageType = MessageType.Popup }); } else { player.User = _registerlist.Find(t => t.UserName == player.Username); if (!player.User.IsAuthenticated) player.AddPopup(new Popup() { Message = "Используй /auth [пароль] чтобы войти", MessageType = MessageType.Popup }); } return package; }
public Package PlayerDisconnect(McpeDisconnect package, Player player) { if (_registerlist.Contains(player.User)) { player.User.IsAuthenticated = false; } return package; }
public override void RemovePlayer(Player player, bool despawn = true) { base.RemovePlayer(player, despawn); Entity entity; if (!_playerEntities.TryGetValue(player, out entity)) return; entity.DespawnEntity(); }
public void F**k(Player player) { //player.SendSetHealth(); player.Level.BroadcastMessage(string.Format("{0} current health is {1} with {2} hearts!", player.Username, player.HealthManager.Health, player.HealthManager.Hearts), type: MessageType.Raw); player.HealthManager.Health -= 5; player.SendSetHealth(); player.Level.BroadcastMessage(string.Format("{0} health after reset is {1} with {2} hearts!", player.Username, player.HealthManager.Health, player.HealthManager.Hearts), type: MessageType.Raw); }
public Pet(Player owner, Level level, int id = 12) : base(id, level) { IsBaby = true; IsInRage = false; Owner = owner; HealthManager = new PetHealthManager(this); Age = 0; }
public PlayerInventory(Player player) { Player = player; Slots = Enumerable.Repeat(new ItemStack(), InventorySize).ToList(); //Slots = Enumerable.Repeat(new ItemStack(new ItemIronSword(0), 1), InventorySize).ToList(); //Slots[Slots.Count-10] = new ItemStack(new ItemDiamondAxe(0), 1); //Slots[Slots.Count-9] = new ItemStack(new ItemDiamondAxe(0), 1); //int c = -1; //Slots[++c] = new ItemStack(new ItemIronSword(0), 1); //Slots[++c] = new ItemStack(new ItemBow(0), 1); //Slots[++c] = new ItemStack(new ItemSnowball(0), 64); //Slots[++c] = new ItemStack(new ItemEgg(0), 64); //Slots[++c] = new ItemStack(262, 32); //Slots[++c] = new ItemStack(new ItemBucket(10), 1); //Slots[++c] = new ItemStack(new ItemChest(0), 1); ////Slots[++c] = new ItemStack(new ItemBlock(new DiamondOre(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new GoldBlock(), 0), 64); //Slots[++c] = new ItemStack(new ItemBlock(new CoalBlock(), 0), 64); //Slots = new List<ItemStack>(); //for (int i = 0; i < 100; i++) //{ // Slots.Add(new ItemStack(ItemFactory.GetItem(i, 0), 1)); //} ItemHotbar = new int[HotbarSize]; InHandSlot = 0; for (byte i = 0; i < ItemHotbar.Length; i++) { ItemHotbar[i] = i; } Boots = new Item(0, 0); Leggings = new Item(0, 0); Chest = new Item(0, 0); Helmet = new Item(0, 0); //Boots = new ItemDiamondBoots(0); //Leggings = new ItemDiamondLeggings(0); //Chest = new ItemDiamondChestplate(0); //Helmet = new ItemDiamondHelmet(0); }
public Package AddPlayerHandler(McpeAddPlayer packet, Player player) { if (_playerEntities.Keys.FirstOrDefault(p => p.EntityId == packet.entityId) != null) { return null; } return packet; }
public void SetSlot(Player player, byte slot, ItemStack itemStack) { Slots[slot] = new MetadataSlot(itemStack); NbtCompound compound = BlockEntity.GetCompound(); compound["Items"] = GetSlots(); OnInventoryChange(player, slot, itemStack); }
private Player getPlayer(string name, Player source) { foreach (var user in source.Level.Players) { if (user.Username.Contains(name)) { return user; } } return source; }
public void SetHome(Player player, Level level, string[] args) { if (args.Length > 0) { } else { } }
public void SetHome(Player source, string[] arguments) { if (PluginGlobals.Homes.ContainsKey(source)) { PluginGlobals.Homes.Remove(source); } PlayerLocation p = source.KnownPosition; p.Y += 2; //Do not spawn underground.... PluginGlobals.Homes.Add(source, p); source.SendMessage("[SetHome] Home set!"); }
public virtual Level GetLevel(Player player, string name) { Level level = Levels.FirstOrDefault(l => l.LevelId.Equals(name, StringComparison.InvariantCultureIgnoreCase)); if (level == null) { level = new Level(name); level.Initialize(); Levels.Add(level); } return level; }
public void Awk(Player player) { string awk = "[" + ChatColors.DarkRed + "AWK" + ChatFormatting.Reset + "]"; if (player.NameTag.StartsWith(awk)) { player.SetNameTag(player.Username);; } else { player.SetNameTag(awk + player.Username); } }
public void Human(Player player, string name) { //TODO: Fix space in pets name, too difficult damn.. PlayerMob p = new PlayerMob(name, player.Level) { NameTag = name, KnownPosition = (PlayerLocation)player.KnownPosition.Clone() }; p.SpawnEntity(); //}); }
// public void OnEnable(PluginContext context) { context.PluginManager.LoadCommands(new SkyCommands(this)); //Initialize Generic Commands context.PluginManager.LoadCommands(Permissions); //Initialize Permission Commands context.PluginManager.LoadCommands(new GameCommands()); //Initialize GameController Commands (/gameedit) context.PluginManager.LoadCommands(new Whitelist()); //Initialize Whitelist Commands (/whitelist) //Register listeners context.Server.PlayerFactory.PlayerCreated += (sender, args) => { _shouldSchedule = false; //Avoid scheduling pending tasks once a player has joined MiNET.Player player = args.Player; player.PlayerLeave += OnPlayerLeave; if (_pendingTasks.Count > 0) { foreach (PendingTask pendingTask in _pendingTasks) { RunnableTask.RunTaskLater(() => { try { pendingTask.Invoke(); } catch (Exception e) { BugSnagUtil.ReportBug(e, new AnonMetadatable((metadata) => { metadata.AddToTab("PendingTask", "Target", pendingTask.Target); metadata.AddToTab("PendingTask", "Method", pendingTask.Method); })); } }, 5000); } _pendingTasks.Clear(); } }; //Trigger any post-launch tasks that cannot be run during startup foreach (GameController coreGameController in GameModes.Values) { coreGameController.PostLaunchTask(); } //Start RestartHandler for Automatic Reboots RestartHandler.Start(); SkyUtil.log("Initialized!"); }
public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face) { Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign; if (signEntity == null) return false; string world = signEntity.Text1; if (player.Level.LevelId.Equals(world)) return true; _gameManager.Join(player, world); _gameManager.RegisterSign(signEntity, currentLevel); return true; }
public void Awk(Player player) { string awk = "[" + ChatColors.DarkRed + "AWK" + ChatFormatting.Reset + "]"; if (player.NameTag.StartsWith(awk)) { player.NameTag = player.Username; } else { player.NameTag = awk + player.Username; } player.BroadcastSetEntityData(); }
public Package HandleIncoming(McpeMovePlayer packet, Player player) { if (_playerEntities.ContainsKey(player)) { var entity = _playerEntities[player]; entity.KnownPosition = player.KnownPosition; var message = new McpeMoveEntity(); message.entities = new EntityLocations(); message.entities.Add(entity.EntityId, entity.KnownPosition); player.Level.RelayBroadcast(message); } return packet; // Process }
//DOESN'T WORK BUT WOULD BE BENEFICIAL /*public override MiNET.Worlds.Level GetLevel(MiNET.Player player, string name) * { * MiNET.Worlds.Level level; * * //'Get Default World' - Find a game for the player * if (name.Equals(Dimension.Overworld.ToString())) * { * //SkyUtil.log("Instantly queuing player using default GetLevel"); * * level = SkyCoreApi.GameModes[SkyCoreApi.GameType].InstantQueuePlayer(player as SkyPlayer, false); * if (level != null) * { * return level; * } * * BugSnagUtil.ReportBug(new Exception($"No initial entry world found for {player.Username}"), player as SkyPlayer, player.Level as GameLevel); * } * * //Select the first level in the collection * level = Levels.FirstOrDefault(l => l.LevelId.Equals(name, StringComparison.InvariantCultureIgnoreCase)); * if (level == null && name.Equals(Dimension.Overworld.ToString())) * { * level = Levels[0]; * } * * return level; * }*/ public override MiNET.Worlds.Level GetLevel(MiNET.Player player, string name) { //'Get Default World' - Find a game for the player if (name.Equals(Dimension.Overworld.ToString())) { //SkyUtil.log("Instantly queuing player using default GetLevel"); return(SkyCoreApi.GameModes[SkyCoreApi.GameType].InstantQueuePlayer(player as SkyPlayer, false)); } else { return(Levels.FirstOrDefault(l => l.LevelId.Equals(name, StringComparison.InvariantCultureIgnoreCase))); } }
public void GameMode(Player player, int gameMode) { player.SendPackage(new McpeStartGame { seed = -1, generator = 1, gamemode = gameMode, entityId = player.EntityId, spawnX = player.Level.SpawnPoint.X, spawnY = player.Level.SpawnPoint.Y, spawnZ = player.Level.SpawnPoint.Z, x = player.KnownPosition.X, y = player.KnownPosition.Y, z = player.KnownPosition.Z }); }
public Package MessageHandler(McpeText message, MiNET.Player player) { string text = message.message; if (text.StartsWith("/")) { return(message); } if (player is SkyPlayer skyPlayer && skyPlayer.Level is GameLevel level) { level.CurrentState.HandlePlayerChat(skyPlayer, text); } return(null); }
//public void Pet(Player player, string type) public void Pet(Player player, string type, params string[] name) { //TODO: Fix space in pets name, too difficult damn.. PetTypes petType; try { petType = (PetTypes) Enum.Parse(typeof (PetTypes), type, true); } catch (ArgumentException e) { return; } if (!Enum.IsDefined(typeof (PetTypes), petType)) { player.SendMessage("No pet found"); return; } string petName = null; if (name.Length > 0) { petName = string.Join(" ", name); } var entities = player.Level.GetEntites(); foreach (var entity in entities) { Pet pet = entity as Pet; if (pet != null && pet.Owner == player) { pet.HealthManager.Kill(); break; } } //ThreadPool.QueueUserWorkItem(delegate(object state) //{ Pet newPet = new Pet(player, player.Level, (int) petType) { NameTag = petName, KnownPosition = (PlayerLocation) player.KnownPosition.Clone() }; newPet.SpawnEntity(); //}); }
public PlayerInventory(Player player) { Player = player; Slots = Enumerable.Repeat(new ItemStack(), 35).ToList(); ItemHotbar = new int[6]; ItemInHand = new Item(-1, 0); Boots = new ItemDiamondBoots(0); Leggings = new ItemDiamondLeggings(0); Chest = new ItemDiamondChestplate(0); Helmet = new ItemDiamondHelmet(0); for (byte i = 0; i < 6; i++) { ItemHotbar[i] = i + 9; } }
public SkyPlayer GetPlayer(string username) { username = username.ToLower(); MiNET.Player foundPlayer = null; foreach (Level level in Server.LevelManager.Levels) { foreach (MiNET.Player player in level.Players.Values) { if (player.Username.ToLower().Equals(username)) { foundPlayer = player; } } } return((SkyPlayer)foundPlayer); }
public void Auth(Player player, string password) { if (!_registerlist.Contains(player.User)) { player.User.IsAuthenticated = player.User.PasswordHash == GetPasswordHash(password); player.ClearPopups(); player.AddPopup(new Popup() { Message = ChatColors.Green + "Добро пожаловать назад!.", Duration = 20 * 10, MessageType = MessageType.Popup }); } else { player.SendMessage(ChatColors.Red + "Вы не зарегистрированы!!"); } }
public PlayerInventory(Player player) { _player = player; Armor = new MetadataSlots(); Slots = new MetadataSlots(); ItemHotbar = new MetadataInts(); ItemInHand = new MetadataSlot(new ItemStack()); Armor[0] = new MetadataSlot(new ItemStack()); Armor[1] = new MetadataSlot(new ItemStack()); Armor[2] = new MetadataSlot(new ItemStack()); Armor[3] = new MetadataSlot(new ItemStack()); //Armor[0] = new MetadataSlot(new ItemStack(306)); //Armor[1] = new MetadataSlot(new ItemStack(307)); //Armor[2] = new MetadataSlot(new ItemStack(308)); //Armor[3] = new MetadataSlot(new ItemStack(309)); for (byte i = 0; i < 35; i++) { Slots[i] = new MetadataSlot(new ItemStack((short)-1, 0)); } byte c = 0; //Slots[c++] = new MetadataSlot(new ItemStack(383, 1, 34)); //Slots[c++] = new MetadataSlot(new ItemStack(355, 64)); //Slots[c++] = new MetadataSlot(new ItemStack(261, 1)); // Bow //Slots[c++] = new MetadataSlot(new ItemStack(262, 64)); // Arrows //Slots[c++] = new MetadataSlot(new ItemStack(344, 64)); // Eggs //Slots[c++] = new MetadataSlot(new ItemStack(332, 64)); // Snowballs //Slots[c++] = new MetadataSlot(new ItemStack(46, 64)); //Slots[c++] = new MetadataSlot(new ItemStack(259, 1)); //Slots[c++] = new MetadataSlot(new ItemStack(268, 1)); //Slots[c++] = new MetadataSlot(new ItemStack(280, 10)); //Slots[c++] = new MetadataSlot(new ItemStack(290, 1)); //Slots[c++] = new MetadataSlot(new ItemStack(259, 1)); // Flint/Steal //Slots[c++] = new MetadataSlot(new ItemStack(325, 64, 8)); // Water //Slots[c++] = new MetadataSlot(new ItemStack(325, 64, 10)); // Lava for (byte i = 0; i < 6; i++) { ItemHotbar[i] = new MetadataInt(i + 9); } }
public override void AddPlayer(Player newPlayer, string broadcastText = null, bool spawn = true) { base.AddPlayer(newPlayer, broadcastText, false); Mob entity = new Mob(new Random().Next(10, 16), this) // Passive mobs //Mob entity = new Mob(new Random().Next(32, 39), this) // Hostile mobs { KnownPosition = newPlayer.KnownPosition, //Data = -(blockId | 0 << 0x10) }; entity.SpawnEntity(); // Despawn the new entity from the player himeself newPlayer.SendPackage(new McpeRemoveEntity() { entityId = entity.EntityId, }); _playerEntities.Add(newPlayer, entity); }
public override Level GetLevel(MiNET.Player player, string levelId) { OpenLevel level; if (_levels.TryGetValue(levelId, out level)) { return(level); } string newLevelid; if (levelId.Equals(_defaultLevel, StringComparison.InvariantCultureIgnoreCase)) { newLevelid = levelId; } else { newLevelid = GetLevelId(levelId); } /*var worldProvider = new WrappedAnvilWorldProvider(Api) * { * MissingChunkProvider = new FlatlandWorldProvider(), * ReadSkyLight = _readSkyLight, * ReadBlockLight = _readBlockLight * };*/var worldProvider = new AnvilWorldProvider(); var openLevel = new OpenLevel(Api /*, Api.EventDispatcher*/, this, newLevelid, worldProvider, EntityManager, _gameMode, _difficulty, _viewDistance) { EnableBlockTicking = _enableBlockTicking, EnableChunkTicking = _enableChunkTicking, // IsWorldTimeStarted = _isWorldTimeStarted }; LoadLevel(openLevel); return(openLevel); }
public string GetNameTag(MiNET.Player player) { string username = player.Username; string rank; if (player is SkyPlayer skyPlayer) { rank = skyPlayer.PlayerGroup.Prefix; } else { rank = SkyCoreApi.Permissions.GetPlayerGroup(player.Username).Prefix; } if (rank.Length > 2) { rank += " "; } return($"{rank}{username}"); }
public override void RemovePlayer(MiNET.Player player, bool despawn = true) { if (player == null || player.EntityId == null) { return; } if (Players == null) { Log.Warn("OpenLevel.Players is null!"); return; } if (Players.ContainsKey(player.EntityId)) { base.RemovePlayer(player, despawn); if (!Players.ContainsKey(player.EntityId)) { LevelEntityRemovedEvent removedEvent = new LevelEntityRemovedEvent(this, player); EventDispatcher.DispatchEventAsync(removedEvent); } } }
public SkyPlayerInventory(MiNET.Player player) : base(player) { }
public static void SendCenteredSubtitle(MiNET.Player player, string content, bool centerText = true) { SendCenteredSubtitle(player, content, centerText, 5, 5, 100); }
protected virtual void OnInventoryChange(Player player, byte slot, Item itemStack) { InventoryChange?.Invoke(player, this, slot, itemStack); }
public GunProjectile(MiNET.Player shooter, MiNET.Worlds.Level level, int damage = 2, bool isCritical = false) : base(shooter, level, damage, isCritical) { }
public void AddObserver(Player player) { Observers.Add(player); }
public void RemoveObserver(Player player) { // Need to arrange for this to work when players get disconnected // from crash. It will leak players for sure. Observers.TryTake(out player); }
public void SendLocalizedMessage(string text, object[] parameters = null, MessageType type = MessageType.Chat, MiNET.Player sender = null) { base.SendMessage(this.GetLocalizedMessage(LocaleManager.GetLocaleProvider(Assembly.GetCallingAssembly()), text, parameters), type, sender); }
public void SendLocalizedTitle(string text, object[] parameters = null, TitleType type = TitleType.Title, int fadeIn = 6, int fadeOut = 6, int stayTime = 20, MiNET.Player sender = null) { SendTitle(this.GetLocalizedMessage(LocaleManager.GetLocaleProvider(Assembly.GetCallingAssembly()), text, parameters), type, fadeIn, fadeOut, stayTime, sender); }
public override void BroadcastMessage(string text, MessageType type = MessageType.Chat, MiNET.Player sender = null, MiNET.Player[] sendList = null, bool needsTranslation = false, string[] parameters = null) { if (type == MessageType.Chat || type == MessageType.Raw) { foreach (var line in text.Split(new[] { "\n", Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) { string sen = sender == null ? "" : (sender.DisplayName ?? sender.Username) + ": "; McpeText message = McpeText.CreateObject(); message.type = 0; message.source = ""; //sender == null ? "" : (sender.DisplayName ?? sender.Username); message.message = $"{sen}{line}"; //message.parameters = new string[0]; // message.islocalized = false; RelayBroadcast(sendList, message); } return; } else { McpeText message = McpeText.CreateObject(); message.type = (byte)type; message.source = sender == null ? "" : sender.Username; message.message = text; // message.parameters = new string[0]; // message.islocalized = false; RelayBroadcast(sendList, message); } }
public SkyFoodManager(MiNET.Player player) : base(player) { }