Skip to content

raphydaphy/breakoutapi

Repository files navigation

Breakout API

BreakoutAPI is a Minecraft mod which allows developers to create new windows that run alongside Minecraft. All the windows run on the same OpenGL context, so all the game assets and data is shared between them. With this library, you can create external GUIs, maps, inventory reports and much more - you could even render a portion of your Minecraft world from a different perspective, or split in-game GUIs between physical screens.

Using BreakoutAPI in your mod

To get started using BreaakoutAPI, add the following to your build.gradle file:

def lwjgl_version="3.2.2"
def breakoutapi_version="0a8061b"

repositories {
	mavenCentral()
	maven { url 'https://jitpack.io' }
}

dependencies {
	modCompile "com.github.raphydaphy:breakoutapi:$breakoutapi_version"

	implementation "org.lwjgl:lwjgl-nanovg:$lwjgl_version"
	runtimeOnly "org.lwjgl:lwjgl-nanovg:$lwjgl_version:natives-windows"
	runtimeOnly "org.lwjgl:lwjgl-nanovg:$lwjgl_version:natives-linux"
	runtimeOnly "org.lwjgl:lwjgl-nanovg:$lwjgl_version:natives-macos"

	implementation "org.lwjgl:lwjgl-yoga:$lwjgl_version"
	runtimeOnly "org.lwjgl:lwjgl-yoga:$lwjgl_version:natives-windows"
	runtimeOnly "org.lwjgl:lwjgl-yoga:$lwjgl_version:natives-linux"
	runtimeOnly "org.lwjgl:lwjgl-yoga:$lwjgl_version:natives-macos"
}

Once you have added the required dependencies to your project, you will need to create aa class which extends AbstractBreakout:

public class ExampleBreakout extends Breakout {

  public ExampleBreakout(Identifier identifier) {
    super(identifier, new BreakoutWindow("Example Breakout", 480, 720));
  }

  @Override
  public void render() {
    super.render();

    MinecraftClient client = MinecraftClient.getInstance();
    MatrixStack stack = new MatrixStack();

    client.getTextureManager().bindTexture(new Identifier("textures/block/azalea_leaves.png"));
    DrawableHelper.drawTexture(stack, 50, 250, 0, 0, 0, 180, 300, 32, 32);

    client.textRenderer.draw(stack, "Hello world!", 100 / 3f, 200 / 3f, 0);
  }
}

Once you have created the class, you can open and close the breakout using the methods provided in BreakoutAPIClient. The identifier is only used to keep track of an instance of a breakout, and it can be used to close or track it after creation.

Identifier id = new Identifier("your_mod_id", "your_first_breakout");
BreakoutAPIClient.openBreakout(id, new ExampleBreakout(id));