public void SendAvailableCommands() { AvailableCommandsPacket availableCommandsPacket = new AvailableCommandsPacket { Commands = MineNET_Registries.Command.ToDictionary() }; this.SendPacket(availableCommandsPacket); }
private void ResourcePackClientResponsePacketHandle(ResourcePackClientResponsePacket pk) { if (this.PackSyncCompleted) { return; } else if (pk.ResponseStatus == ResourcePackClientResponsePacket.STATUS_REFUSED) { this.Close("disconnectionScreen.resourcePackn"); } else if (pk.ResponseStatus == ResourcePackClientResponsePacket.STATUS_SEND_PACKS) { //TODO: ResourcePackDataInfoPacket } else if (pk.ResponseStatus == ResourcePackClientResponsePacket.STATUS_HAVE_ALL_PACKS) { ResourcePackStackPacket resourcePackStackPacket = new ResourcePackStackPacket(); this.SendPacket(resourcePackStackPacket); this.HaveAllPacks = true; } else if (pk.ResponseStatus == ResourcePackClientResponsePacket.STATUS_COMPLETED && this.HaveAllPacks) { this.PackSyncCompleted = true; if (this.IsLogined) { return; } PlayerLoginEventArgs playerLoginEvent = new PlayerLoginEventArgs(this, ""); PlayerEvents.OnPlayerLogin(playerLoginEvent); if (playerLoginEvent.IsCancel) { this.Close(playerLoginEvent.KickMessage); return; } this.IsLogined = true; //if (World.Exists(worldName)) //{ // this.World = World.GetWorld(worldName); //} //else //{ this.World = World.GetMainWorld(); //} this.LoadData(); if (this.X == 0 && this.Y == 0 && this.Z == 0) { this.X = this.World.SpawnPoint.FloorX; this.Y = this.World.SpawnPoint.FloorY; this.Z = this.World.SpawnPoint.FloorZ; } StartGamePacket startGamePacket = new StartGamePacket(); startGamePacket.EntityUniqueId = this.EntityID; startGamePacket.EntityRuntimeId = this.EntityID; startGamePacket.PlayerGamemode = this.GameMode; startGamePacket.PlayerPosition = new Vector3(this.X, this.Y, this.Z); startGamePacket.Direction = new Vector2(this.Yaw, this.Pitch); startGamePacket.WorldGamemode = this.World.DefaultGameMode.GameModeToInt(); startGamePacket.Difficulty = this.World.Difficulty; startGamePacket.SpawnX = this.World.SpawnPoint.FloorX; startGamePacket.SpawnY = this.World.SpawnPoint.FloorY; startGamePacket.SpawnZ = this.World.SpawnPoint.FloorZ; startGamePacket.WorldName = this.World.Name; this.SendPacket(startGamePacket); this.SendPlayerAttribute(); AvailableCommandsPacket availableCommandsPacket = new AvailableCommandsPacket(); availableCommandsPacket.commands = Server.Instance.CommandManager.CommandList; this.SendPacket(availableCommandsPacket); this.Inventory.SendContents(); this.Inventory.ArmorInventory.SendContents(); this.Inventory.SendCreativeItems(); this.Inventory.SendMainHand(this); PlayerJoinEventArgs playerJoinEvent = new PlayerJoinEventArgs(this, $"§e{this.Name} が世界にやってきました", ""); PlayerEvents.OnPlayerJoin(playerJoinEvent); if (playerJoinEvent.IsCancel) { this.Close(playerJoinEvent.KickMessage); return; } if (!string.IsNullOrEmpty(playerJoinEvent.JoinMessage)) { Server.Instance.BroadcastMessage(playerJoinEvent.JoinMessage); } Logger.Info($"§e{this.Name} join the game"); this.SendPlayStatus(PlayStatusPacket.PLAYER_SPAWN); this.HasSpawned = true; GameRules rules = new GameRules(); rules.Add(new GameRule <bool>("ShowCoordinates", true)); GameRulesChangedPacket gameRulesChangedPacket = new GameRulesChangedPacket(); gameRulesChangedPacket.GameRules = rules; this.SendPacket(gameRulesChangedPacket); this.PlayerListEntry = new PlayerListEntry(this.LoginData.ClientUUID, this.EntityID, this.Name, this.ClientData.DeviceOS, this.ClientData.Skin, this.LoginData.XUID); AdventureSettingsEntry adventureSettingsEntry = new AdventureSettingsEntry(); adventureSettingsEntry.SetFlag(AdventureSettingsPacket.WORLD_IMMUTABLE, false); adventureSettingsEntry.SetFlag(AdventureSettingsPacket.NO_PVP, false); adventureSettingsEntry.SetFlag(AdventureSettingsPacket.AUTO_JUMP, false); adventureSettingsEntry.SetFlag(AdventureSettingsPacket.ALLOW_FLIGHT, true); adventureSettingsEntry.SetFlag(AdventureSettingsPacket.NO_CLIP, false); adventureSettingsEntry.SetFlag(AdventureSettingsPacket.FLYING, false); adventureSettingsEntry.CommandPermission = this.Op ? PlayerPermissions.OPERATOR : PlayerPermissions.MEMBER; adventureSettingsEntry.PlayerPermission = this.Op ? PlayerPermissions.OPERATOR : PlayerPermissions.MEMBER; adventureSettingsEntry.EntityUniqueId = this.EntityID; this.AdventureSettingsEntry = adventureSettingsEntry; this.SendSkin(this.Skin); Server.Instance.AddPlayer(this); this.World.AddPlayer(this); this.SendDataProperties(); Server.Instance.CraftingManager.SendPacket(this); } }