Search in sources :

Example 1 with ConfiguredModelList

use of net.minecraftforge.client.model.generators.BlockStateProvider.ConfiguredModelList in project MinecraftForge by MinecraftForge.

the class VariantBlockStateBuilder method addModels.

/**
 * Assign some models to a given {@link PartialBlockstate partial state}.
 *
 * @param state  The {@link PartialBlockstate partial state} for which to add
 *               the models
 * @param models A set of models to add to this state
 * @return this builder
 * @throws NullPointerException     if {@code state} is {@code null}
 * @throws IllegalArgumentException if {@code models} is empty
 * @throws IllegalArgumentException if {@code state}'s owning block differs from
 *                                  the builder's
 * @throws IllegalArgumentException if {@code state} partially matches another
 *                                  state which has already been configured
 */
public VariantBlockStateBuilder addModels(PartialBlockstate state, ConfiguredModel... models) {
    Preconditions.checkNotNull(state, "state must not be null");
    Preconditions.checkArgument(models.length > 0, "Cannot set models to empty array");
    Preconditions.checkArgument(state.getOwner() == owner, "Cannot set models for a different block. Found: %s, Current: %s", state.getOwner(), owner);
    if (!this.models.containsKey(state)) {
        Preconditions.checkArgument(disjointToAll(state), "Cannot set models for a state for which a partial match has already been configured");
        this.models.put(state, new ConfiguredModelList(models));
        for (BlockState fullState : owner.getStateDefinition().getPossibleStates()) {
            if (state.test(fullState)) {
                coveredStates.add(fullState);
            }
        }
    } else {
        this.models.compute(state, ($, cml) -> cml.append(models));
    }
    return this;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) ConfiguredModelList(net.minecraftforge.client.model.generators.BlockStateProvider.ConfiguredModelList)

Aggregations

BlockState (net.minecraft.world.level.block.state.BlockState)1 ConfiguredModelList (net.minecraftforge.client.model.generators.BlockStateProvider.ConfiguredModelList)1