
Persistent Blocks Data
A simple utility for storing persistent data chained to blocks in paper plugins using PersistentDataContainer.
KOTLIN ONLY
Usage
You can write data as if you are just interacting with PersistentDataContainer.
import dev.devoirr.pbd.Blocks.getPersistentData
import dev.devoirr.pbd.Blocks.setPersistentData
import org.bukkit.NamespacedKey
import org.bukkit.block.Block
import org.bukkit.persistence.PersistentDataType
class SomeClass {
val key = NamespacedKey.minecraft("current_clicks")
fun addAndReturnClicks(block: Block): Int {
val currentClicks = block.getPersistentData(key, PersistentDataType.INTEGER) as? Int ?: 0
val updatedClicks = currentClicks + 1
block.setPersistentData(key, PersistentDataType.INTEGER, updatedClicks)
return updatedClicks
}
}
Warning
You need to take into account that the NamespacedKey has limited length (32768 symbols), and the lib adds blocks coordinates to the initial provided key, so don't use ridiculously long keys, otherwise it will break.
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.21, 1.21.1, 1.21.2
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Modrinth — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
Verified by MCModsHub
- Ships as PersistentBlockData.jar — drop this file into the mods folder
- Download size: 4 KB
- Download link checked 22 Aug 2026 — working
These come from our own check of the pack file, not from the source page.