Skip to content

Commit

Permalink
仓库整理 功能雏形
Browse files Browse the repository at this point in the history
  • Loading branch information
liuning committed Oct 8, 2023
1 parent db9d041 commit 002a0b7
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public async Task<dynamic> PutItem([FromBody] ReqMinecraftItemDto model)
player.Id = await _mcPlayerRepostiory.Add(player);
}
playerWareHouseDefault.PlayerId = player.Id;
PlayerWareHouse wareHouse = await _wareHouseService.AutoCreateDefaultWareHouseAsync(new()
PlayerWareHouse wareHouse = await _wareHouseService.AutoCreateDefaultWareHouseAsync(new PlayerWareHouseCreateDto()
{
WareHouse = playerWareHouseDefault,
Items = new List<PlayerWareHouseItem>
Expand Down Expand Up @@ -125,6 +125,10 @@ public async Task<dynamic> PullItem([FromBody]ReqMinecraftItemDto model)

}





/// <summary>
/// Kook绑定
/// </summary>
Expand Down
37 changes: 18 additions & 19 deletions MineCosmos.Core.Common/Helper/NbtHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,41 +22,40 @@ public static string Escape(string input) =>
}


public class NbtHelper
public struct NbtHelper
{

static string NBTID => "id";
static string NBTCOUNT => "Count";
static string NBTLVL => "lvl";
static string NBTDAMAGE => "Damage";
static string NBTTAG => "tag";
static string NBTtext => "text";
static string NBTEnchantments => "Enchantments";
static string NBTSlot => "Slot";
static string NBTBlockEntityTag => "BlockEntityTag";
static string NBTItems => "Items";
public static string NBTID => "id";
public static string NBTCOUNT => "Count";
public static string NBTLVL => "lvl";
public static string NBTDAMAGE => "Damage";
public static string NBTTAG => "tag";
public static string NBTtext => "text";
public static string NBTEnchantments => "Enchantments";
public static string NBTSlot => "Slot";
public static string NBTBlockEntityTag => "BlockEntityTag";
public static string NBTItems => "Items";

/// <summary>
/// 物品的自定义显示信息(名称、描述、皮革盔甲的颜色等等)
/// </summary>
static string NBTdisplay => "display";
public static string NBTdisplay => "display";

/// <summary>
/// 物品名称底下的文字,必须是原始JSON文本
/// </summary>
static string NBTLore => "Lore";
public static string NBTLore => "Lore";
/// <summary>
/// 书本
/// </summary>
static string NBTpages => "pages";
public static string NBTpages => "pages";

/// <summary>
/// 能够为生物以及物品增加属性修饰符
/// </summary>
static string NBTAttributeModifiers => "AttributeModifiers";
static string NBTextra => "extra";
static string NBTName => "Name";
static string NBTRepairCost => "RepairCost";
public static string NBTAttributeModifiers => "AttributeModifiers";
public static string NBTextra => "extra";
public static string NBTName => "Name";
public static string NBTRepairCost => "RepairCost";

public static CompoundTag NbtStrToString(string nbtStr)
{
Expand Down
50 changes: 50 additions & 0 deletions MineCosmos.Core.Services/Minecraft/WareHouseService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,56 @@ public WareHouseServiceService(IBaseRepository<PlayerWareHouseItem> mcPlayerWare
_playerService = playerService;
}

#region 仓库功能


/// <summary>
/// 仓库整理
/// *目的就是把相同类型不满一组的物品合并到一个格子
/// </summary>
/// <param name="wareHouseId">仓库ID</param>
/// <returns></returns>
public async Task TidyUp(int wareHouseId)
{
var has = await AnyAsync(a => a.Id == wareHouseId);
if (!has) return;
var lstWareHouseInfo = await _mcPlayerWareHouseItem.GetListAsync
(a => a.WareHouseId == wareHouseId);
if (lstWareHouseInfo.Count <= 0) return;

//先拿到转换后的Tag集合
List<CompoundTag> lstTag = new();
foreach (var item in lstWareHouseInfo) lstTag.Add(StringNbt.Parse(item.ItemData));



//minecraft:iron_ingot

//lstTag.Where(a=>a.item)

foreach (CompoundTag tagItem in lstTag)
{
tagItem.TryGetValue(NbtHelper.NBTID, out StringTag id);
switch (id)
{
case "minecraft:iron_ingot":

break;

default:
break;
}

}





}

#endregion

public async Task<List<PlayerWareHouse>> GetPlayerWareHouseByPlayerId(int playerId)
{
var playerWareHouse = await base.GetListAsync(a => a.PlayerId == playerId);
Expand Down
3 changes: 2 additions & 1 deletion pack包加密研究/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,15 @@

CompoundTag? tags = StringNbt.Parse(testNbtStr3);


//下边的不管

Dictionary<string, object>? testDic =nbtHelper.TagToDic(tags, null);

string webJson =JsonConvert.SerializeObject(testDic);
Console.WriteLine($"正经的Json :{webJson}");
var dics = JsonConvert.DeserializeObject<Dictionary<string, object>>(webJson);
var Ntag = nbtHelper.DicToTag(dics).Create();

string nSNBT = Ntag.Stringify(false,false);


Expand Down

0 comments on commit 002a0b7

Please sign in to comment.