Skip to content

Instantly share code, notes, and snippets.

@intsuc
Last active August 22, 2019 15:13
Show Gist options
  • Save intsuc/76db39e773a5c04d82185c90876767e4 to your computer and use it in GitHub Desktop.
Save intsuc/76db39e773a5c04d82185c90876767e4 to your computer and use it in GitHub Desktop.
typeof function
scoreboard objectives add typeof dummy
# n @ data get block 0 0 0 RecordItem.tag.tags[n][0] | result
# ----------------------------------------------------------------------------+-------
# 0 (1b) | 1
# 1 (2s) | 2
# 2 (3) | 3
# 3 (4L) | 4
# 4 (5.0f) | 5
# 5 (6.0d) | 6
# 6 ([B; 0B, 0B, 0B, 0B, 0B, 0B, 0B]) | 7
# 7 ("00000000") | 8
# 8 ([0b, 0b, 0b, 0b, 0b, 0b, 0b, 0b, 0b]) | 9
# 9 ({0: 0b, 1: 0b, 2: 0b, 3: 0b, 4: 0b, 5: 0b, 6: 0b, 7: 0b, 8: 0b, 9: 0b}) | 10
# 10 ([I; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) | 11
# 11 ([L; 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]) | 12
setblock 0 0 0 minecraft:jukebox{RecordItem: {id: "minecraft:tnt", Count: 1b, tag: {tags: [[1b], [2s], [3], [4L], [5.0f], [6.0d], [[B; 0B, 0B, 0B, 0B, 0B, 0B, 0B]], ["00000000"], [[0b, 0b, 0b, 0b, 0b, 0b, 0b, 0b, 0b]], [{0: 0b, 1: 0b, 2: 0b, 3: 0b, 4: 0b, 5: 0b, 6: 0b, 7: 0b, 8: 0b, 9: 0b}], [[I; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], [[L; 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L]]]}}}
# example: RecordItem.tag.operand = "value"
# [1b ] -> failure: [1b ]
# [2s ] -> failure: [2s ]
# [3 ] -> failure: [3 ]
# [4L ] -> failure: [4L ]
# [5.0f ] -> failure: [5.0f ]
# [6.0d ] -> failure: [6.0d ]
# [[B;...]] -> failure: [[B;...]]
# ["..." ] -> success: ["..." , "value"]
# [[...] ] -> failure: [[...] ]
# [{...} ] -> failure: [{...} ]
# [[I;...]] -> failure: [[I;...]]
# [[L;...]] -> failure: [[L;...]]
data modify block 0 0 0 RecordItem.tag.tags[] append from block 0 0 0 RecordItem.tag.operand
# [-2] [-1] | [0] [1]
# get: |
# +-------+ |
# | | [1b ] | [1b ]
# | | [2s ] | [2s ]
# | | [3 ] | [3 ]
# | | [4L ] | [4L ]
# | | [5.0f ] | [5.0f ]
# | | [6.0d ] | [6.0d ]
# | | [[B;...]] | [[B;...]]
# [|"..." |, "value"] | ["..." , "value"]
# | | [[...] ] | [[...] ]
# | | [{...} ] | [{...} ]
# | | [[I;...]] | [[I;...]]
# | | [[L;...]] | [[L;...]]
# +-------+ |
execute store result score #result typeof run data get block 0 0 0 RecordItem.tag.tags[][-2]
# [-2] [-1] | [0] [1]
# | remove:
# | +-------+
# [1b ] | [1b ] | |
# [2s ] | [2s ] | |
# [3 ] | [3 ] | |
# [4L ] | [4L ] | |
# [5.0f ] | [5.0f ] | |
# [6.0d ] | [6.0d ] | |
# [[B;...]] | [[B;...]] | |
# ["..." , "value"] | ["..." , |"value"|]
# [[...] ] | [[...] ] | |
# [{...} ] | [{...} ] | |
# [[I;...]] | [[I;...]] | |
# [[L;...]] | [[L;...]] | |
# | +-------+
data remove block 0 0 0 RecordItem.tag.tags[][1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment