There are several built-in APIs in CBL that cover core features of Minecraft as well as providing utilities for building higher-order types.
The empty type. Only valid for return types.
type int { bool operator ||(int other); bool operator &&(int other); int operator |(int other); int operator ^(int other); int operator &(int other); bool operator ==(int other); bool operator !=(int other); bool operator <=(int other); bool operator >=(int other); bool operator <(int other); bool operator >(int other); int operator <<(int other); int operator >>(int other); int operator +(int other); int operator -(int other); int operator *(int other); int operator /(int other); int operator %(int other); int operator +(); int operator -(); int operator ~(); int operator !(); int operator ++(); int operator ++(int dummy); int operator --(); int operator --(int dummy); }
Basic 32 signed integer. Operators are the same as C/C++ operators.
type bool { bool operator ||(bool other); bool operator &&(bool other); bool operator !(); }
Basic boolean type. Internally mapped to int
.
type decimal { decimal operator ==(decimal other); decimal operator !=(decimal other); decimal operator <=(decimal other); decimal operator >=(decimal other); decimal operator <(decimal other); decimal operator >(decimal other); decimal operator +(decimal other); decimal operator -(decimal other); decimal operator *(decimal other); decimal operator /(decimal other); decimal operator %(decimal other); decimal operator +(); decimal operator -(); }
Fixed point fractional value. A Q Number with 10 fractional bits.
Represents a string in the compiler. Has no runtime representation. Must be a literal string.
type Maybe<T> { constructor(); constructor(T value); bool isEmpty(); T get(); Maybe<T> operator =(T value); }
A generic type that optionally contains type T
. There is no NULL
in CBL, instead, Maybe<T>
can be used to represent an empty value.
Represents a type native to Command IR. Used internally.
type Entity { __EntityPtr _ptr; constructor(__EntityPtr ptr); property EntityPos pos(); property World world(); property RuntimeEntityType type(); Entity operator =(Entity other); void kill(); SelectorFilter has_tag(string tag); }
Represents an in-game entity. Not usually constructed manually (__EntityPtr
is an internal type).
type EntityLocal<T> { T global; T operator[](Entity entity); }
Represents a variable "local" to an entity i.e. a mapping of entity -> value
. Currently only EntityLocal<int>
is supported.
type EntityPos { __EntityPtr _ptr; constructor(__EntityPtr ptr); property EntityPosComponent x(); property EntityPosComponent y(); property EntityPosComponent z(); vec3d as_vec(); }
Position of an entity. Can be converted to vec3d
.
type EntityPosComponent : decimal { }
A decimal
backed by an entity position rather than a scoreboard/NBT value.
type EntityCollection { Entity first(); EntityCollection sortNearest(); }
Type of an entity. Represented in the compiler.
Represents a collection of entities.
singleton Entities { EntityType area_effect_cloud; EntityType armor_stand; ... }
All vanilla entity types.
type RuntimeEntityType { __EntityPtr _ptr; SelectorFilter operator==(EntityType other); }
The type of entity represented at runtime.
A type that represents a filter for a selector. Used in filter (...) { ... }
expressions.
type vec3<T> { T x; T y; T z; constructor(T x, T y, T z); vec3<T> operator *(T scalar); }
A 3 dimensional vector of generic type T
.
Built-in derivative types:
type vec3i is vec3<int>; type vec3d: vec3<decimal> { constructor(decimal x, decimal y, decimal z); vec3i to_int(); }
type World { __EntityPtr _ptr; constructor(__EntityPtr ptr); void spawn(EntityType type, vec3i pos); }
Represents a minecraft world.
singleton Blocks { BlockType air; BlockType stone; ... }
singleton Items { ItemType air; ItemType stone; ... }
type TagEvent { void fire(); }
singleton Events { TagEvent tick = TagEvent("minecraft:tick"); TagEvent load = TagEvent("minecraft:load"); ... }
singleton Game { EntityCollection entities; async void tick(); }
type Text { _IRType _text; void append_ref(int &ref); Text operator+=(int val); Text operator+=(string str); Text operator<<(int val); Text operator<<(string str); Text operator=(Text other); void send_to_all(); }
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4