itemに個別のkeyとvalueを設定してあげたい

entityなら set metadata "test" of entity to 10 とかできるじゃないですか アイテムでも似たようなことがやりたいです
set {_gun} to diamond hoe named "test"
set data "damage" of {_gun} to 0
set {_gun} to diamond hoe named "test"
set data "damage" of {_gun} to 0
こんな感じのことがやりたいです 何か良さげなexpressionとかありますか…
No description
4 Replies
___
___12mo ago
add "{damage:0}" to nbt of {_item} でいいんじゃないの?
function get_tag_as_text(tag: text, item: item) :: text:
set {_value} to "%tag {_tag} of nbt of {_item}%"
replace """" in {_value} with ""
return {_value}

function get_tag_as_number(tag: text, item: item) :: number:
return "%tag {_tag} of nbt of {_item}%" parsed as number

function get_tag_as_boolean(tag: text, item: item) :: boolean:
set {_value} to "%tag {_tag} of nbt of {_item}%"
if {_value} is "1b" or "1":
return true
return false

function has_tag(tag: text, item: item) :: boolean:
set {_value} to tag {_tag} of nbt of {_item}
if {_value} is set:
return true
return false
function get_tag_as_text(tag: text, item: item) :: text:
set {_value} to "%tag {_tag} of nbt of {_item}%"
replace """" in {_value} with ""
return {_value}

function get_tag_as_number(tag: text, item: item) :: number:
return "%tag {_tag} of nbt of {_item}%" parsed as number

function get_tag_as_boolean(tag: text, item: item) :: boolean:
set {_value} to "%tag {_tag} of nbt of {_item}%"
if {_value} is "1b" or "1":
return true
return false

function has_tag(tag: text, item: item) :: boolean:
set {_value} to tag {_tag} of nbt of {_item}
if {_value} is set:
return true
return false
set {_damage} to get_tag_as_number("damage", {_item})
set {_damage} to get_tag_as_number("damage", {_item})
yukkina
yukkina12mo ago
アイテムは、好きな文字列のnbtを保持できる仕様があるよ(カスタムnbt) (それが___氏が話しているやつ)
月猫ch
月猫chOP12mo ago
まさに望んでたやつです すみません便利な関数まで用意してもらっちゃって💦
function getTagAsStr(tag: text, item: item) :: text:
set {_value} to "%tag {_tag} of nbt of {_item}%"
replace """" in {_value} with ""
return {_value}

function getTagAsNum(tag: text, item: item) :: number:
return "%tag {_tag} of nbt of {_item}%" parsed as number

function getTagAsBoolean(tag: text, item: item) :: boolean:
set {_value} to "%tag {_tag} of nbt of {_item}%"
return true if {_value} is "1b" or "1"
return false

function itemHasTag(tag: text, item: item) :: boolean:
set {_value} to tag {_tag} of nbt of {_item}
return true if {_value} is set
return false
function getTagAsStr(tag: text, item: item) :: text:
set {_value} to "%tag {_tag} of nbt of {_item}%"
replace """" in {_value} with ""
return {_value}

function getTagAsNum(tag: text, item: item) :: number:
return "%tag {_tag} of nbt of {_item}%" parsed as number

function getTagAsBoolean(tag: text, item: item) :: boolean:
set {_value} to "%tag {_tag} of nbt of {_item}%"
return true if {_value} is "1b" or "1"
return false

function itemHasTag(tag: text, item: item) :: boolean:
set {_value} to tag {_tag} of nbt of {_item}
return true if {_value} is set
return false
使用する上で特に不都合もなさそうなので 細部だけうちのスタイルに書き換えてそのまま使わせてもらいます><
___
___12mo ago
かまいませんよ。 僕のはjigokuのスタイルでoopでもない言語でoopの様な書き方をするのが気に入らないそうです
Want results from more Discord servers?
Add your server