Skip to main content

McDic's Language for Minecraft JE Datapack

Project description

MCDIL: McDic's Language

This language is created for easy development of Minecraft JE datapack.

Installation

You have to prepare Python 3.11+ to use this library. After you prepared appropriate environment, run following;

pip install mcdil

Features

WIP

Principles of the Language

1. Never trust any value as intermediates other than scoreboard integers and data storages.

The list of trustable values during the function execution are following;

  • Scoreboard values.
  • Data storages.

Other than the aboves, you should capture everything at the beginning of the function call whatever you need to calculate, and output those at the end of the function. Never refer those during the intermediate calculations.

2. Every function execution is atomic.

Minecraft ensures that every function execution is an atomic. There are few exceptions like /worldborder though. Similar manners are applied in this language. Every trustable local state should be reliable, even after delay calls.

3. Take more memory than sacrificing runtime performance whenever possible.

We don't care about the number of functions or duplicated commands here. If that has much lighter runtime performance, we goes for that.

4. A MCDIL function does not guarantee to run code after delay call if the original target entity is killed.

Since /schedule does not store the information, I introduce a different way to execute various functions in same tick but under different entities. However, the calling entity must be alive, otherwise the function will not be executed.

5. Not every semantics are predictable during runtime, therefore I always consider the worst case.

Suppose you conditionally call some delay. Then the compiler always asssume the delay is always happening, even if there are some cases which does not call delay at all.

Specifications

This section is incomplete, and always follow the exact grammar specification. Please read mcdil.lark for the exact grammar.

Built-in Types

Not many primitive types are supported for this moment. I am focusing to make working example first, and then will support floating numbers etc.

Integer

Used with keyword int. Specifically, only 32-bit integers are supported. In most situations, this value is maintained by /scoreboard.

int i = 1;
i += 2;

Boolean

Used with keyword bool. There are 2 literal keywords for this type; true and false. Like int, this value is maintained by /scoreboard in most situations. 0 is considered as false, non-zero values are considered as true.

bool b = true;

Null

This type is used to indicate only one value - the null. This is similar to C++'s void or Python's None.

There is no way to assign anything to this value. Any operator used with null value will fail to compile, except null == null and null != null.

null n;

Range

Used with keyword range. For now, only literal ranges are supported for target selectors.

Target Selector

Used with special character @. The syntax is slightly different from Minecraft target selectors.

Control Flows

While Loop

Used with keyword while. This loop is used for typical programming loops.

For Loop

Used with keyword as. This loop is specifically used for iterating all entities that fits on given selectors.

Example Program

def increment(int x) -> int {
    x += 1;
    return x;
}

def load() -> bool {
    RAW("say Hello everyone!")
};

def tick() -> int {

};

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcdil-0.0.2.tar.gz (8.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcdil-0.0.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file mcdil-0.0.2.tar.gz.

File metadata

  • Download URL: mcdil-0.0.2.tar.gz
  • Upload date:
  • Size: 8.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for mcdil-0.0.2.tar.gz
Algorithm Hash digest
SHA256 37306b9a0342564e5c7abae6ad6bfd014cff33510d4e8aee14122183245dc777
MD5 76bd4377fb22a58745b766bf63698580
BLAKE2b-256 cbc0798d5b7d9761680330b27dbf0a811822afd579c36baa5a485730e52813dd

See more details on using hashes here.

File details

Details for the file mcdil-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mcdil-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for mcdil-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 44f19a3abf0e3a6a2329cb0fd9e133ccc8a2a05ea1a7f7737645a5a9f7cd0311
MD5 bd1bc24174cdc9cfd528046d109c1096
BLAKE2b-256 fdd6f46f22e1871ff60d0ba5c6cd40e8ea599d4d395a7e33d4d1e732a8d9bef3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page