diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeAuthors.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeAuthors.cs deleted file mode 100644 index f54dc3c5..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeAuthors.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgeAuthors( - int id, - string name, - string url); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeCategories.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeCategories.cs deleted file mode 100644 index 02f0d4c9..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeCategories.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgeCategories( - int id, - int gameId, - string name, - string slug, - string url, - string iconUrl, - string dateModified, - bool isClass, - int classId, - int parentCategoryId, - int displayIndex); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeFile.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeFile.cs deleted file mode 100644 index 26eb1ce4..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeFile.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgeFile( - int id, - int gameId, - int modId, - bool isAvailable, - string displayName, - string fileName, - int releaseType, - int fileStatus, - CurseforgeHashes hashes); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeHashes.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeHashes.cs deleted file mode 100644 index 348a9134..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeHashes.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgeHashes( - string value, - int algo); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeLinks.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeLinks.cs deleted file mode 100644 index 63fa6b31..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeLinks.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgeLinks( - string websiteUrl, - string wikiUrl, - string issuesUrl, - string sourceUrl); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgePictures.cs b/Minecraft/ResourceProject/Curseforge/CurseforgePictures.cs deleted file mode 100644 index 50d3c64f..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgePictures.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgePictures( - int id, - int modId, - string title, - string description, - string thumbnailUrl, - string url); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeProject.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeProject.cs deleted file mode 100644 index 2fbb8fb5..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeProject.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record class CurseforgeProject( - int id, - int gameId, - string name, - string slug, - CurseforgeLinks links, - string summary, - int status, - int downloadCount, - bool isFeatured, - int primaryCategoryId, - List categories, - int classId, - List authors, - CurseforgePictures logo, - List screenshots, - int mainFileId, - object latestFiles); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeResponseData.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeResponseData.cs deleted file mode 100644 index 981516dd..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeResponseData.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PCL.Core.Minecraft.ResourceProject.Curseforge; - -[Serializable] -public record class CurseforgeProjectResponse(CurseforgeProject data); -[Serializable] -public record class CurseforgeProjectsResponse(List data); diff --git a/Minecraft/ResourceProject/Curseforge/CurseforgeScreenshots.cs b/Minecraft/ResourceProject/Curseforge/CurseforgeScreenshots.cs deleted file mode 100644 index 00ad62ff..00000000 --- a/Minecraft/ResourceProject/Curseforge/CurseforgeScreenshots.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; - -namespace PCL.Core.Model.ResourceProject.Curseforge; - -[Serializable] -public record CurseforgeScreenshots( - int id, - int modId, - string title, - string description, - string thumbnailUrl); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Modrinth/ModrinthDonationUrl.cs b/Minecraft/ResourceProject/Modrinth/ModrinthDonationUrl.cs deleted file mode 100644 index 9343db9d..00000000 --- a/Minecraft/ResourceProject/Modrinth/ModrinthDonationUrl.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Modrinth; - -[Serializable] -public record ModrinthDonationUrl( - string id, - string platform, - string url); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Modrinth/ModrinthGallery.cs b/Minecraft/ResourceProject/Modrinth/ModrinthGallery.cs deleted file mode 100644 index 880786e3..00000000 --- a/Minecraft/ResourceProject/Modrinth/ModrinthGallery.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Modrinth; - -[Serializable] -public record ModrinthGallery( - string url, - bool featured, - string? title, - string? description, - string created, - int ordering); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Modrinth/ModrinthLicense.cs b/Minecraft/ResourceProject/Modrinth/ModrinthLicense.cs deleted file mode 100644 index b91607a0..00000000 --- a/Minecraft/ResourceProject/Modrinth/ModrinthLicense.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Modrinth; - -[Serializable] -public record ModrinthLicense( - string id, - string name, - string? url); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Modrinth/ModrinthModeratorMessage.cs b/Minecraft/ResourceProject/Modrinth/ModrinthModeratorMessage.cs deleted file mode 100644 index 98747de4..00000000 --- a/Minecraft/ResourceProject/Modrinth/ModrinthModeratorMessage.cs +++ /dev/null @@ -1,8 +0,0 @@ -using System; - -namespace PCL.Core.Minecraft.ResourceProject.Modrinth; - -[Serializable] -public record ModrinthModeratorMessage( - string message, - string? body); \ No newline at end of file diff --git a/Minecraft/ResourceProject/Modrinth/ModrinthProject.cs b/Minecraft/ResourceProject/Modrinth/ModrinthProject.cs deleted file mode 100644 index 8a02a06c..00000000 --- a/Minecraft/ResourceProject/Modrinth/ModrinthProject.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace PCL.Core.Minecraft.ResourceProject.Modrinth; - -[Serializable] -public record class ModrinthProject( - string slug, - string title, - string description, - List categories, - string client_side, - string server_side, - string body, - string status, - string? requested_status, - List additional_categories, - string? issues_url, - string? source_url, - string? wiki_url, - string? discord_url, - List donation_urls, - string project_type, - int downloads, - string icon_url, - int color, - string thread_id, - string monetization_status, - string id, - string team, - string body_url, - ModrinthModeratorMessage moderator_message, - string published, - string updated, - string? approved, - string? queued, - int followers, - ModrinthLicense license, - List versions, - List game_versions, - List loaders, - List gallery); \ No newline at end of file diff --git a/Minecraft/ResourceProject/ResourcePlatform/Models/ProjectDefine.cs b/Minecraft/ResourceProject/ResourcePlatform/Models/ProjectDefine.cs new file mode 100644 index 00000000..b93c8e57 --- /dev/null +++ b/Minecraft/ResourceProject/ResourcePlatform/Models/ProjectDefine.cs @@ -0,0 +1,353 @@ +namespace PCL.Core.Minecraft.ResourceProject.ResourcePlatform.Models; + +/// +/// 资源信息的来源平台 +/// +public enum ProjectSource +{ + Unknown, + Modrinth, + CurseForge +} + +/// +/// 资源类型 +/// +public enum ResourceType +{ + All, + /// + /// 模组 + /// + Mod, + /// + /// 模组包 + /// + Modpack, + /// + /// 资源包(材质包) + /// + ResourcePack, + /// + /// 数据包 + /// + DataPack, + /// + /// 光影 + /// + Shader, +} + +/// +/// Mod 加载器类型 +/// +public enum ModLoaderType +{ + /// + /// 未知 + /// + Unknown, + /// + /// 文件覆盖 + /// + Native, + /// + /// Forge + /// + Forge, + /// + /// Fabric + /// + Fabric, + /// + /// LiteLoader + /// + LiteLoader +} + +/// +/// 资源的发布类型,例如 Beta、Release 等 +/// +public enum ReleaseType{ + Alapha, + Beta, + Release +} + +/// +/// 通用 Tag +/// +public enum CommonTag +{ + /// + /// 不筛选 + /// + Nothing, + /// + /// 科技 + /// + Technology, + /// + /// 魔法 + /// + Magic, + /// + /// 冒险 + /// + Adventure, + /// + /// 实用工具 + /// + Utility, + /// + /// 性能优化 + /// + Optimizationags, + /// + /// 原版风 + /// + VanillaLike, + /// + /// 写实风 + /// + Realistic, +} + +/// +/// Mod & 数据包标签 +/// +public enum ModOrDataoackTag{ + /// + /// 世界元素 + /// + Worldgen, + /// + /// 食物/烹饪 + /// + Food, + /// + /// 游戏机制 + /// + GameMechanics, + /// + /// 运输 + /// + Transportation, + /// + /// 仓储 + /// + Storage, + /// + /// 装饰 + /// + Decoration, + /// + /// 生物 + /// + Mobs, + /// + /// 装备 + /// + Equipment, + /// + /// 服务器 + /// + Social, + /// + /// 支持库 + /// + Library +} + +/// +/// 整合包标签 +/// +public enum ModpackTag +{ + /// + /// 多人 + /// + MultiPlayer, + /// + /// 硬核 + /// + Challenging, + /// + /// 战斗 + /// + Combat, + /// + /// 任务 + /// + Quests, + /// + /// 水槽包 + /// + KitchenSink, + /// + /// 轻量 + /// + Lightweight +} + + +public enum ResourcePackTag +{ + /// + /// 简介 + /// + Simplistic, + /// + /// 战斗 + /// + Combat, + /// + /// 改良 + /// + Tweaks, + /// + /// 极简 (8x-) + /// + R8OrLower, + /// + /// 16px + /// + R16, + /// + /// 32px + /// + R32, + /// + /// 48px + /// + R48, + /// + /// 64px + /// + R64, + /// + /// 128px + /// + R128, + /// + /// 256px + /// + R256, + /// + /// 超高清 (512px+) + /// + R512OrHigher, + /// + /// 含声音 + /// + Audio, + /// + /// 含字体 + /// + Fonts, + /// + /// 含 UI + /// + Gui, + /// + /// 含模型 + /// + Models, + /// + /// 含语言 + /// + Locale, + /// + /// 核心着色器 + /// + CoreShaders, + /// + /// 兼容 Mod + /// + Modded +} + +public enum ShadowTag +{ + /// + /// 幻想风 + /// + Fantasy, + /// + /// 半写实风 + /// + SemiRealistic, + /// + /// 卡通风 + /// + Cartoon, + /// + /// 极低 + /// + Potato, + /// + /// 低 + /// + Low, + /// + /// 中 + /// + Medium, + /// + /// 高 + /// + High, + /// + /// 彩色光照 + /// + ColoredLighting, + /// + /// 路径追踪 + /// + PathTracing, + /// + /// PBR + /// + PBR, + /// + /// 反射 + /// + Reflections, + /// + /// Iris + /// + Iris, + /// + /// OptiFine + /// + OptiFine, + /// + /// 原版可用 + /// + Vanilla +} + + +/// +/// 是否支持此平台 +/// +public enum ResourceRequire +{ + /// + /// 未知 + /// + Unknown, + /// + /// 必须安装 + /// + Required, + /// + /// 可选 + /// + Optional, + /// + /// 不支持此平台 + /// + Unsupported +} + diff --git a/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceComp.cs b/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceComp.cs new file mode 100644 index 00000000..e1712aab --- /dev/null +++ b/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceComp.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; + +namespace PCL.Core.Minecraft.ResourceProject.ResourcePlatform.Models; + +public class ResourceComp +{ + private string? _mcModUrl; + /// + /// 资源名称 + /// + public required string Title; + /// + /// 资源简介 + /// + public required string Description; + /// + /// 资源图标的 Url + /// + public string? IconUrl; + /// + /// 资源类型 + /// + public ResourceType Type; + public ProjectSource Source; + public required List Authors; + public string? I18NName; + + public string? McmodUrl + { + get => _mcModUrl ?? "https://www.mcmod.cn"; + set => _mcModUrl = value; + } + + public required List SupportMcVersions; + + public int DownloadCount { get; set; } + +} \ No newline at end of file diff --git a/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceFile.cs b/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceFile.cs new file mode 100644 index 00000000..e603bd14 --- /dev/null +++ b/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceFile.cs @@ -0,0 +1,32 @@ +namespace PCL.Core.Minecraft.ResourceProject.ResourcePlatform.Models; + +public class ResourceFile +{ + private string? _DownloadUrl; + + /// + /// 资源的直接下载地址 + /// + public string? DownloadUrl { + get + { + if (string.IsNullOrEmpty(_DownloadUrl) && FileSource is ProjectSource.CurseForge) + { + _DownloadUrl = "https://edge.forgecen.net"; + return _DownloadUrl; + } + + return _DownloadUrl; + } + set => _DownloadUrl = value; + } + + public ProjectSource FileSource { get; set; } + + public required string Algorithm; + + public required int Size; + + public required string FileHash; + +} \ No newline at end of file diff --git a/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceProject.cs b/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceProject.cs new file mode 100644 index 00000000..e1020b8a --- /dev/null +++ b/Minecraft/ResourceProject/ResourcePlatform/Models/ResourceProject.cs @@ -0,0 +1,9 @@ +namespace PCL.Core.Minecraft.ResourceProject.ResourcePlatform.Models; + +public class ResourceProject +{ + /// + /// 资源的发布平台 + /// + public ProjectSource ProjectSource; +} \ No newline at end of file diff --git a/Minecraft/ResourceProject/ResourcePlatform/ResourcePlatformService.cs b/Minecraft/ResourceProject/ResourcePlatform/ResourcePlatformService.cs new file mode 100644 index 00000000..21866577 --- /dev/null +++ b/Minecraft/ResourceProject/ResourcePlatform/ResourcePlatformService.cs @@ -0,0 +1,9 @@ +namespace PCL.Core.Minecraft.ResourceProject.ResourcePlatform; + +public static class ResourcePlatformService +{ + public static void CheckUpdate() + { + + } +} \ No newline at end of file diff --git a/PCL.Core.slnx b/PCL.Core.slnx deleted file mode 100644 index 65157cbf..00000000 --- a/PCL.Core.slnx +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index 97f6d27f..00000000 --- a/README.md +++ /dev/null @@ -1,7 +0,0 @@ -## ✨ PCL.Core - -这是为 PCL CE 版本特别开发的核心库,由社区开发与维护 - -## 🔒 协议 - -遵循 Apache License 2.0 开源协议 \ No newline at end of file diff --git a/Utils/Hash/MurmurHash2Provider.cs b/Utils/Hash/MurmurHash2Provider.cs new file mode 100644 index 00000000..8013fcc8 --- /dev/null +++ b/Utils/Hash/MurmurHash2Provider.cs @@ -0,0 +1,117 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; + + +namespace PCL.Core.Utils.Hash; + +public class MurmurHash2Provider : IHashProvider +{ + public static readonly MurmurHash2Provider Instance = new(); + private const int Size = 1024 * 1024; + private const uint M = 0x5BD1E995u; + + /// + /// 计算给定流的 Murmur Hash 2 + /// + /// 数据流 + /// 该对象对应的 Murmur Hash 2 + public string ComputeHash(Stream input) + { + // 会自动截断溢出 + unchecked + { + if (input == null) throw new ArgumentNullException(nameof(input)); + + using var ms = new MemoryStream(); + input.CopyTo(ms); + byte[] src = ms.ToArray(); + + // 这些字节不能列入计算 + var filtered = new List(src.Length); + foreach (var b in src) + { + if (b == 9 || b == 10 || b == 13 || b == 32) continue; + filtered.Add(b); + } + + int length = filtered.Count; + uint h = 1u ^ (uint)length; + + int i = 0; + + while (i + 4 <= length) + { + uint k = (uint)filtered[i] + | (uint)filtered[i + 1] << 8 + | (uint)filtered[i + 2] << 16 + | (uint)filtered[i + 3] << 24; + + k *= M; + k ^= k >> 24; + k *= M; + + h *= M; + h ^= k; + + i += 4; + } + + int rem = length - i; + switch (rem) + { + case 3: + h ^= (uint)filtered[i] | (uint)filtered[i + 1] << 8; + h ^= (uint)filtered[i + 2] << 16; + h *= M; + break; + case 2: + h ^= (uint)filtered[i] | (uint)filtered[i + 1] << 8; + h *= M; + break; + case 1: + h ^= (uint)filtered[i]; + h *= M; + break; + } + + h ^= h >> 13; + h *= M; + h ^= h >> 15; + + return h.ToString(); + } + } + + /// + /// 计算给定字节的 Murmur Hash 2 + /// + /// 字节 + /// 该对象的 Murmur Hash2 + public string ComputeHash(byte[] input) + { + using MemoryStream stream = new(input); + return ComputeHash(stream); + } + + /// + /// 计算给定字符串的 Murmru Hash 2 + /// + /// 字符串 + /// 编码 + /// 该对象的 Murmur Hash 2 + public string ComputeHash(string input, Encoding? en = null) + { + using MemoryStream stream = new((en ?? Encoding.UTF8).GetBytes(input)); + return ComputeHash(stream); + } + + public string ComputeHash(string filePath) + { + if (!File.Exists(filePath)) return string.Empty; + using FileStream fs = new(filePath, FileMode.Open, FileAccess.Read, FileShare.Read, 16384, true); + return ComputeHash(fs); + } + +} \ No newline at end of file