How do I create blockstates for a custom model?

Started by THE LIMINAL on

Topic category: Help with modding (Java Edition)

Last seen on 21:53, 12. Sep 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How do I create blockstates for a custom model?

Hello! I've just created a custom model on blockbench. I want it to behave like a wall, but I don't know how to create blockstates for it. Any assistance / guidance / tutorials would be welcome!

Last seen on 21:53, 12. Sep 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also, does anyone know if…
Tue, 08/30/2022 - 22:30

Also, does anyone know if there are plans to add this feature to mcreator?

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
As far as I know there are…
Wed, 08/31/2022 - 06:16

As far as I know there are no current plans to implement blockstates but that could change in the future. It is rather simple to do blockstates actually by editing the json file to set the block variants. The following contains a tutorial on how to create custom block property's to use in blockstate json files. It is actually not too difficult. It is not necessary to add a block property to do block variants, but it is the better way to do it.

In this example, I will recreate a "level" feature of a cauldron.

Step 1: Create your block. I recommend creating one with block directions to make it easier to find and edit block property's.

Step 2: Open the BlockNameBlock.Java file

Step 3: Find this this line:

    public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING;

Then Declare the following just under it:

   public static final IntegerProperty LEVEL = IntegerProperty.create("level", 0, 3);

Step 4: Find the class "public BlockNameBlock "

It should look similar to this:

public BrewingCauldronBlock() {
        super(BlockBehaviour.Properties.of(Material.METAL).sound(SoundType.GRAVEL).strength(1f, 10f).noOcclusion()
                .isRedstoneConductor((bs, br, bp) -> false));
        this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH));
    }

Step 5: Add your new block property to the line containing "this.registerDefaultState":

        this.registerDefaultState(this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(LEVEL, 0));

Step 6: Find the class "public BlockState getStateForPlacement(BlockPlaceContext context)":

@Override
    public BlockState getStateForPlacement(BlockPlaceContext context) {
        ;
        return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite());
    }

Step 7: Change the return value to include your new block property:

        return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()).setValue(LEVEL, 0);

Your Block should now have a functioning new block property! You can set this new block property using procedures, and then set block variants in your BlockNameBlockstates.json file. This is an example of mine below following this tutorial. The block property level is determined by right clicking with water bucket/bucket 3 levels or a water bottle/bottle for 1 level.

{
  "variants": {
      "level=0": {
      "model": "better_brewing:block/brewing_cauldron"
    },
    "level=1": {
      "model": "better_brewing:block/brewing_cauldron_level_one"
    },
    "level=2": {
      "model": "better_brewing:block/brewing_cauldron_level_two"
    },
    "level=3": {
      "model": "better_brewing:block/brewing_cauldron_level_three"
    }
  }
}
Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
The last part is the json…
Wed, 08/31/2022 - 06:28

The last part is the json blockstate file for the block. It can be used without all the custom code for the new blockstate property and use something else instead, but it best to use blockstate properties.

Last seen on 21:53, 12. Sep 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is it possible to take…
Wed, 08/31/2022 - 21:23

Is it possible to take minecraft's json files from its blockstate folder, paste them into my workspace's assets > [my-mod's-name-here] > blockstate folder, and edit as needed?

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Absolutely, that is probably…
Wed, 08/31/2022 - 23:13

Absolutely, that is probably the best way as well!

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Although that blockstate…
Wed, 08/31/2022 - 23:16

Although that blockstate generator only handles the basics really.

Last seen on 21:53, 12. Sep 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If it's not too much to ask,…
Sat, 09/03/2022 - 16:52

If it's not too much to ask, could you instruct me on how to use the blockstate generator?

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've honestly never used it…
Sun, 09/04/2022 - 13:31

I've honestly never used it so no I write mine by hand, I use that same kind of generator for other kidn of json files though, to help me get the notation of stuff correct usually. I know someone made a wall tutorial on making fences a while back. But I suggest looking at any of the fence json files.

Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
{ "multipart": [ { …
Sun, 09/04/2022 - 13:32
{
  "multipart": [
    {
      "apply": {
        "model": "minecraft:block/acacia_fence_post"
      }
    },
    {
      "when": {
        "north": "true"
      },
      "apply": {
        "model": "minecraft:block/acacia_fence_side",
        "uvlock": true
      }
    },
    {
      "when": {
        "east": "true"
      },
      "apply": {
        "model": "minecraft:block/acacia_fence_side",
        "y": 90,
        "uvlock": true
      }
    },
    {
      "when": {
        "south": "true"
      },
      "apply": {
        "model": "minecraft:block/acacia_fence_side",
        "y": 180,
        "uvlock": true
      }
    },
    {
      "when": {
        "west": "true"
      },
      "apply": {
        "model": "minecraft:block/acacia_fence_side",
        "y": 270,
        "uvlock": true
      }
    }
  ]
}
Last seen on 06:22, 13. Mar 2023
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Fences use different boolean…
Sun, 09/04/2022 - 13:35

Fences use different boolean blockstates for each direction to determine whether there is a block next to it that it should connect to.

Last seen on 21:53, 12. Sep 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
When I'm using the…
Sun, 09/04/2022 - 15:14

When I'm using the blockstate generator, should I set it to 'variants' or 'multipart'?

Last seen on 21:53, 12. Sep 2022
Joined Aug 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Never mind. Pointless…
Sun, 09/04/2022 - 15:15

Never mind. Pointless question. The json file literally already says it. Sorry.