示例#1
0
        public Item GetItem(short id, short metadata = 0, int count = 1)
        {
            Item item = null;

            if (id == 280)
            {
                item = new ItemStick();
            }
            else if (id == 332)
            {
                item = new ItemSnowball();
            }
            else if (id == 333)
            {
                item = new ItemBoat(metadata);
            }
            else if (id == 340)
            {
                item = new ItemBook();
            }
            else if (id == 344)
            {
                item = new ItemEgg();
            }

            else if (id == 401)
            {
                item = new ItemFireworks();
            }

            item.Metadata = metadata;
            item.Count    = (byte)count;

            return(item);
        }
示例#2
0
        public void NbtCheckPerformanceTests()
        {
            var firework = new ItemFireworks();

            firework.ExtraData = ItemFireworks.ToNbt(new ItemFireworks.FireworksData()
            {
                Explosions = new List <ItemFireworks.FireworksExplosion>()
                {
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)0 },
                        FireworkFade    = new[] { (byte)1 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 0,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)1 },
                        FireworkFade    = new[] { (byte)2 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 1,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)2 },
                        FireworkFade    = new[] { (byte)3 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 2,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)3 },
                        FireworkFade    = new[] { (byte)4 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 3,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)4 },
                        FireworkFade    = new[] { (byte)5 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 4,
                    }
                },
                Flight = 2
            });

            for (var i = 0; i < 10000; i++)
            {
                Assert.AreEqual(firework.Equals(firework), true);
            }
        }
示例#3
0
        private void OnPlayerJoin(object o, PlayerEventArgs eventArgs)
        {
            Level level = eventArgs.Level;

            if (level == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Level));
            }

            Player player = eventArgs.Player;

            if (player == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Player));
            }

            if (player.CertificateData.ExtraData.Xuid != null && player.Username.Equals("gurunx"))
            {
                player.ActionPermissions = ActionPermissions.Operator;
                player.CommandPermission = 4;
                player.PermissionLevel   = PermissionLevel.Operator;
                player.SendAdventureSettings();
            }

            //player.HealthManager.MaxHealth = 800;
            //player.HealthManager.ResetHealth();
            //player.SendUpdateAttributes();


            int idx = 0;

            //player.Inventory.Slots[idx++] = new ItemMonsterEgg(EntityType.Sheep) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemMonsterEgg(EntityType.Wolf) {Count = 64};

            //player.Inventory.Slots[idx++] = new ItemEmptyMap()
            //{
            //	Count = 64,
            //	UniqueId = Environment.TickCount
            //};
            player.Inventory.Slots[idx++] = new ItemAir()
            {
                Count    = 0,
                UniqueId = 0
            };
            player.Inventory.Slots[idx++] = new ItemDiamondAxe()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemDiamondShovel()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemDiamondPickaxe()
            {
                Count = 1
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new CraftingTable())
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new Chest())
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new Anvil())
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new EnchantingTable())
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemBlock(new Loom())
            {
                Count = 64
            };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Sapling()) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Sapling(), 2) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Vine(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new SnowLayer()) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Dirt()) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new WoodenButton(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new CustomTestItem(0xC0FFEE) { Count = 1 };
            //player.Inventory.Slots[idx++] = new CustomTestItem(0xDEADBEEF) {Count = 10 };
            //player.Inventory.Slots[idx++] = new CustomTestItem(0xDEADBEEF) {Count = 10 };
            //player.Inventory.Slots[idx++] = new CustomTestItem(0xBEEF) {Count = 10 };
            idx = 8;
            player.Inventory.Slots[idx++] = new ItemStick()
            {
                Count = 64
            };

            var fireworks = new ItemFireworks()
            {
                Count = 64
            };

            fireworks.ExtraData = ItemFireworks.ToNbt(new ItemFireworks.FireworksData()
            {
                Explosions = new List <ItemFireworks.FireworksExplosion>()
                {
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)0 },
                        FireworkFade    = new[] { (byte)1 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 0,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)1 },
                        FireworkFade    = new[] { (byte)2 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 1,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)2 },
                        FireworkFade    = new[] { (byte)3 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 2,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)3 },
                        FireworkFade    = new[] { (byte)4 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 3,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)4 },
                        FireworkFade    = new[] { (byte)5 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 4,
                    }
                },
                Flight = 1
            });

            player.Inventory.Slots[idx++] = fireworks;
            //player.Inventory.Slots[idx++] = new ItemBread() {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemSnowball() {Count = 16};
            //player.Inventory.Slots[idx++] = new ItemBow() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemArrow() {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Torch(), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Stone(), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemWheat() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemCarrot() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemWheatSeeds() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemBone() {Count = 64};
            player.Inventory.Slots[idx++] = new ItemDye()
            {
                Metadata = 4,
                Count    = 64
            };
            player.Inventory.Slots[idx++] = new ItemIronIngot()
            {
                Count = 64
            };
            player.Inventory.Slots[idx++] = new ItemIronSword()
            {
                Count    = 1,
                Metadata = 0,
                UniqueId = Environment.TickCount
            };
            player.Inventory.Slots[idx++] = new ItemIronSword()
            {
                Count    = 1,
                Metadata = 0,
                UniqueId = Environment.TickCount
            };
            player.Inventory.Slots[idx++] = new ItemIronSword()
            {
                Count    = 1,
                Metadata = 0,
                UniqueId = Environment.TickCount
            };
            player.Inventory.Slots[idx++] = new ItemIronSword()
            {
                Count    = 1,
                Metadata = 0,
                UniqueId = Environment.TickCount
            };

            player.Inventory.Helmet = new ItemDiamondHelmet()
            {
                UniqueId = Environment.TickCount
            };
            player.Inventory.Chest = new ItemElytra()
            {
                UniqueId = Environment.TickCount
            };
            player.Inventory.Leggings = new ItemDiamondLeggings()
            {
                UniqueId = Environment.TickCount
            };
            player.Inventory.Boots = new ItemDiamondBoots()
            {
                UniqueId = Environment.TickCount
            };
            //while (player.Inventory.SetFirstEmptySlot(new ItemIronAxe(), false)) { }

            player.SendPlayerInventory();

            player.SendArmorForPlayer();
            player.SendEquipmentForPlayer();

            _players.TryAdd(player.Username, player);
        }
