public class VariantBlockStateBuilder extends java.lang.Object implements IGeneratedBlockstate
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, IProperty...)
for cases where the model
for each variant can be decided dynamically based on the state's property
values.
BlockStateProvider
Modifier and Type | Class and Description |
---|---|
static class |
VariantBlockStateBuilder.PartialBlockstate |
Modifier and Type | Field and Description |
---|---|
private java.util.Set<BlockState> |
coveredStates |
private java.util.Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> |
models |
private Block |
owner |
Constructor and Description |
---|
VariantBlockStateBuilder(Block owner) |
private final Block owner
private final java.util.Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> models
private final java.util.Set<BlockState> coveredStates
VariantBlockStateBuilder(Block owner)
public java.util.Map<VariantBlockStateBuilder.PartialBlockstate,BlockStateProvider.ConfiguredModelList> getModels()
public Block getOwner()
public com.google.gson.JsonObject toJson()
toJson
in interface IGeneratedBlockstate
public VariantBlockStateBuilder addModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... models)
partial state
.state
- The partial state
for which to add
the modelsmodels
- A set of models to add to this statejava.lang.NullPointerException
- if state
is null
java.lang.IllegalArgumentException
- if models
is emptyjava.lang.IllegalArgumentException
- if state
's owning block differs from
the builder'sjava.lang.IllegalArgumentException
- if state
partially matches another
state which has already been configuredpublic VariantBlockStateBuilder setModels(VariantBlockStateBuilder.PartialBlockstate state, ConfiguredModel... model)
partial state
,
throwing an exception if the state has already been configured. Otherwise,
simply calls addModels(PartialBlockstate, ConfiguredModel...)
.state
- The partial state
for which to set
the modelsmodels
- A set of models to assign to this statejava.lang.IllegalArgumentException
- if state
has already been configuredaddModels(PartialBlockstate, ConfiguredModel...)
private boolean disjointToAll(VariantBlockStateBuilder.PartialBlockstate newState)
public VariantBlockStateBuilder.PartialBlockstate partialState()
public VariantBlockStateBuilder forAllStates(java.util.function.Function<BlockState,ConfiguredModel[]> mapper)
public VariantBlockStateBuilder forAllStatesExcept(java.util.function.Function<BlockState,ConfiguredModel[]> mapper, IProperty<?>... ignored)