Ejemplo n.º 1
0
        public void Modify(Action <ResourcePackBuilder> action)
        {
            var v = new ResourcePackBuilder(_rp);

            action(v);
            _rp = v.Build();
        }
Ejemplo n.º 2
0
        public static void Load()
        {
            DefaultRP       = new ResourcePack();
            DefaultRP.Items = new Dictionary <string, ItemResource>();
            var p    = Path.GetRandomFileName();
            var path = Path.GetTempPath() + Path.GetFileNameWithoutExtension(p) + "/";

            Directory.CreateDirectory(path);

            // we need the offical Minecraft Version
            using (var c = new WebClient())
                c.DownloadFile(Utils.ClientLink, path + "client.jar");

            //extract
            ZipFile.ExtractToDirectory(path + "client.jar", path);
            foreach (var v in Directory.EnumerateFiles(path, "*", SearchOption.TopDirectoryOnly))
            {
                File.Delete(v);
            }
            foreach (var v in Directory.EnumerateDirectories(path, "*", SearchOption.TopDirectoryOnly))
            {
                if (Path.GetFileNameWithoutExtension(v) != "assets")
                {
                    Directory.Delete(v, true);
                }
            }
            File.Delete(path + "assets/.mcassetsroot");

            foreach (var v in Directory.EnumerateFiles(path + "assets/minecraft/models/item", "*.json", SearchOption.TopDirectoryOnly))
            {
                DefaultRP.Items.Add(Path.GetFileNameWithoutExtension(v), new ItemResource()
                {
                    Path   = v,
                    Model  = File.ReadAllText(v),
                    ItemId = Path.GetFileNameWithoutExtension(v),
                    Type   = ResourceType.Model_Item,
                });
            }

            //TODO: At the end of the programm, TMP shoud be cleaned

            Provider = new ResourcePackProvider();
        }
Ejemplo n.º 3
0
 public ResourcePackProvider()
 {
     _rp = new ResourcePack("Generated-Server");
 }
Ejemplo n.º 4
0
 public ResourcePackBuilder(ResourcePack rp)
 {
     this._rp = rp;
 }