public MinecraftServer() { Log.Info("Initializing..."); MCPacketFactory.Load(); Server = new NetServer(new NetConfiguration() { Host = IPAddress.Any, Port = 25565, Protocol = ProtocolType.Tcp }); Server.NetConnectionFactory = new ConnectionFactory(this); PlayerFactory = new DefaultPlayerFactory(this); LevelManager = new LevelManager(); //Cache the level LevelManager.GetLevel(null, "default"); Info = new ServerInfo(this); Log.Info("Generating RSA keypair..."); //RsaEncryption = null; RsaEncryption = new EncryptionHolder(); }
private void InitializeGame(IProgressReceiver progressReceiver) { progressReceiver.UpdateProgress(0, "Initializing..."); API.Extensions.Init(GraphicsDevice); MCPacketFactory.Load(); //ConfigureServices(); var eventDispatcher = Services.GetRequiredService <IEventDispatcher>() as EventDispatcher; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { eventDispatcher.LoadFrom(assembly); } //var options = Services.GetService<IOptionsProvider>(); // Log.Info($"Loading resources..."); if (!Resources.CheckResources(GraphicsDevice, progressReceiver, OnResourcePackPreLoadCompleted)) { Console.WriteLine("Press enter to exit..."); Console.ReadLine(); Exit(); return; } var profileManager = Services.GetService <ProfileManager>(); profileManager.LoadProfiles(progressReceiver); //GuiRenderer.LoadResourcePack(Resources.ResourcePack, null); AnvilWorldProvider.LoadBlockConverter(); PluginManager.EnablePlugins(); var storage = Services.GetRequiredService <IStorageSystem>(); if (storage.TryReadJson("skin.json", out EntityModel model)) { PlayerModel = model; } if (storage.TryReadBytes("skin.png", out byte[] skinBytes))
private void InitializeGame(IProgressReceiver progressReceiver) { progressReceiver.UpdateProgress(0, "Initializing..."); API.Extensions.Init(GraphicsDevice); MCPacketFactory.Load(); //ConfigureServices(); var eventDispatcher = Services.GetRequiredService <IEventDispatcher>() as EventDispatcher; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { eventDispatcher.LoadFrom(assembly); } var options = Services.GetService <IOptionsProvider>(); string pluginDirectoryPaths = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var pluginDir = options.AlexOptions.ResourceOptions.PluginDirectory; if (!string.IsNullOrWhiteSpace(pluginDir)) { pluginDirectoryPaths = pluginDir; } else { if (!string.IsNullOrWhiteSpace(LaunchSettings.WorkDir) && Directory.Exists(LaunchSettings.WorkDir)) { pluginDirectoryPaths = LaunchSettings.WorkDir; } } foreach (string dirPath in pluginDirectoryPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { string directory = dirPath; if (!Path.IsPathRooted(directory)) { directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), dirPath); } PluginManager.DiscoverPlugins(directory); } var profileManager = Services.GetService <ProfileManager>(); // Log.Info($"Loading resources..."); if (!Resources.CheckResources(GraphicsDevice, progressReceiver, OnResourcePackPreLoadCompleted)) { Console.WriteLine("Press enter to exit..."); Console.ReadLine(); Exit(); return; } profileManager.LoadProfiles(progressReceiver); //GuiRenderer.LoadResourcePack(Resources.ResourcePack, null); AnvilWorldProvider.LoadBlockConverter(); PluginManager.EnablePlugins(); if (LaunchSettings.ModelDebugging) { GameStateManager.SetActiveState <ModelDebugState>(); } else { GameStateManager.SetActiveState <TitleState>("title"); // var player = new Player(GraphicsDevice, InputManager, null, null, new Skin(), null, PlayerIndex.One, null); // player.Inventory.IsPeInventory = true; /*Random rnd = new Random(); * for (int i = 0; i < player.Inventory.SlotCount; i++) * { * player.Inventory[i] = new ItemBlock(BlockFactory.AllBlockstates.ElementAt(rnd.Next() % BlockFactory.AllBlockstates.Count).Value) * { * Count = rnd.Next(1, 64) * }; * }*/ //GuiManager.ShowDialog(new GuiPlayerInventoryDialog(player, player.Inventory)); } GameStateManager.RemoveState("splash"); }
public ServerQueryProvider(Alex alex) { Alex = alex; MCPacketFactory.Load(); }
private void InitializeGame(IProgressReceiver progressReceiver) { progressReceiver.UpdateProgress(0, "Initializing..."); API.Extensions.Init(GraphicsDevice); MCPacketFactory.Load(); //ConfigureServices(); //var options = Services.GetService<IOptionsProvider>(); // Log.Info($"Loading resources..."); if (!Resources.CheckResources(GraphicsDevice, progressReceiver, OnResourcePackPreLoadCompleted)) { Console.WriteLine("Press enter to exit..."); Console.ReadLine(); Exit(); return; } var profileManager = Services.GetService <ProfileManager>(); profileManager.LoadProfiles(progressReceiver); //GuiRenderer.LoadResourcePack(Resources.ResourcePack, null); AnvilWorldProvider.LoadBlockConverter(); PluginManager.EnablePlugins(); var storage = Services.GetRequiredService <IStorageSystem>(); if (storage.TryReadString("skin.json", out var str, Encoding.UTF8)) { Dictionary <string, EntityModel> models = new Dictionary <string, EntityModel>(); BedrockResourcePack.LoadEntityModel(str, models); models = BedrockResourcePack.ProcessEntityModels(models); if (models.Count > 0) { if (models.TryGetValue("geometry.humanoid.custom", out var entityModel) || models.TryGetValue( "geometry.humanoid.customSlim", out entityModel)) { PlayerModel = entityModel; Log.Info($"Player model loaded..."); } } } if (PlayerModel == null) { if (ModelFactory.TryGetModel("geometry.humanoid.customSlim", out var model)) { //model.Name = "geometry.humanoid.customSlim"; PlayerModel = model; } } if (PlayerModel != null) { //Log.Info($"Player model loaded..."); } if (storage.TryReadBytes("skin.png", out byte[] skinBytes))
public JavaClient(JavaWorldProvider javaWorldProvider, Socket socket, DedicatedThreadPool networkPool) : base(PacketDirection.ClientBound, socket, null, networkPool) { MCPacketFactory.Load(); JavaWorld = javaWorldProvider; WorldReceiver = javaWorldProvider; }
private void InitializeGame(IProgressReceiver progressReceiver) { progressReceiver.UpdateProgress(0, "Initializing..."); API.Extensions.Init(GraphicsDevice); MCPacketFactory.Load(); //ConfigureServices(); var eventDispatcher = Services.GetRequiredService <IEventDispatcher>() as EventDispatcher; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { eventDispatcher.LoadFrom(assembly); } //var options = Services.GetService<IOptionsProvider>(); // Log.Info($"Loading resources..."); if (!Resources.CheckResources(GraphicsDevice, progressReceiver, OnResourcePackPreLoadCompleted)) { Console.WriteLine("Press enter to exit..."); Console.ReadLine(); Exit(); return; } var profileManager = Services.GetService <ProfileManager>(); profileManager.LoadProfiles(progressReceiver); //GuiRenderer.LoadResourcePack(Resources.ResourcePack, null); AnvilWorldProvider.LoadBlockConverter(); PluginManager.EnablePlugins(); var storage = Services.GetRequiredService <IStorageSystem>(); if (storage.TryReadString("skin.json", out var str, Encoding.UTF8)) { //var entries = new Dictionary<string, EntityModel>(); //EntityModel.GetEntries(str, entries); var geometryModel = MCJsonConvert.DeserializeObject <GeometryModel>(str); var model = geometryModel.FindGeometry("geometry.humanoid.custom"); if (model == null) { model = geometryModel.FindGeometry("geometry.humanoid.customSlim"); } if (model != null) { PlayerModel = model; } } if (PlayerModel == null) { if (ModelFactory.TryGetModel("geometry.humanoid.customSlim", out var model)) { model.Name = "geometry.humanoid.customSlim"; PlayerModel = model; } } if (PlayerModel != null) { Log.Info($"Player model loaded..."); } if (storage.TryReadBytes("skin.png", out byte[] skinBytes))
public JavaClient(JavaWorldProvider javaWorldProvider, Socket socket) : base(Direction.ClientBound, socket, null, null) { MCPacketFactory.Load(); WorldReceiver = javaWorldProvider; }
private void InitializeGame(IProgressReceiver progressReceiver) { progressReceiver.UpdateProgress(0, "Initializing..."); API.Extensions.Init(GraphicsDevice); MCPacketFactory.Load(); //ConfigureServices(); var eventDispatcher = Services.GetRequiredService <IEventDispatcher>() as EventDispatcher; foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) { eventDispatcher.LoadFrom(assembly); } var options = Services.GetService <IOptionsProvider>(); string pluginDirectoryPaths = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var pluginDir = options.AlexOptions.ResourceOptions.PluginDirectory; if (!string.IsNullOrWhiteSpace(pluginDir)) { pluginDirectoryPaths = pluginDir; } else { if (!string.IsNullOrWhiteSpace(LaunchSettings.WorkDir) && Directory.Exists(LaunchSettings.WorkDir)) { pluginDirectoryPaths = LaunchSettings.WorkDir; } } foreach (string dirPath in pluginDirectoryPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { string directory = dirPath; if (!Path.IsPathRooted(directory)) { directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), dirPath); } PluginManager.DiscoverPlugins(directory); } var profileManager = Services.GetService <ProfileManager>(); // Log.Info($"Loading resources..."); if (!Resources.CheckResources(GraphicsDevice, progressReceiver, OnResourcePackPreLoadCompleted)) { Console.WriteLine("Press enter to exit..."); Console.ReadLine(); Exit(); return; } profileManager.LoadProfiles(progressReceiver); //GuiRenderer.LoadResourcePack(Resources.ResourcePack, null); AnvilWorldProvider.LoadBlockConverter(); PluginManager.EnablePlugins(); var storage = Services.GetRequiredService <IStorageSystem>(); if (storage.TryReadJson("skin.json", out EntityModel model)) { PlayerModel = model; } if (storage.TryReadBytes("skin.png", out byte[] skinBytes))
private void InitializeGame(IProgressReceiver progressReceiver) { progressReceiver.UpdateProgress(0, "Initializing..."); Extensions.Init(GraphicsDevice); MCPacketFactory.Load(); ConfigureServices(); var options = Services.GetService <IOptionsProvider>(); string pluginDirectoryPaths = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath); var pluginDir = options.AlexOptions.ResourceOptions.PluginDirectory; if (!string.IsNullOrWhiteSpace(pluginDir)) { pluginDirectoryPaths = pluginDir; } else { if (!string.IsNullOrWhiteSpace(LaunchSettings.WorkDir) && Directory.Exists(LaunchSettings.WorkDir)) { pluginDirectoryPaths = LaunchSettings.WorkDir; } } foreach (string dirPath in pluginDirectoryPaths.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { string directory = dirPath; if (!Path.IsPathRooted(directory)) { directory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), dirPath); } PluginManager.DiscoverPlugins(directory); } ProfileManager.LoadProfiles(progressReceiver); // Log.Info($"Loading resources..."); Resources = new ResourceManager(GraphicsDevice, Storage, options); if (!Resources.CheckResources(GraphicsDevice, progressReceiver, OnResourcePackPreLoadCompleted)) { Console.WriteLine("Press enter to exit..."); Console.ReadLine(); Exit(); return; } GuiRenderer.LoadResourcePack(Resources.ResourcePack); AnvilWorldProvider.LoadBlockConverter(); GameStateManager.AddState <TitleState>("title"); if (LaunchSettings.ConnectOnLaunch && ProfileService.CurrentProfile != null) { ConnectToServer(LaunchSettings.Server, ProfileService.CurrentProfile, LaunchSettings.ConnectToBedrock); } else { GameStateManager.SetActiveState <TitleState>("title"); var player = new Player(GraphicsDevice, this, null, null, new Skin(), null, PlayerIndex.One); player.Inventory.IsPeInventory = true; Random rnd = new Random(); for (int i = 0; i < player.Inventory.SlotCount; i++) { player.Inventory[i] = new ItemBlock(BlockFactory.AllBlockstates.ElementAt(rnd.Next() % BlockFactory.AllBlockstates.Count).Value) { Count = rnd.Next(1, 64) }; } //GuiManager.ShowDialog(new GuiPlayerInventoryDialog(player, player.Inventory)); } GameStateManager.RemoveState("splash"); }