Skip to content

Commit

Permalink
Add mcfunction language (#4425)
Browse files Browse the repository at this point in the history
* Add mcfunction to languages.yml

* Run script/add-grammar successfully

* Add samples

* Obtain unique ID via script/update-ids

* Remove extraneous samples; keep showcase

* Add missing submodule

* Update license

* Re-order mcfunction language
  • Loading branch information
Arcensoth authored and lildude committed Mar 1, 2019
1 parent f2e05af commit 849b5dc
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,9 @@
[submodule "vendor/grammars/language-maxscript"]
path = vendor/grammars/language-maxscript
url = https://github.com/Alhadis/language-maxscript
[submodule "vendor/grammars/language-mcfunction"]
path = vendor/grammars/language-mcfunction
url = https://github.com/Arcensoth/language-mcfunction
[submodule "vendor/grammars/language-meson"]
path = vendor/grammars/language-meson
url = https://github.com/TingPing/language-meson
Expand Down
2 changes: 2 additions & 0 deletions grammars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ vendor/grammars/language-less:
- source.css.less
vendor/grammars/language-maxscript:
- source.maxscript
vendor/grammars/language-mcfunction:
- source.mcfunction
vendor/grammars/language-meson:
- source.meson
vendor/grammars/language-ncl:
Expand Down
8 changes: 8 additions & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5663,6 +5663,14 @@ fish:
tm_scope: source.fish
ace_mode: text
language_id: 415
mcfunction:
type: programming
color: "#E22837"
extensions:
- ".mcfunction"
tm_scope: source.mcfunction
ace_mode: text
language_id: 462488745
mupad:
type: programming
extensions:
Expand Down
44 changes: 44 additions & 0 deletions samples/mcfunction/showcase.mcfunction
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## Raycasting
# Casts a ray from starting position up to 128 blocks away.
# @params
# $mypack.raycast.precision temp
# The ratio of block precision to a full block.
# @returns The number of entities hit by the ray.

# TODO use real commands
function mypack:raycast/loop
function #mypack:hooks/raycast/begin
effect give @s minecraft:night_vision 999999 1 true
execute if score @a temp matches 10..20
execute positioned 10 ~10 -10
execute positioned 10 ^0.5 -10
execute if block ~ ~ ~ minecraft:oak_leaves[persistent=true]
execute if block ~ ~ ~ #minecraft:leaves[distance=5,persistent=false]
tag @s add my.tag
datapack enable "hello world"
datapack enable "escape \" me"
execute as f7a39418-72ca-4bf2-bc7e-ba9df67a4707 run say hello
execute as 0-0-0-0-0 run say goodbye
execute as @a[sort=nearest]
execute as @a[gamemode=!creative]
execute as @a[tag=foo,tag=bar,tag=!baz]
execute as @a[distance=100]
execute as @a[distance=1..19]
execute as @a[distance=...001]
execute as @a[type=minecraft:bat]
execute as @a[type=!#minecraft:skeletons,type=!minecraft:zombie]
execute as @a[name="Custom Name"] as @s
execute as @e[nbt={ PortalCooldown: 0 }]
execute as @e[nbt={ Item: {id: "minecraft:diamond", Count: 64 } }]
execute if score @s foo < @s bar
scoreboard players operation @s foo %= @s bar
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"}]

1 change: 1 addition & 0 deletions vendor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ This is a list of grammars that Linguist selects to provide syntax highlighting
- **Maven POM:** [textmate/maven.tmbundle](https://github.com/textmate/maven.tmbundle)
- **Max:** [textmate/json.tmbundle](https://github.com/textmate/json.tmbundle)
- **MAXScript:** [Alhadis/language-maxscript](https://github.com/Alhadis/language-maxscript)
- **mcfunction:** [Arcensoth/language-mcfunction](https://github.com/Arcensoth/language-mcfunction)
- **MediaWiki:** [textmate/mediawiki.tmbundle](https://github.com/textmate/mediawiki.tmbundle)
- **Mercury:** [sebgod/mercury-tmlanguage](https://github.com/sebgod/mercury-tmlanguage)
- **Meson:** [TingPing/language-meson](https://github.com/TingPing/language-meson)
Expand Down
1 change: 1 addition & 0 deletions vendor/grammars/language-mcfunction
Submodule language-mcfunction added at 009c65
27 changes: 27 additions & 0 deletions vendor/licenses/grammar/language-mcfunction.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
type: grammar
name: language-mcfunction
version: '009c65b1a8a60c2a4f3be4751ffbad5a4117e091'
license: mit
---
MIT License

Copyright (c) 2019 Arcensoth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

0 comments on commit 849b5dc

Please sign in to comment.