Skip to content

Commit

Permalink
Merge pull request #433 from YsGqHY/master
Browse files Browse the repository at this point in the history
[nms-tag] update itemTagReader
  • Loading branch information
Bkm016 authored Aug 11, 2024
2 parents 3fd7433 + 2135d96 commit ba36a90
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ fun ItemStack?.ifAir(): ItemStack? {
*
* 注: 如果修改了ItemTag 需要使用 write 设置回去
*/
fun ItemTag.reader(reader: ItemTagReader.() -> Unit) {
inline fun ItemTag.reader(reader: ItemTagReader.() -> Unit): ItemTagReader {
val itemTagReader = ItemTagReader(this)
reader.invoke(itemTagReader)
return itemTagReader
}

fun ItemStack?.itemTagReader(reader: ItemTagReader.() -> Unit) {
val item = this.ifAir() ?: return
item.getItemTag().reader(reader)
inline fun ItemStack?.itemTagReader(reader: ItemTagReader.() -> Unit): ItemTagReader? {
val item = this.ifAir() ?: return null
return item.getItemTag().reader(reader)

}

data class ItemTagReader(var itemTag: ItemTag) {
Expand Down

0 comments on commit ba36a90

Please sign in to comment.