Ejemplo n.º 1
0
        public void SpawnFake(Player player, string name)
        {
            string pluginDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            //var bytes = Encoding.Default.GetBytes(new string('Z', 8192));
            //byte[] skinData = Skin.GetTextureFromFile(Path.Combine(pluginDirectory, "test_skin.png"));
            byte[] skinData   = Skin.GetTextureFromFile(Path.Combine(pluginDirectory, "IMG_0220.png"));
            string skinString = File.ReadAllText(Path.Combine(pluginDirectory, "geometry.json"));

            var    random  = new Random();
            string newName = $"geometry.{DateTime.UtcNow.Ticks}.{random.NextDouble()}";

            skinString = skinString.Replace("geometry.humanoid.custom", newName);
            GeometryModel geometryModel = Skin.Parse(skinString);

            PlayerLocation coordinates = player.KnownPosition;
            Vector3        direction   = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;

            var fake = new PlayerMob(string.Empty, player.Level)
            {
                KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, 0, 0)
                                //KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw + 180f, coordinates.Yaw + 180f)
            };

            fake.Skin.Data = skinData;
            fake.Skin.SkinResourcePatch = new SkinResourcePatch()
            {
                Geometry = new GeometryIdentifier()
                {
                    Default = newName
                }
            };
            fake.Skin.GeometryName = newName;
            //fake.Skin.GeometryData = skinString;
            fake.Skin.GeometryData = Skin.ToJson(geometryModel);
            ;

            fake.SpawnEntity();

            fake.SetPosition(new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, 0, 0), true);

            var state = new GravityGeometryBehavior(fake, geometryModel);

            fake.Ticking += state.FakeMeltTicking;
        }
Ejemplo n.º 2
0
        public void SpawnFake(Player player, string name)
        {
            string pluginDirectory = Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            //var bytes = Encoding.Default.GetBytes(new string('Z', 8192));
            byte[] bytes = Skin.GetTextureFromFile(Path.Combine(pluginDirectory, "test_skin.png"));
            //byte[] bytes = Skin.GetTextureFromFile(Path.Combine(pluginDirectory, "IMG_0220.png"));
            string skinString = File.ReadAllText(Path.Combine(pluginDirectory, "geometry.json"));

            var    random  = new Random();
            string newName = $"geometry.{DateTime.UtcNow.Ticks}.{random.NextDouble()}";

            skinString = skinString.Replace("geometry.humanoid", newName);
            GeometryModel geometryModel = Skin.Parse(skinString);

            var coordinates = player.KnownPosition;
            var direction   = Vector3.Normalize(player.KnownPosition.GetHeadDirection()) * 1.5f;

            PlayerMob fake = new PlayerMob(string.Empty, player.Level)
            {
                Skin = new Skin
                {
                    SkinId           = "testing",
                    Slim             = false,
                    SkinData         = bytes,
                    CapeData         = new byte[0],
                    SkinGeometryName = newName,
                    SkinGeometry     = skinString
                },
                KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, 0, 0)
                                //KnownPosition = new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, coordinates.HeadYaw + 180f, coordinates.Yaw + 180f)
            };

            fake.SpawnEntity();

            fake.SetPosition(new PlayerLocation(coordinates.X + direction.X, coordinates.Y, coordinates.Z + direction.Z, 0, 0), true);

            GravityGeometryBehavior state = new GravityGeometryBehavior(fake, geometryModel);

            fake.Ticking += state.FakeMeltTicking;
        }