Craftopia / 创世理想乡

Craftopia / 创世理想乡

ChatItem
Psychloor 2023 年 7 月 4 日 下午 1:43
itemname as input
hi, i decompiled your code to use privately with commandhandler and also added in so you can type in itemname with spaces instead of itemid.

can write "@item gigantes' arrow 20"
to get 20 of them

the modification i did is this if you'd like to use it:

private static void CreateItemCommand(string[] args)
{
try
{
if (args.IsNullOrEmpty())
{
Debug.Log("The number of arguments is invalid.");
CommandHandler.DisplayBubbleToPlayer("The number of arguments is invalid.");
return;
}

string[] itemParams = { "", "", "", "", "", "", "" };

// Item name as string
if (!char.IsDigit(args[0][0]))
{
int stringEndPos = 0;
for (int i = 0; i < args.Length; i++)
{
if (char.IsDigit(args[i][0]))
{
stringEndPos = i;
break;
}
}

string itemName = string.Join(" ", args.Take(stringEndPos));
var itemRes = SingletonMonoBehaviour<OcItemDataMng>.Inst.appearIngameItemDataList.FirstOrDefault(i =>
i.DisplayName.IndexOf(itemName, StringComparison.OrdinalIgnoreCase) >= 0);

if (itemRes != null)
{
itemParams[0] = itemRes.Id.ToString();
Array.Copy(args, stringEndPos, itemParams, 1, Math.Min(args.Count() - stringEndPos, 6));
}
else
{
CommandHandler.DisplayBubbleToPlayer("Item not found : " + itemName);
return;
}
}
else
{
Array.Copy(args, 0, itemParams, 0, Math.Min(args.Count(), 7));
}
// and the rest of the code continues here
最后由 Psychloor 编辑于; 2023 年 7 月 4 日 下午 1:53
< >
正在显示第 1 - 6 条,共 6 条留言
mokos311  [开发者] 2023 年 7 月 4 日 下午 8:52 
We did not implement the item name generation because it seemed to increase the number of cases of generation failure due to typing errors.

And even in those cases, I get comments saying "this mod doesn't work". It is very annoying.
mokos311  [开发者] 2023 年 7 月 4 日 下午 8:53 
:rbrbu3:
Psychloor 2023 年 7 月 5 日 上午 1:53 
alright, well it's your mod so you're freely able to do what you want and i can get that some people think misspelling is an error
来自风都的人 2023 年 7 月 5 日 上午 6:58 
This extension looks very cool, just like using the command [/give] in Minecraft:steamthumbsup:
JingShing 2023 年 7 月 11 日 上午 9:52 
How do you decompiled code? I using dnspy and I failed to recompile the code I changed.
Psychloor 2023 年 7 月 12 日 上午 3:33 
引用自 JingShing
How do you decompiled code? I using dnspy and I failed to recompile the code I changed.
you need all references the code used if you want to recompile with dnspy.
i made a new mod all together and used the decompiled code to change how it works and use with commandhandler instead
< >
正在显示第 1 - 6 条,共 6 条留言
每页显示数: 1530 50