#Error while modifying BlockState placement (1.19.2)

11 messages · Page 1 of 1 (latest)

mighty nest
#

I am trying to rotate a block on placement and am getting the following error:
[ERR] Error while modifying BlockState placement of kubejs:hayrack: dev.latvian.mods.rhino.EcmaError: TypeError: Cannot find function set(net.minecraft.class_2754,java.lang.String) in object Block{kubejs:hayrack}[facing=north].

I am using the following code:

event.create('hayrack').material('metal').hardness(0.5).defaultCutout().defaultTranslucent().property(BlockProperties.HORIZONTAL_FACING).placementState(placement => {placement['set(net.minecraft.class_2754,java.lang.String)'](BlockProperties.HORIZONTAL_FACING, placement.getHorizontalDirection().opposite())})
  })```

Any ideas why this is happening?
knotty tokenBOT
#

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

wet glacier
#

make its type cardinal instead of using that method

#

event.create('hayrack', 'cardinal').otherStuff()

mighty nest
#

it seems to crash the game when I do that. It says the following:

Caused by: java.lang.RuntimeException: Object 'kubejs:hayrack' of registry 'minecraft:block' hasn't been registered yet!
        at dev.latvian.mods.kubejs.BuilderBase.get(BuilderBase.java:59) ~[kubejs-forge-1902.6.0-build.135.jar%23253!/:1902.6.0-build.135] {re:classloading}
        at dev.latvian.mods.kubejs.block.BlockItemBuilder.createObject(BlockItemBuilder.java:21) ~[kubejs-forge-1902.6.0-build.135.jar%23253!/:1902.6.0-build.135] {re:classloading}
        at dev.latvian.mods.kubejs.block.BlockItemBuilder.createObject(BlockItemBuilder.java:12) ~[kubejs-forge-1902.6.0-build.135.jar%23253!/:1902.6.0-build.135] {re:classloading}
        at dev.latvian.mods.kubejs.BuilderBase.createTransformedObject(BuilderBase.java:113) ~[kubejs-forge-1902.6.0-build.135.jar%23253!/:1902.6.0-build.135] {re:classloading}

I can post more of the error if needed

wet glacier
#

script from that?

mighty nest
#

here's the full script:

  event.create('hayrack', 'cardinal').material('metal').hardness(0.5).defaultCutout().defaultTranslucent().property(BlockProperties.HORIZONTAL_FACING).placementState(placement => {placement['set(net.minecraft.class_2754,java.lang.String)'](BlockProperties.HORIZONTAL_FACING, placement.getHorizontalDirection().opposite())})
  })```

The only thing I can think of is that I am registering the block at the wrong point? But it works fine and registers without that extra 'cardinal' text
wet glacier
#

remoce all the stuff you copied from the other script (property, placement state), the cardinal type recplaces that

mighty nest
#

Ooh ok good to know - that worked perfectly.

For anyone who is wondering, here is the working script:

StartupEvents.registry('block', event => {
  event.create('hayrack', 'cardinal').material('metal').hardness(0.5).defaultCutout().defaultTranslucent()
  })

Is there any documentation on this cardinal type so I can learn more?

wet glacier
#

it was added in 1.19.2 and makes a block act like a furnace/carved pumpkin in the way its placed

mighty nest
#

It is exactly what I needed - thank you so much 🙂