#Setblock only works on first tick, sequential ticks do not work
25 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
Paste version of message.txt from @worthy flume
Dang you need a text editor to read that code
Or click the button that the bot posted to read it. Very helpful.
Although, since it wasn't renamed, and just has the default message.txt, instead of anything.js, it doesn't do the syntax highlighting.
It's a bit too long for me to mentally parse right now, though. Someone else will have to help, or else me at a future time, but at the moment I'm mentally drained.
const coalBlockState = Block.getBlock("minecraft:coal_block").getBlockStates().get(0);
const airBlockState = Block.getBlock("minecraft:air").getBlockStates().get(0);
const fireBlockState = Block.getBlock("minecraft:fire").getBlockStates().get(0);
const blackGlassBlockState = Block.getBlock("minecraft:fire").getBlockStates().get(0);
const deepslateDiamondBlockState = Block.getBlock("minecraft:deepslate_diamond_ore").getBlockStates().get(0);
const autuniteBlockState = Block.getBlock("createnuclear:autunite").getBlockStates().get(0);
You are using consts within a block that isn't top level of a function.
Change those to let
(This is a Rhino bug, in normal JS this would work fine)
constis also bugged inside of blocks that aren't global or function scope.
const x = 5; // Fine
function myFun() {
const y = 7 // Fine
if (player != null) {
const z = 9 // Error: "Redeclaration of var" if this runs the second time!
}
}
Also, some tips:
- Instead of writing:
Block.getBlock("createnuclear:autunite").getBlockStates().get(0);
you can do:
Block.getBlock("createnuclear:autunite").defaultBlockState();
Or you could also make a function to get default states:
/** @param {Internal.ResourceLocation_} block */
const getState = (block) => Block.getBlock(block).defaultBlockState();
const airBlockState = getState("minecraft:air");
(be aware of where you put that, if you want to put this inside of a non-function/global block then use let instead of const)
let me try that
Thanks for the coding advice, tho the tick error still persists. Imma do some testing while you come up with ideas (at your own pace)
Is the error redeclaration of var?
no, it just doesn't update the blocks after the first tick
Check the console (latest.log)
no errors or warning
KubeJS errors are only caught during initial script load, not when something runs a JS script
So check the console, NOT /kubejs errors
Checked the console and there's no kubejs errors or warnings
including during startup
I think the error's caused cause the ticking script is on a startup event. Maybe if it were on a server event it would work just fine....
(kinda grasping at straws atm)
figured it out. it was a problem with my logic.