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:
BlockStateProvider
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... models)
Assign some models to a givenpartial state
.private boolean
forAllStates(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.JsonObject
toJson()
-
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:
toJson
in interfaceIGeneratedBlockstate
-
addModels
public VariantBlockStateBuilder addModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... models)Assign some models to a givenpartial state
.- Parameters:
state
- Thepartial state
for which to add the modelsmodels
- A set of models to add to this state- Returns:
- this builder
- Throws:
NullPointerException
- ifstate
isnull
IllegalArgumentException
- ifmodels
is emptyIllegalArgumentException
- ifstate
's owning block differs from the builder'sIllegalArgumentException
- ifstate
partially 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 state
for which to set the modelsmodel
- A set of models to assign to this state- Returns:
- this builder
- Throws:
IllegalArgumentException
- ifstate
has already been configured- See Also:
addModels(PartialBlockstate, ConfiguredModel...)
-
disjointToAll
-
partialState
-
forAllStates
-
forAllStatesExcept
public VariantBlockStateBuilder forAllStatesExcept(Function<BlockState,ConfiguredModel[]> mapper, Property<?>... ignored)
-