isCustom(Block block);
customBlock(Block block);
customBlock(Location location);
block(String worldName, int x, int y, int z);
block(World world, int x, int y, int z);
block(Location location);
location(String worldName, int x, int y, int z);
removeBlock(Block block);
placeBlock(Block block, Material material);
placeBlock(Block block, CustomBlock customBlock);
placeBlock(Block block, String identifier);
Always check isCustom() before modifying custom items or blocks.
Log actions with log() during debugging.
Use cancelEvent() to prevent default behavior when handling interactions.
Example code
Replace near custom blocks.
cancelEvent(); // Cancel the event to prevent further processing
var location = $player.getLocation();
var count = 0;
// Iterate through all blocks in a 10x10x10 cube around the player and check isCustom(block) == true
for (var x = -5; x <= 5; x++) {
for (var y = -5; y <= 5; y++) {
for (var z = -5; z <= 5; z++) {
var block = location.getWorld().getBlockAt(location.getBlockX() + x, location.getBlockY() + y, location.getBlockZ() + z);
if (isCustom(block)) {
msg($player, "Found a custom block at " + block.getLocation().toString());
placeBlock(block, "minecraft:stone");
count++;
}
}
}
}
// Send a message to the player indicating that the script has finished running
msg($player, "Replaced " + count + " custom blocks with stone blocks.");