示例#4
0
        private void OnPlayerJoin(object o, PlayerEventArgs eventArgs)
        {
            Level level = eventArgs.Level;

            if (level == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Level));
            }

            Player player = eventArgs.Player;

            if (player == null)
            {
                throw new ArgumentNullException(nameof(eventArgs.Player));
            }

            if (player.CertificateData.ExtraData.Xuid != null && player.Username.Equals("gurunx"))
            {
                player.ActionPermissions = ActionPermissions.Operator;
                player.CommandPermission = 4;
                player.PermissionLevel   = PermissionLevel.Operator;
                player.SendAdventureSettings();
            }


            int idx = 0;

            //player.Inventory.Slots[idx++] = new ItemDiamondAxe() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemDiamondShovel() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemDiamondPickaxe() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Sapling(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Sapling(), 2) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Vine(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new Dirt(), 0) { Count = 64 };
            //player.Inventory.Slots[idx++] = new ItemBlock(new WoodenButton(), 0) { Count = 64 };
            idx = 8;
            player.Inventory.Slots[idx++] = new ItemStick()
            {
                Count = 64
            };

            var fireworks = new ItemFireworks()
            {
                Count = 64
            };

            fireworks.ExtraData = ItemFireworks.ToNbt(new ItemFireworks.FireworksData()

            {
                Explosions = new List <ItemFireworks.FireworksExplosion>()
                {
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)0 },
                        FireworkFade    = new[] { (byte)1 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 0,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)1 },
                        FireworkFade    = new[] { (byte)2 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 1,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)2 },
                        FireworkFade    = new[] { (byte)3 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 2,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)3 },
                        FireworkFade    = new[] { (byte)4 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 3,
                    },
                    new ItemFireworks.FireworksExplosion()
                    {
                        FireworkColor   = new[] { (byte)4 },
                        FireworkFade    = new[] { (byte)5 },
                        FireworkFlicker = true,
                        FireworkTrail   = false,
                        FireworkType    = 4,
                    }
                },
                Flight = 2
            });

            player.Inventory.Slots[idx++] = fireworks;
            //player.Inventory.Slots[idx++] = new ItemBread() {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemSnowball() {Count = 16};
            //player.Inventory.Slots[idx++] = new ItemBow() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemArrow() {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Torch(), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemBlock(new Stone(), 0) {Count = 64};
            //player.Inventory.Slots[idx++] = new ItemWheat() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemCarrot() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemWheatSeeds() {Count = 1};
            //player.Inventory.Slots[idx++] = new ItemBone() {Count = 64};

            //player.Inventory.Helmet = new ItemDiamondHelmet();
            player.Inventory.Chest = new ItemElytra();
            //player.Inventory.Leggings = new ItemDiamondLeggings();
            //player.Inventory.Boots = new ItemDiamondBoots();
            //while (player.Inventory.SetFirstEmptySlot(new ItemIronAxe(), false)) { }

            player.SendPlayerInventory();

            player.SendArmorForPlayer();
            player.SendEquipmentForPlayer();

            _players.TryAdd(player.Username, player);

            ThreadPool.QueueUserWorkItem(state =>
            {
                Thread.Sleep(2000);
                level.BroadcastMessage($"{ChatColors.Gold}[{ChatColors.Green}+{ChatColors.Gold}]{ChatFormatting.Reset} {player.Username} joined the server");
                var joinSound = new AnvilUseSound(level.SpawnPoint.ToVector3());
                joinSound.Spawn(level);

                player.SendTitle(null, TitleType.Clear);
                player.SendTitle(null, TitleType.AnimationTimes, 6, 6, 20 * 10);
                player.SendTitle($"{ChatColors.White}This is gurun's MiNET\n.NET core test server", TitleType.SubTitle);
                player.SendTitle($"{ChatColors.Gold}Welcome {player.Username}!", TitleType.Title);
            });
        }