Package net.commoble.databuddy.datagen

# Class BlockStateBuilder

java.lang.Object
net.commoble.databuddy.datagen.BlockStateBuilder

public final class BlockStateBuilder extends Object
Alternative datageneration for blockstate jsons Use `singleVariant(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked)`, `variants(java.util.function.Consumer<net.commoble.databuddy.datagen.BlockStateBuilder.Variants>)`, or `multipart(java.util.function.Consumer<net.commoble.databuddy.datagen.BlockStateBuilder.Multipart>)` to build a BlockModelDefinition (the java representation of a blockstate json). `model(net.minecraft.resources.ResourceLocation)` or its overloads can help create BlockStateModel.Unbakeds (the json objects with model, x, y, uvlock) when the builders ask for one. `addDataProvider(GatherDataEvent, Map)` is a shortcut for creating the dataprovider from a map of BlockModelDefinitions.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static final record`
`BlockStateBuilder.Multipart`
Multipart format for blockstate jsons.
`static final record`
`BlockStateBuilder.OrWhen`
Component of Multipart definitions' 'when' blocks.
`static final record`
`BlockStateBuilder.PropertyValueList`
Component of Variants definitions, representing one or more property-value entries, e.g.
`static final record`
`BlockStateBuilder.Variants`
Represents a "variants" block in a blockstate json.
`static final record`
`BlockStateBuilder.When`
Component of Multipart definitions representing a blockstate predicate.

## Method Summary

Modifier and Type
Method
Description
`static void`
`addDataProvider(net.neoforged.neoforge.data.event.GatherDataEvent event, Map<net.minecraft.resources.ResourceLocation,net.minecraft.client.renderer.block.model.BlockModelDefinition> blockStates)`
Helper to add a dataprovider for blockstate jsons
`static net.minecraft.client.renderer.block.model.BlockModelDefinition`
`custom(net.neoforged.neoforge.client.model.block.CustomBlockModelDefinition customBlockModelDefinition)`
Creates a non-vanilla BlockModelDefinition
`static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked`
`model(net.minecraft.resources.ResourceLocation model)`
Returns new Unbaked BlockStateModel with no rotation, no uvlock.
`static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked`
`model(net.minecraft.resources.ResourceLocation model, com.mojang.math.Quadrant x, com.mojang.math.Quadrant y)`
Returns new Unbaked BlockStateModel with specified rotation and no uvlock.
`static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked`
`model(net.minecraft.resources.ResourceLocation model, com.mojang.math.Quadrant x, com.mojang.math.Quadrant y, boolean uvLock)`
Returns new Unbaked BlockStateModel with specified rotation and uvlock.
`static net.minecraft.client.renderer.block.model.BlockModelDefinition`
`multipart(Consumer<BlockStateBuilder.Multipart> multipartBuilder)`
Builds and returns a BlockModelDefinition for a multipart blockstate json.
`static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked`
`randomModels(net.minecraft.util.random.Weighted<net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked> firstModel, net.minecraft.util.random.Weighted<net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked> secondModel, net.minecraft.util.random.Weighted<net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked>... additionalModels)`
Returns new Unbaked BlockStateModel for random selection from a list of two or more Weighted models (e.g. like how stone is).
`static net.minecraft.client.renderer.block.model.BlockModelDefinition`
`singleVariant(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked model)`
Creates and returns a BlockModelDefinition for a variants-type blockstate json which assigns one model to all states.
`static net.minecraft.client.renderer.block.model.BlockModelDefinition`
`variants(Consumer<BlockStateBuilder.Variants> variantsBuilder)`
Builds and returns a BlockModelDefinition for a variants blockstate json.
`static net.minecraft.client.renderer.block.model.BlockModelDefinition`
`variantsAndMultipart(Consumer<BlockStateBuilder.Variants> variantsBuilder, Consumer<BlockStateBuilder.Multipart> multipartBuilder)`
Builds and returns a BlockModelDefinition which has both variants and multipart

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### addDataProvider

public static void addDataProvider(net.neoforged.neoforge.data.event.GatherDataEvent event, Map<net.minecraft.resources.ResourceLocation,net.minecraft.client.renderer.block.model.BlockModelDefinition> blockStates)
Helper to add a dataprovider for blockstate jsons

Parameters:
  `event` - GatherDataEvent
  `blockStates` - Map of BlockModelDefinitions (blockstate jsons) by id. Use `singleVariant(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked)`, `variants(java.util.function.Consumer<net.commoble.databuddy.datagen.BlockStateBuilder.Variants>)`, or `multipart(java.util.function.Consumer<net.commoble.databuddy.datagen.BlockStateBuilder.Multipart>)` to create BlockModelDefinitions to add to this map, or `custom(net.neoforged.neoforge.client.model.block.CustomBlockModelDefinition)` for non-vanilla implementations

### singleVariant

public static net.minecraft.client.renderer.block.model.BlockModelDefinition singleVariant(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked model)
Creates and returns a BlockModelDefinition for a variants-type blockstate json which assigns one model to all states.

Parameters:
  `model` - Unbaked BlockStateModel to use, e.g.

      {
        "model": "foo:bar",
        "x": 90,
        "y": 180,
        "uvlock": true
      }

  see `model(net.minecraft.resources.ResourceLocation)` or its overloads for helpers to create vanilla models (or a CustomUnbakedBlockStateModel can be used by constructing it yourself)
Returns:
  BlockModelDefinition for a blockstate json of the form

      {
        "variants": {
          "": {"model": "foo:bar"}
      	}
      }

### variants

public static net.minecraft.client.renderer.block.model.BlockModelDefinition variants(Consumer<BlockStateBuilder.Variants> variantsBuilder)
Builds and returns a BlockModelDefinition for a variants blockstate json.

Parameters:
  `variantsBuilder` - Variants builder which cases can be added too, see Variants javadoc for details
Returns:
  BlockModelDefinition for a blockstate json of the form

      {
      	"variants": {
         "powered=false": {"model": "foo:bar"},
         "powered=true": {"model": "foo:bar_powered"}
       }
      }

### multipart

public static net.minecraft.client.renderer.block.model.BlockModelDefinition multipart(Consumer<BlockStateBuilder.Multipart> multipartBuilder)
Builds and returns a BlockModelDefinition for a multipart blockstate json.

Parameters:
  `multipartBuilder` - Multipart builder which when-apply cases can be added to, see Multipart javadoc for details
Returns:
  BlockModelDefinition for a blockstate json of the form

      {
        "multipart": [
          {
            "when": {"powered": false},
            "apply": {"model": "foo:bar"}
          }
        ]
      }

### variantsAndMultipart

public static net.minecraft.client.renderer.block.model.BlockModelDefinition variantsAndMultipart(Consumer<BlockStateBuilder.Variants> variantsBuilder, Consumer<BlockStateBuilder.Multipart> multipartBuilder)
Builds and returns a BlockModelDefinition which has both variants and multipart

Parameters:
  `variantsBuilder` - Variants builder
  `multipartBuilder` - Multipart builder
Returns:
  BlockModelDefinition for a blockstate json which has both variants and multipart

### custom

public static net.minecraft.client.renderer.block.model.BlockModelDefinition custom(net.neoforged.neoforge.client.model.block.CustomBlockModelDefinition customBlockModelDefinition)
Creates a non-vanilla BlockModelDefinition

Parameters:
  `customBlockModelDefinition` - CustomBlockModelDefinition (not variants or multipart)
Returns:
  BlockModelDefinition for blockstate json with non-vanilla format

### model

public static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked model(net.minecraft.resources.ResourceLocation model)
Returns new Unbaked BlockStateModel with no rotation, no uvlock.

Parameters:
  `model` - ResourceLocation of a model, e.g. "minecraft:block/dirt"
Returns:
  new Unbaked BlockStateModel with no rotation, no uvlock

### model

public static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked model(net.minecraft.resources.ResourceLocation model, com.mojang.math.Quadrant x, com.mojang.math.Quadrant y)
Returns new Unbaked BlockStateModel with specified rotation and no uvlock.

Parameters:
  `model` - ResourceLocation of a model, e.g. "minecraft:block/dirt"
  `x` - x-rotation to apply to the model
  `y` - y-rotation to apply to the model
Returns:
  new Unbaked BlockStateModel with specified rotation and no uvlock

### model

public static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked model(net.minecraft.resources.ResourceLocation model, com.mojang.math.Quadrant x, com.mojang.math.Quadrant y, boolean uvLock)
Returns new Unbaked BlockStateModel with specified rotation and uvlock.

Parameters:
  `model` - ResourceLocation of a model, e.g. "minecraft:block/dirt"
  `x` - x-rotation to apply to the model
  `y` - y-rotation to apply to the model
  `uvLock` - whether to lock UVs
Returns:
  new Unbaked BlockStateModel with specified rotation and uvlock

### randomModels

@SafeVarargs public static net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked randomModels(net.minecraft.util.random.Weighted<net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked> firstModel, net.minecraft.util.random.Weighted<net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked> secondModel, net.minecraft.util.random.Weighted<net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked>... additionalModels)
Returns new Unbaked BlockStateModel for random selection from a list of two or more Weighted models (e.g. like how stone is).

Parameters:
  `firstModel` - Weighted BlockStateModel.Unbaked, e.g. new Weighted(BlockStateBuilder.model(ResourceLocation.fromNamespaceAndPath("foo","bar")), 1)
  `secondModel` - another weighted model
  `additionalModels` - more weighted models as needed
Returns:
  new Unbaked BlockStateModel for random selection from a list of two or more Weighted models (e.g. like how stone is)