Need help with NBT Blockstates

Started by Dbok on

Topic category: Help with modding (Java Edition)

Last seen on 17:10, 11. Apr 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Need help with NBT Blockstates

I'm making a block with a NBT Logic tag named "powered" (ISPOWERED in .java file) that is either true or false. (This part is working as it shows in the F3 menu.) When attaching that blockstate to the blockstate JSON file, it results in broken textures. How can I fix this?

This is the JSON code. Any help is appreciated!

{
"variants": {
"facing=north,powered=false": {
"model": "farmsandfood:block/redstone_burner"
},
"facing=east,powered=false": {
"model": "farmsandfood:block/redstone_burner",
"y": 90
},
"facing=south,powered=false": {
"model": "farmsandfood:block/redstone_burner",
"y": 180
},
"facing=west,powered=false": {
"model": "farmsandfood:block/redstone_burner",
"y": 270
},
"facing=north,powered=true": {
"model": "farmsandfood:block/redstone_burner_lit"
},
"facing=east,powered=true": {
"model": "farmsandfood:block/redstone_burner_lit",
"y": 90
},
"facing=south,powered=true": {
"model": "farmsandfood:block/redstone_burner_lit",
"y": 180
},
"facing=west,powered=true": {
"model": "farmsandfood:block/redstone_burner_lit",
"y": 270
}
}
}
Last seen on 05:10, 3. Dec 2023
Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The issue with using a…
Fri, 09/22/2023 - 16:58

The issue with using a custom blockstate is that you have to define it in your block's code, which means you will have to lock the code. Here's an example code from my current mod I'm working on: https://imgur.com/NahWb1a

 

There are two crucial parts, the first being defining the blockstate/property:

public static final BooleanProperty NAME = BlockStateProperties.NAME;

And then you have to tell the game what the default is:

this.registerDefaultState(this.stateDefinition.any().setValue(NAME, VALUE);