/BedrockFP

Functional API wrapper for Minecraft bedrock script api (But Idris)

Primary LanguageIdrisMIT LicenseMIT

Ideal

Minecraft Script API starter for Idris2.

This project demonstrates a simple process and Idris2 compilation for Minecraft.

Code generation

This code will generate a file signs.idr.

deno run gen.ts

Requirements

To start with this project you must have the idris2 and idris2-pack installed.

Build Library

pack build ideal.ipkg

Examples

In the following example, we're listening for the blockPlace event on afterEvents. When a block is placed, we spawn a pig at the block placement location:

module Main

import MC.Server

overworld : Dimension
overworld = getDimension world "overworld"

on_place : BlockPlaceAfterEvent -> IO Entity
on_place e = pure $ spawnEntity overworld "minecraft:pig" (location $ block $ asBlockEvent e)

sub : (BlockPlaceAfterEvent -> IO ()) -> IO (BlockPlaceAfterEvent -> IO ())
sub = subscribe $ blockPlace $ afterEvents world
 
main : IO ()
main = ignore $ sub (ignore . on_place)

Idris2 is a statically typed functional programming language that places a strong emphasis on type safety and correctness. It has a very powerful type-checker hence you don't need to tag every Data Types.

You can find more examples on the folder test/src.

pack build 

Build tests

check the make.sh file for more details.

TO DO

This project is still working in progress.

  • Implement @minecraft/server
    • Basic Data Types support
    • Event system
    • Promise and more complex data types
    • Interfaces and Enum
    • JS primitive types
  • Implement @minecraft/server-ui and more
  • Auto code generation
  • A code Starter
  • Project management

Contributors