paulevsGitch / BlueLib

A library for Rising World Unity blueprint format

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A library for Rising World Unity blueprint format. Library use published blueprint format. At this moment library supports only V6 blueprint format (GameVersion 0.4.5).

Library depends on LZ4 Java library (version 1.8.0). Library can be used with Java 8 and higher.

Main features:

  • BlueprintIO - allows to save and load blueprints from files, streams and buffers;
  • Blueprint - class that represent blueprint instance;
  • BlueprintElement - construction elements in blueprints;
  • BlueprintObject - objects (furniture) in blueprints;
  • BlueprintPlant - plants in blueprints;
  • LittleEndianDataOutputStream - stream to save data in LittleEndian order.

Constants:

  • BlueprintElementType - contains default construction element types (with names from definitions.db);
  • BlueprintObjectType - contains default object types (with names from definitions.db);
  • BlueprintPlantType - contains default plant types (with names from definitions.db);
  • BlueprintVersion - contains blueprint version IDs.

Usage

Adding to project

If you are using Gradle adding library to your project is simple:

  1. Add jitpack and maven central to your gradle repositories section in build.gradle:
repositories {
    maven { url 'https://jitpack.io' }
    mavenCentral()
}
  1. Add library into dependency section in build.gradle:
dependencies {
    implementation 'org.lz4:lz4-java:1.8.0'
    implementation 'com.github.paulevsGitch:BlueLib:0.1.1'
}

If you want to make your project more configurable you can replace
implementation 'com.github.paulevsGitch:BlueLib:0.1.1'

with

implementation 'com.github.paulevsGitch:BlueLib:${project.bluelib_version}'

and add version into your gradle.properties:

bluelib_version = 0.1.1

If you want to use specific commit you can use commit hash instead of numeric version, example:

bluelib_version = d480b08

Creating new blueprint

Each blueprint require some fields to be initialised on startup, these fields will be initialised with default values if you will use Blueprint.create() static function from Blueprint class:

Blueprint blueprint = Blueprint.create();

After that you can change any required element fields and add/remove elements. Example:

Blueprint blueprint = Blueprint.create(); // Create blueprint
blueprint.name = "MyGreatBlueprint"; // Set bluepint name

// Set blueprint size
blueprint.setSize(2, 2, 2);

// Creating new element
BlueprintElement element = new BlueprintElement(BlueprintElementType.BLOCK);
element.setPosition(0, 1, 0); // Set element relative position
element.setSize(size, 0.01F, 0.01F); // Set element size
element.setColor(255, 0, 0, 128); // Set element color (red)
element.texture = 800; // Set element texture, 800 = emissive material
blueprint.addElement(element); // Adding element to blueprint

// Save blueprint to file
File outputFile = new File("./MyGreatBlueprint.blueprint");
try {
    BlueprintIO.write(blueprint, outputFile);
}
catch (IOException exception) {
    exception.printStackTrace();
}

Objects and Plants have almost same behaviour and constructors as Elements.

Loading existing blueprint

If you need to load and modify existing blueprint you can do it with BlueprintIO:

File file = new File("./MyGreatBlueprint.blueprint");
Blueprint blueprint = null;
try {
    blueprint = BlueprintIO.read(file);
}
catch (IOException exception) {
    exception.printStackTrace();
}

Now you can change it in any way you need and save it with same method as in section above.

About

A library for Rising World Unity blueprint format

License:MIT License


Languages

Language:Java 100.0%