Jigsaw Logic Lib
A library for mod developers that enables creating custom game logic when structures load in the world.
Installation
To add the library to your project, follow these steps:
Add to your build.gradle file:
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
modImplementation 'com.github.Totobird-Creations:JigsawLogicLib:${jigsawlogiclib_version}'
// Optional:
include 'com.github.Totobird-Creations:JigsawLogicLib:${jigsawlogiclib_version}'
}
Specify the version in gradle.properties:
jigsawlogiclib_version = v1.0.1-mc1.19
Add the dependency to your fabric.mod.json file:
"depends": {
"jigsawlogiclib": "1.x.x"
}
Usage
In your initializer's onInitialize method, add the following code:
LogicCommandManager.register(
new Identifier("yourModId", "commandName"),
(metadata, world, blockPos, structureOrigin) -> {
// Arguments:
// - String metadata : Additional information from the logic block.
// - World world : The world where the logic block is executed.
// - BlockPos blockPos : The position of the logic block during execution.
// - BlockPos structureOrigin : The position where structure generation started.
// Important notes:
// - If you modify blocks, make sure they are in the same chunk.
}
);
In-Game Procedure
- Set up the structure using regular structure blocks and place a logic block inside it.
- Obtain the logic block with the command:
/give @s jigsawlogiclib:logic - Place it and set the command value as specified above:
yourModId:commandName - Optionally add metadata that will be passed to your function.
- Save changes with the "Done" button or test using "Run".
- Save the structure and configure all necessary world generation files.