For current mods, prefer the voxel operations exposed through ModAPI rather than direct unsafe voxel memory access. The generated typings already expose the most common runtime operations you need from TypeScript.
The practical order of preference is:
ModAPI helpers on VoxelDestructor or VoxelVolume.ModAPI.ModAPIThe generated typings expose common helpers such as:
DemolishVoxelSphereClearVoxelScreenLineClearVoxelBoxSweepClearVoxelCylinderExplodeVoxelObjectModifyVoxelPropertyProjectVoxelDecalThese are the preferred tools for gameplay features such as explosions, sword slashes, drilling, painting, or decals.
const ModAPI = VX.Mod.ModAPI;
ModAPI.DemolishVoxelSphere(
voxelDestructor,
impactPosition,
4.0,
25.0,
bindTo.transform.forward
);
The katana sample uses this pattern to cut voxel chunks:
ModAPI.ClearVoxelScreenLine(
voxelDestructor,
screenA,
screenB,
worldToScreen,
chunk
);
When you only need to inspect voxel data, use the read helpers:
GetVoxelSolidCountGetVoxelOriginalSolidCountGetVoxelSolidRatioGetVoxelAtWorldGetVoxelAtLocalGetVoxelAtHitconst ModAPI = VX.Mod.ModAPI;
const initialCount = ModAPI.GetVoxelOriginalSolidCount(voxelVolume);
const onVoxelModified = () => {
const ratio = ModAPI.GetVoxelSolidCount(voxelVolume) / initialCount;
if (ratio < 0.95) {
ModAPI.PlayVFX("NuclearBomb_Explode", bindTo.transform.position, 2.0);
}
};
ModAPI.AddVoxelModifiedListener(voxelVolume, onVoxelModified);
This is the same family of pattern used by the Homelander sample.
If you want a voxel object to burst apart rather than just lose a region, use:
VX.Mod.ModAPI.ExplodeVoxelObject(voxelDestructor, true, true);
Use this for scripted destruction set pieces, death reactions, or failure states.