Skip to content

Commit bdf318f

Browse files
authored
Create getItemName function (JaylyDev#193)
* Create index.js * Update index.js
1 parent 04606d5 commit bdf318f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

scripts/item-name/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Script example for ScriptAPI
2+
// Author: Unknown <Bedrock Add-Ons>
3+
// Project: https://discord.gg/bedrock-addons
4+
/**
5+
* @param {import("@minecraft/server").ItemStack} item
6+
*/
7+
const getItemName = (item) => {
8+
return item.nameTag ?? item.typeId.split(":")[1].split('_').map(v => v[0].toUpperCase() + v.slice(1).toLowerCase()).join(" ")
9+
}
10+
11+
export { getItemName }

0 commit comments

Comments
 (0)