Class VariantBlockStateBuilder
java.lang.Object
net.minecraftforge.client.model.generators.VariantBlockStateBuilder
- All Implemented Interfaces:
IGeneratedBlockstate
Builder for variant-type blockstates, i.e. non-multipart blockstates. Should
not be manually instantiated, instead use
BlockStateProvider.getVariantBuilder(Block).
Variants can either be set via
setModels(PartialBlockstate, ConfiguredModel...) or
addModels(PartialBlockstate, ConfiguredModel...), where model(s) can
be assigned directly to partial states, or builder
style via partialState() and its subsequent methods.
This class also provides the convenience methods
forAllStates(Function) and
forAllStatesExcept(Function, Property...) for cases where the model
for each variant can be decided dynamically based on the state's property
values.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set<BlockState>private final Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> private final Block -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... models) Assign some models to a givenpartial state.private booleanforAllStates(Function<BlockState, ConfiguredModel[]> mapper) forAllStatesExcept(Function<BlockState, ConfiguredModel[]> mapper, Property<?>... ignored) getOwner()setModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... model) Assign some models to a givenpartial state, throwing an exception if the state has already been configured.com.google.gson.JsonObjecttoJson()
-
Field Details
-
owner
-
models
private final Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> models -
coveredStates
-
-
Constructor Details
-
VariantBlockStateBuilder
VariantBlockStateBuilder(Block owner)
-
-
Method Details
-
getModels
public Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> getModels() -
getOwner
-
toJson
public com.google.gson.JsonObject toJson()- Specified by:
toJsonin interfaceIGeneratedBlockstate
-
addModels
public VariantBlockStateBuilder addModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... models) Assign some models to a givenpartial state.- Parameters:
state- Thepartial statefor which to add the modelsmodels- A set of models to add to this state- Returns:
- this builder
- Throws:
NullPointerException- ifstateisnullIllegalArgumentException- ifmodelsis emptyIllegalArgumentException- ifstate's owning block differs from the builder'sIllegalArgumentException- ifstatepartially matches another state which has already been configured
-
setModels
public VariantBlockStateBuilder setModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... model) Assign some models to a givenpartial state, throwing an exception if the state has already been configured. Otherwise, simply callsaddModels(PartialBlockstate, ConfiguredModel...).- Parameters:
state- Thepartial statefor which to set the modelsmodels- A set of models to assign to this state- Returns:
- this builder
- Throws:
IllegalArgumentException- ifstatehas already been configured- See Also:
-
disjointToAll
-
partialState
-
forAllStates
-
forAllStatesExcept
public VariantBlockStateBuilder forAllStatesExcept(Function<BlockState, ConfiguredModel[]> mapper, Property<?>... ignored)
-