#Block states for dynamically registered custom blocks with ROTATION_16 block property

9 messages · Page 1 of 1 (latest)

stiff hare
#

I have the following startup script snippet:

const block = e
  .create(id)
  .property(BlockProperties.ROTATION_16)
  ...
block.modelJson = {
  parent: 'kubejs:block/base_ingot_cast',
  textures: { base: baseTexture },
}
let variants = {}
for (let rotation = 0; rotation < 16; ++rotation) {
  variants[`rotation=${rotation}`] = {
    model: 'kubejs:block/base_ingot_cast',
    y: (rotation * 360) / 16,
  }
}
block.blockstateJson = {
  variants: variants,
}

base_ingot_cast.json is a block model with a parameterized texture in it, so I'm using this to autogenerate textures for all the ingot casts that I need with the right texture. I would also like this ingot to be placeable with ROTATION_16, so that means I need the right block state declaration. It seems to me like this should work. In logs though, I'm getting errors that seem to be looking for a different model name:

[03Aug2024 19:00:12.355] [Worker-ResourceReload-16/WARN] [net.minecraft.client.resources.model.ModelBakery/]: Exception loading blockstate definition: 'kubejs:blockstates/unfired_ingot_cast.json' missing model for variant: 'kubejs:unfired_ingot_cast#rotation=15'
[03Aug2024 19:00:12.355] [Worker-ResourceReload-16/WARN] [net.minecraft.client.resources.model.ModelBakery/]: Exception loading blockstate definition: 'kubejs:blockstates/unfired_ingot_cast.json' missing model for variant: 'kubejs:unfired_ingot_cast#rotation=12'
[03Aug2024 19:00:12.355] [Worker-ResourceReload-16/WARN] [net.minecraft.client.resources.model.ModelBakery/]: Exception loading blockstate definition: 'kubejs:blockstates/unfired_ingot_cast.json' missing model for variant: 'kubejs:unfired_ingot_cast#rotation=11'
[03Aug2024 19:00:12.355] [Worker-ResourceReload-16/WARN] [net.minecraft.client.resources.model.ModelBakery/]: Exception loading blockstate definition: 'kubejs:blockstates/unfired_ingot_cast.json' missing model for variant: 'kubejs:unfired_ingot_cast#rotation=14'
[03Aug2024 19:00:12.355] [Worker-ResourceReload-16/WARN] [net.minecraft.client.resources.model.ModelBakery/]: Exception loading blockstate definition: 'kubejs:blockstates/unfired_ingot_cast.json' missing model for variant: 'kubejs:unfired_ingot_cast#rotation=13'
[03Aug2024 19:00:12.355] [Worker-ResourceReload-16/WARN] [net.minecraft.client.resources.model.ModelBakery/]: Exception loading blockstate definition: 'kubejs:blockstates/unfired_ingot_cast.json' missing model for variant: 'kubejs:unfired_ingot_cast#rotation=10'

Is it possible to force it to reference that base model instead (keeping the parameterized texture in the model)?

violet archBOT
#

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

stiff hare
#

Block states for dynamically registered custom blocks with ROTATION_16 block property

#

Is the alternative to instead write the block state jsons dynamically to the kubejs/blockstate directory?

#

The block itself works without the rotation property, but I want to add the rotation property to it.

#

As another attempt, I also tried removing that code and adding the json to kubejs/assets/kubejs/blockstates/unfired_ingot_cast.json with ```json
{
"variants": {
"rotation=0": {
"model": "kubejs:block/base_ingot_cast",
"y": 11.25
},
"rotation=1": {
"model": "kubejs:block/base_ingot_cast",
"y": 22.5
},
"rotation=2": {
"model": "kubejs:block/base_ingot_cast",
"y": 33.75
},
"rotation=3": {
"model": "kubejs:block/base_ingot_cast",
"y": 45
},
...

#

I am still getting the missing model error in logs.

tepid peak
#

This normally means that you don't have a model defined for rotation=10 in the blockstate

stiff hare
#

I mean, yes, but why is it not recognizing the rotation=10 entry in my blockstate json?