Mcpy, an Mcfunction compiler

                      avatar Revon Zev
                      Level 57 : Grandmaster Dragon
                      60
                      Example Project:
                      The example project is from my Poisonous Block Datapack except it's rewritten in MCPY

                      MCPY is the programming language (".mcpy" file extension)
                      The downloaded file is the compiler ("mcpy.exe" or "mcpy.py")

                      If your computer tells you the program is a virus, it is not, if you download it from the above links or the above download button and in planetminecraft.com, or from my Github.


                      MCPY

                      Mcfunction compiler by using Python. This programming language is designed based on Mcfunction or Minecraft's commands, so moving from Mcfunction to Mcpy is easy. The file extension is ".mcpy" example: "main.mcpy"

                      Comment
                      # This is a comment
                      Note: Put a comment in its own line


                      Normal Commands

                      Normal commands are... just that, normal commands.
                      say Hello World
                      function test:main
                      effect give @s minecraft:speed_boost 1 1
                      summon minecraft:bat ~ ~ ~
                      execute as @a at @s run say Hello Player


                      Execute

                      As At
                      # A
                      as at @a:
                      say Hello World

                      # B
                      as @a:
                      at @s:
                      say Hello World

                      # Compile into:
                      execute as @a at @s run say Hello World

                      If matches x or x
                      unless score @a home matches [​0, 2, 4]:
                      say your score is 0 or 2 or 4

                      # Compile into:
                      execute unless score @a home matches 0 say your score is 0 or 2 or 4
                      execute unless score @a home matches 2 say your score is 0 or 2 or 4
                      execute unless score @a home matches 4 say your score is 0 or 2 or 4

                      Else
                      if score @a home matches 0:
                      say your score is 0
                      else:
                      say your score is not 0

                      # Compile into:
                      execute if score @a home matches 0 run say your score is 0
                      execute unless score @a home matches 0 run say your score is not 0

                      Other parts of execute
                      The rest of the execute chain is the same as Minecraft, but with a ":" colon at the end.
                      in nether:
                      if block ~ ~ ~ fire:
                      say Your burn is in a whole other dimensions

                      # Compile into:
                      execute in nether if block ~ ~ ~ fire run say Your burn is in whole other dimensions


                      Scoreboard

                      Define

                      score home dummy "Display"

                      # Compile into:
                      scoreboard objectives add home dummy "Display"

                      # DO NOT DO: score home dummy "Display" = 10

                      Set
                      home @a = 10
                      home = 10

                      # Compile into:
                      scoreboard players set @a home 10
                      scoreboard players set @s home 10

                      Add
                      home @a += 1
                      home += 1

                      # Compile into:
                      scoreboard players add @a home 1
                      scoreboard players add @s home 1

                      Subtract
                      home @a -= 1
                      home -= 1

                      # compile into:
                      scoreboard players remove @a home 1
                      scoreboard players remove @s home 1

                      Operation
                      home @a *= home @p
                      home @a *= home
                      home *= home @p
                      home *= home

                      # Compile into:
                      scoreboard players operation @a home *= @p home
                      scoreboard players operation @a home *= @s home
                      scoreboard players operation @s home *= @p home
                      scoreboard players operation @s home *= @s home

                      # Operations: %=, *=, +=, -=, /=, <, >, =, ><

                      Store command result
                      home @a := say Hello
                      home := say Hello

                      # Compile into
                      execute store result score @a home run say Hello
                      execute store result score @s home run say Hello

                      Note
                      # For selector arguments do not use space in it
                      home @e[name=someone,tag=something] += 10
                      # The below code do not work
                      home @e[name=someone, tag=something] += 10

                      # Compile into
                      scoreboard players add @e[name=someone,tag=something] home 10
                      scoreboard players add @e[name=someone, home tag=something]


                      Obfuscation
                      To generate a new obfuscation, delete "obfuscated_data.json". to turn on obfuscation in user_settings.json change keep_unused_obfuscated_string from false to true. Default: false


                      Scoreboards
                      In the user_settings.json if "obfuscate": true then instead of the variable name it will generate a random 16 character string. You can name the variables as long as you want. This will remove the scoreboards' display names.

                      If "obfuscate": false you are limited in naming your variables to 16 characters (Minecraft's scoreboard objective name limit).

                      Tags or strings
                      To obfuscate a tag or string use
                      obf tag_name

                      Note: Any string that matches it will be obfuscated

                      Keep the unused obfuscated string
                      If keep_unused_obfuscated_string in user_settings.json is true then it will keep any unused obfuscated string from obfuscated_data.json, if it is false it will automatically remove any unused obfuscated string from obfuscated_data.json. Default: false


                      User Settings
                      The file is "user_settings.json"

                      Watch delay
                      The default is every 5 seconds. How much delay before it checks if a file has been modified and compiled. If set to 0, then it is on manual.

                      Dist path
                      The default is "./dist/". Dist location is in local. That means it cannot do "C:/Users/user/Documents/project/mcpy/dist" but instead "./dist/".
                      WARNING: Files inside dist will get deleted.

                      Project base path
                      The default is "./mcpy/". Any Mcpy files that are inside the project base will be generated in the dist path.

                      Tabbing style
                      The default is 4 spaces. Do use the proper tabbing otherwise the compiler will not compile Mcpy to Mcfunction correctly.

                      Keep comment
                      The default is false. Keep comments written in mcpy in the compiled mcfunction.

                      Any bugs you find or features you want, report them in the comments section below or on Github

                      The MCPY compiler is © 2020 - 2021 Revon Zev. Any mcfunction / datapack you make with this is yours. Do not include the compiler when uploading your datapack. You may include the ".mcpy" files. Do not distribute the MCPY compiler.
                      CompatibilityMinecraft 1.13
                      toMinecraft 1.17 Snapshot
                      Tags

                      1 Update Logs

                      2.0.0 : 01/20/2021 7:39:06 pmJan 20th

                      Refactor the codes.
                      Updated example project to MCPY v2.0.0
                      Made the code open source.
                      • Auto-generate user_settings.json if it is not the latest version of the user_settings.json.
                      • Multi-match can now use "," (coma) and ", " (coma space).
                      • Default base path is now "./mcpy/" (where the mcpy.exe is > mcpy > your_fuction.mcpy).
                      • Added nested multi-match.
                      • Added score set, add, subtract, operation with self (@s) (score_name = 10).
                      • Removed "//" for comments.

                      2
                      01/21/2021 9:38 am
                      Level 15 : Journeyman Engineer
                      deltamachine
                      hell yeah I love the idea. If only we had an actual datapack programming language instead of command lists. good job
                      1
                      12/03/2020 10:45 am
                      Level 26 : Expert Engineer
                      VanillaFriendlyDatapacks
                      I would just like to generally advice against running arbitrary executable files from the internet. Although I am sure the author only has good intentions, you can't be certain for sure. If you happen to use the program, make sure to take a look at the source code of the `mcpy.py` and only then run it. Even Python can be dangerous to your system :)

                      Anyway, great job OP.
                      1
                      12/03/2020 4:07 pmhistory
                      Level 57 : Grandmaster Dragon
                      Revon Zev
                      Thanks! Of course, you can try to look in the source code, but both files are obfuscated to keep the source. I'll release the source when I abandon this project (or when I decide this project should be an open-source project) so you guys can take over and see that this program doesn't contain any virus. I don't like viruses and I don't want anyone to get one from my creations.

                      It is now open source.
                      1
                      12/03/2020 8:22 am
                      Level 8 : Apprentice Explorer
                      MysticMage
                      Im not sure, for what it is useful right now, but at least it looks pretty useful... ;-)
                      2
                      12/03/2020 4:13 pmhistory
                      Level 57 : Grandmaster Dragon
                      Revon Zev
                      Currently (v1.4.1) it makes a more readable code for execute command and shorten the scoreboard commands. In the future, I'll make like, functions so you don't have to write the code again and again. If I manage to do that, then you guys can easily share codes. (Like packages and imports)
                      2
                      12/02/2020 8:04 am
                      Level 63 : High Grandmaster Artist
                      Meridiana
                      💙
                      Planet Minecraft Logo

                      Website

                      © 2010 - 2021
                      www.planetminecraft.com

                      Welcome