1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
|
# This example file is borrowed from https://github.com/Arcensoth/language-mcfunction/blob/main/tests/everything.mcfunction
#> Raycasting
#
# Casts a ray from starting position along a configurable number
# of blocks with a confugrable accuracy, counting the number of
# entities hit by the ray along the way.
#
# @params
# $mypack.raycast.distance param
# The number of blocks to cast forward.
# $mypack.raycast.precision param
# The ratio of block precision to a full block.
#
# @returns
# $mypack.raycast.result return
# The number of entities hit by the ray.
function #mypack:hooks/raycast/begin
function mypack:raycast/loop
function #mypack:hooks/raycast/end
# this is a comment
say hello world
# indented comment
say hello indent
effect give @s minecraft:night_vision 999999 1 true
effect give @s minecraft:night_vision 999999 1 false
teleport 1 2 3
teleport 100.5 80 -100.5
execute if score @a temp matches 10.. run
execute if score @a temp matches ..20 run
execute if score @a temp matches 10..20 run
execute positioned 10 ~ -10 run
execute positioned 10 ~10 -10 run
execute positioned 10 ~0.5 -10 run
execute positioned 10 ~.5 -10 run
execute positioned 10 ~-10 -10 run
execute positioned 10 ~-0.5 -10 run
execute positioned 10 ~-.5 -10 run
execute positioned 10 ^ -10 run
execute positioned 10 ^10 -10 run
execute positioned 10 ^0.5 -10 run
execute positioned 10 ^.5 -10 run
execute positioned 10 ^-10 -10 run
execute positioned 10 ^-0.5 -10 run
execute positioned 10 ^-.5 -10 run
function mypack:foo
function mypack:foo/bar
function mypack:foo/bar/baz
function #mypack:foo
function #mypack:foo/bar
function #mypack:foo/bar/baz
execute if block ~ ~ ~ minecraft:oak_log[axis=x] run
execute if block ~ ~ ~ minecraft:oak_leaves[distance=5] run
execute if block ~ ~ ~ minecraft:oak_leaves[persistent=true] run
execute if block ~ ~ ~ minecraft:oak_leaves[persistent=false] run
execute if block ~ ~ ~ minecraft:oak_leaves[distance=5,persistent=true] run
execute if block ~ ~ ~ #minecraft:leaves[distance=5] run
execute if block ~ ~ ~ #minecraft:leaves[distance=5,persistent=true] run
setblock ~ ~ ~ mypack:foo{foo:bar} destroy
setblock ~ ~ ~ mypack:foo{foo: bar} destroy
setblock ~ ~ ~ mypack:foo[facing=up]{foo: bar} destroy
setblock ~ ~ ~ mypack:foo[facing = up]{foo: bar} destroy
setblock ~ ~ ~ minecraft:dispenser[facing=up]{Items: [{id: "minecraft:diamond", Count: 1}]}
tag @s add my.tag
datapack enable "hello world"
datapack enable "escape \" me"
datapack enable 'hello world'
datapack enable 'escape \' me'
execute as f7a39418-72ca-4bf2-bc7e-ba9df67a4707 run
execute as 0-0-0-0-0 run
execute store result score #fakeplayer
execute store result score #fake.player
execute store result score #fake_player
execute store result score $fakeplayer
execute store result score %fakeplayer
execute as @b
execute as @a
execute as @a[tag=foo]
execute as @a[tag=!foo]
execute as @a[sort=nearest] run
execute as @a[gamemode=survival] run
execute as @a[gamemode=!creative] run
execute as @a[tag=foo,tag=bar,tag=!baz] run
execute as @a[distance=15]
execute as @a[distance=1.5]
execute as @a[distance=.5]
execute as @a[distance=-.25]
execute as @a[distance=100]
execute as @a[distance=..10]
execute as @a[distance=11..19]
execute as @a[distance=20..]
execute as @a[distance=0.5]
execute as @a[distance=..0.1]
execute as @a[distance=0.2..0.8]
execute as @a[distance=0.9..]
execute as @a[type=minecraft:bat] run
execute as @a[type=!minecraft:cow,type=!minecraft:pig] run
execute as @a[type=#minecraft:skeletons] run
execute as @a[type=!#minecraft:skeletons,type=!minecraft:zombie] run
execute as @a[tag=my.tag] run
execute as @a[name="hello world"] as @s run
execute as @a[name="escape \" me"] as @s run
execute as @a[name="how, about, commas ?"] as @s run
execute as @a[name="and [braces] ?"] as @s run
execute as @e[nbt={ PortalCooldown: 0 }] run
execute as @e[nbt={ Item: {id: "minecraft:diamond", Count: 64 } }] run
execute if score @s foo < @s bar run
execute if score @s foo <= @s bar run
execute if score @s foo = @s bar run
execute if score @s foo > @s bar run
execute if score @s foo >= @s bar run
data get entity @s SelectedItem.tag.display.Name
data get entity @s Inventory[0]
data get entity @s Inventory[{id: "minecraft:diamond"}].Count
data get entity @s Inventory[].tag{custom: true}.display.Name
data merge entity @s { foo: true, bar: 1234 }
data modify block ~ ~ ~ RecordItem.tag set value { messages: [hi, bye] }
data modify block ~ ~ ~ RecordItem.tag.messages append value [ { message: "hello world" } ]
tellraw @a {"text": "hello world", "color": "blue"}
tellraw @a [{"text": "hello", "color": "blue"}, {"text": "world", "color": "blue"}]
execute as @a[scores={myscore=10}] run
execute as @a[scores={myscore=10..12}] run
execute as @a[scores={foo=10, bar=1..5, baz=..0}] run
execute as @a[advancements={minecraft:story/form_obsidian=true}] run
execute as @a[advancements={minecraft:story/obtain_armor={iron_helmet=true}}] run
execute as @a[advancements={minecraft:story/obtain_armor={iron_helmet=true, gold_helmet=false}}] run
execute as @a[advancements={minecraft:story/form_obsidian=true, minecraft:story/follow_ender_eye=true}] run
execute as @a[advancements={minecraft:story/form_obsidian={foo=true, bar=false},minecraft:story/follow_ender_eye={foo=false, bar=true}}] run
give @s diamond_sword{display: {Name: '"My Custom Sword"'}}
give @s minecraft:diamond_sword{display: {Name: '"My Custom Sword"'}}
execute if score @s foo < @s bar run say execute if score @s foo < @s bar run say
execute if score @s foo < @s bar run say hello @e[tag=baz, sort=nearest, limit=1] how are you?
execute
as @a # For each "player",
at @s # start at their feet.
anchored eyes # Looking through their eyes,
facing 0 0 0 # face perfectly at the target
anchored feet # (go back to the feet)
positioned ^ ^ ^1 # and move one block forward.
rotated as @s # Face the direction the player
# is actually facing,
positioned ^ ^ ^-1 # and move one block back.
if entity @s[distance=..0.6] # Check if we're close to the
# player's feet.
run
say "I'm facing the target!"
|