Title, I'm trying to make every red wool block between two points turn into a custom block when a player jumps, then back into a red wool block when they jump again. I do have a script that works, but it's using minecraft's fill command replace function, and there's a noticeable stutter since the area I'm trying to target is relatively large. I'm wondering if there's a way to do this without runCommandSilent.
Here's my script that works for reference
let $EntityJump = Java.loadClass("net.minecraftforge.event.entity.living.LivingEvent$LivingJumpEvent");
global.switch = 0
ForgeEvents.onEvent($EntityJump, event => {
if(event.entity.level.clientSide) {
if (global.switch == 0) {
Utils.server.runCommandSilent(`fill 254 -30 -29 225 -20 -57 minecraft:red_wool replace kubejs:red_swap`)
global.switch = 1
return
}
if (global.switch == 1) {
Utils.server.runCommandSilent(`fill 254 -30 -29 225 -20 -57 kubejs:red_swap replace minecraft:red_wool`)
global.switch = 0
return
}
}})