#Setblock only works on first tick, sequential ticks do not work

25 messages · Page 1 of 1 (latest)

worthy flume
#

Here's the ticking code (if you're willing to read it). Could lag be an issue?

strong zincBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

lucid pythonBOT
#

Paste version of message.txt from @worthy flume

worthy flume
#

Dang you need a text editor to read that code

dark cloud
#

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.

tight mesa
#
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)

#

const is 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!
  }
}
tight mesa
#

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)

worthy flume
tight mesa
#

Is the error redeclaration of var?

worthy flume
tight mesa
#

Check the console (latest.log)

worthy flume
#

no errors or warning

tight mesa
#

KubeJS errors are only caught during initial script load, not when something runs a JS script

#

So check the console, NOT /kubejs errors

worthy flume
#

including during startup

worthy flume
#

(kinda grasping at straws atm)

worthy flume
#

figured it out. it was a problem with my logic.