Class VariantBlockStateBuilder
- java.lang.Object
-
- net.minecraftforge.client.model.generators.VariantBlockStateBuilder
-
- All Implemented Interfaces:
IGeneratedBlockstate
public class VariantBlockStateBuilder extends java.lang.Object implements IGeneratedBlockstate
Builder for variant-type blockstates, i.e. non-multipart blockstates. Should not be manually instantiated, instead useBlockStateProvider.getVariantBuilder(Block)
.Variants can either be set via
setModels(PartialBlockstate, ConfiguredModel...)
oraddModels(PartialBlockstate, ConfiguredModel...)
, where model(s) can be assigned directly topartial states
, or builder style viapartialState()
and its subsequent methods.This class also provides the convenience methods
forAllStates(Function)
andforAllStatesExcept(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
Nested Classes Modifier and Type Class Description static class
VariantBlockStateBuilder.PartialBlockstate
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<BlockState>
coveredStates
private java.util.Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList>
models
private Block
owner
-
Constructor Summary
Constructors Constructor Description VariantBlockStateBuilder(Block owner)
-
Method Summary
-
-
-
Field Detail
-
owner
private final Block owner
-
models
private final java.util.Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> models
-
coveredStates
private final java.util.Set<BlockState> coveredStates
-
-
Constructor Detail
-
VariantBlockStateBuilder
VariantBlockStateBuilder(Block owner)
-
-
Method Detail
-
getModels
public java.util.Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> getModels()
-
getOwner
public Block 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:
java.lang.NullPointerException
- ifstate
isnull
java.lang.IllegalArgumentException
- ifmodels
is emptyjava.lang.IllegalArgumentException
- ifstate
's owning block differs from the builder'sjava.lang.IllegalArgumentException
- 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 modelsmodels
- A set of models to assign to this state- Returns:
- this builder
- Throws:
java.lang.IllegalArgumentException
- ifstate
has already been configured- See Also:
addModels(PartialBlockstate, ConfiguredModel...)
-
disjointToAll
private boolean disjointToAll(VariantBlockStateBuilder.PartialBlockstate newState)
-
partialState
public VariantBlockStateBuilder.PartialBlockstate partialState()
-
forAllStates
public VariantBlockStateBuilder forAllStates(java.util.function.Function<BlockState,ConfiguredModel[]> mapper)
-
forAllStatesExcept
public VariantBlockStateBuilder forAllStatesExcept(java.util.function.Function<BlockState,ConfiguredModel[]> mapper, Property<?>... ignored)
-
-