DGLAB x Minecraft - Integration with Stimulation Devices
This mod creates a bridge between Minecraft and DG-LAB devices, allowing game events to directly influence stimulation intensity.
Getting Started
To use the mod, you need to install it together with KubeJS in the mods folder. After launching the game, you can write JavaScript scripts that determine how different game situations affect stimulation parameters.
Script Examples
Here's how to configure a response to character death:
// Full list of events available at https://wiki.latvian.dev/books/kubejs/page/list-of-events
EntityEvents.death('player', event => {
// Search for active connection by player UUID
const connection = DgLabManager.getByUUID(event.getEntity().getUuid())
// If connection exists
if (connection != null) {
// Get current intensity values
connection.getStrength().getACurrentStrength()
connection.getStrength().getBCurrentStrength()
connection.getStrength().getAMaxStrength()
connection.getStrength().getBMaxStrength()
// Add 10 intensity units to channel A
connection.addStrength(ChannelType.A, 10)
}
})
And this script responds to taking damage:
EntityEvents.afterHurt('player', event => {
let connection = DgLabManager.getByUUID(event.getEntity().getUuid())
if (connection != null) {
let damage = event.getDamage()
let strength = 0;
if (damage >= 20) {
strength = 100
} else {
strength = Math.ceil((damage / 20) 100)
}
// Create pulsating effect with gradual increase and decrease
let pulse = DgLabPulseUtil.pulse(
500, 0,
500, 0,
500, 0,
500, 0,
500, Math.ceil(strength / 3),
500, Math.ceil(strength / 3),
500, Math.ceil(strength / 3),
500, Math.ceil(strength / 3),
500, Math.ceil((strength / 3) 2),
500, Math.ceil((strength / 3) 2),
500, Math.ceil((strength / 3) 2),
500, Math.ceil((strength / 3) 2),
500, Math.ceil(strength),
500, Math.ceil(strength),
500, Math.ceil(strength),
500, Math.ceil(strength),
500, Math.ceil((strength / 3) 2),
500, Math.ceil((strength / 3) 2),
500, Math.ceil((strength / 3) 2),
500, Math.ceil((strength / 3) * 2),
500, Math.ceil(strength / 3),
500, Math.ceil(strength / 3),
500, Math.ceil(strength / 3),
500, Math.ceil(strength / 3),
500, 0,
500, 0,
500, 0,
500, 0
)
// Apply pulsation to channel A
connection.addPulse('a', pulse)
}
})
The first example adds intensity when the player dies, while the second creates a wave-like effect when taking damage, where the impact strength depends on the amount of damage received.
Device Connection
In the game, use the command /dglab connect to get a link with a QR code. Scan it in the DG-LAB app to establish a connection with the game.
Configuration
The configuration file is located at .minecraft/config/dglab.yml and is created on the first game launch.
address (String) - IP address for WebSocket connection. If the phone and computer are on the same local network, specify the computer's IP address like 192.168.xx.xx
port (int) - Port for creating WebSocket server that the DG-LAB app connects to