Package net.commoble.databuddy.datagen

# Record Class BlockStateBuilder.Multipart

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

Record Components:
  `cases` - List of when-apply components.

Enclosing class:
  `BlockStateBuilder`

public static record BlockStateBuilder.Multipart(List<net.commoble.databuddy.datagen.BlockStateBuilder.WhenApply> cases) extends Record
Multipart format for blockstate jsons. Assigns models to blockstates by comparing states to property-value predicate Cases. Multiple models can be applied to individual blockstates. When used with the Variants format, models applied by Variants will override models applied by Multiparts. Can be used as a builder like so:

    BlockStateBuilder.multipart(multipart -> multipart
      .apply(BlockStateBuilder.model(ResourceLocation.fromNamespaceAndPath("foo", "bar")))
      .applyWhen(BlockStateBuilder.model(ResourceLocation.fromNamespaceAndPath("foo", "bar_powered")), BlockStateProperties.POWERED, true)
      .applyWhenAll(BlockStateBuilder.model(ResourceLocation.fromNamespaceAndPath("foo", "bar_lit")), when -> when
        .addCondition(BlockStateProperties.POWERED, false)
        .addCondition(BlockStateProperties.LIT, true)));

Which results in the json:

    {
      "multipart": [
        {
          "apply": {"model": "foo:bar"},
        },
        {
          "when": {"powered": "true"},
          "apply": {"model": "foo:bar_powered"}
        },
        {
          "when": {"powered": "false", "lit": "true"},
          "apply": {"model": "foo:bar_lit"}
        }
      ]
    }

## Constructor Summary

Constructors
Constructor
Description
`Multipart(List<net.commoble.databuddy.datagen.BlockStateBuilder.WhenApply> cases)`
Creates an instance of a `Multipart` record class.

## Method Summary

Modifier and Type
Method
Description
`BlockStateBuilder.Multipart`
`apply(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply)`
Applies a model to all blockstates, e.g.
`final <T extends Comparable<T>>
BlockStateBuilder.Multipart`
`applyWhen(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply, net.minecraft.world.level.block.state.properties.Property<T> property, T value, T... additionalValues)`
Applies a model to blockstates which have any specified value of the specified property, e.g.
`BlockStateBuilder.Multipart`
`applyWhenAll(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply, Consumer<BlockStateBuilder.When> whenBuilder)`
Applies a model to blockstates which match all property-values specified via the provided When builder, with results like:

      "when": {
        "lit": "false",
        "powered": "true"
      },
      "apply": {"model": "foo:bar"}

`BlockStateBuilder.Multipart`
`applyWhenOr(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply, Consumer<BlockStateBuilder.OrWhen> orWhenBuilder)`
Applies a model to blockstates which match any specified cases specified via the provided OrWhen builder
`List<net.commoble.databuddy.datagen.BlockStateBuilder.WhenApply>`
`cases()`
Returns the value of the `cases` record component.
`final boolean`
`equals(Object o)`
Indicates whether some other object is "equal to" this one.
`final int`
`hashCode()`
Returns a hash code value for this object.
`final String`
`toString()`
Returns a string representation of this record class.

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

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Multipart

public Multipart(List<net.commoble.databuddy.datagen.BlockStateBuilder.WhenApply> cases)
Creates an instance of a `Multipart` record class.

Parameters:
  `cases` - the value for the `cases` record component

## Method Details

### apply

public BlockStateBuilder.Multipart apply(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply)
Applies a model to all blockstates, e.g. {"apply": {"model": "foo:bar"}}

Parameters:
  `apply` - BlockStateModel.Unbaked to apply to all blockstates, see `BlockStateBuilder.model(net.minecraft.resources.ResourceLocation)` or its overloads to help create these
Returns:
  this

### applyWhen

@SafeVarargs public final <T extends Comparable<T>> BlockStateBuilder.Multipart applyWhen(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply, net.minecraft.world.level.block.state.properties.Property<T> property, T value, T... additionalValues)
Applies a model to blockstates which have any specified value of the specified property, e.g.

    {
      "when": {
        "powered": "true"
      },
      "apply": {"model": "foo:bar"}
    }

Type Parameters:
  `T` - type of the blockstate property's values, e.g. Boolean
Parameters:
  `apply` - BlockStateModel.Unbaked to apply to blockstates which match the criteria
  `property` - blockstate Property to filter states by, e.g. BlockStateProperties.POWERED
  `value` - blockstate Property value to filter states by, e.g. true
  `additionalValues` - additional blockstate property values which the state can match any of
Returns:
  this

### applyWhenAll

public BlockStateBuilder.Multipart applyWhenAll(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply, Consumer<BlockStateBuilder.When> whenBuilder)
Applies a model to blockstates which match all property-values specified via the provided When builder, with results like:

      "when": {
        "lit": "false",
        "powered": "true"
      },
      "apply": {"model": "foo:bar"}

Parameters:
  `apply` - BlockStateModel.Unbaked to apply to blockstates which match all property-values added to the When
  `whenBuilder` - When to add property values to, see When javadocs for details
Returns:
  this

### applyWhenOr

public BlockStateBuilder.Multipart applyWhenOr(net.minecraft.client.renderer.block.model.BlockStateModel.Unbaked apply, Consumer<BlockStateBuilder.OrWhen> orWhenBuilder)
Applies a model to blockstates which match any specified cases specified via the provided OrWhen builder

Parameters:
  `apply` - BlockStateModel.Unbaked to apply to blockstates which match any property values added to the OrWhen
  `orWhenBuilder` - OrWhen consumer to add property values to, see OrWhen javadocs for details
Returns:
  this

### toString

public final String toString()
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.

Specified by:
  `toString` in class `Record`
Returns:
  a string representation of this object

### hashCode

public final int hashCode()
Returns a hash code value for this object. The value is derived from the hash code of each of the record components.

Specified by:
  `hashCode` in class `Record`
Returns:
  a hash code value for this object

### equals

public final boolean equals(Object o)
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with `Objects::equals(Object,Object)`.

Specified by:
  `equals` in class `Record`
Parameters:
  `o` - the object with which to compare
Returns:
  `true` if this object is the same as the `o` argument; `false` otherwise.

### cases

public List<net.commoble.databuddy.datagen.BlockStateBuilder.WhenApply> cases()
Returns the value of the `cases` record component.

Returns:
  the value of the `cases` record component