use of com.almuradev.content.type.block.state.value.StateValue in project Almura by AlmuraDev.
the class StatefulLazyBlockState method createState.
@Override
<T extends Comparable<T>> IBlockState createState() {
final Block block = (Block) this.block.require();
IBlockState state = block.getDefaultState();
for (final Map.Entry<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> entry : this.properties.get().entrySet()) {
@Nullable final IProperty<T> property = (IProperty<T>) entry.getKey();
if (property != null) {
@Nullable final T value = ((StateValue<T>) entry.getValue()).get(property);
if (value != null) {
state = state.withProperty(property, value);
}
}
}
return state;
}
use of com.almuradev.content.type.block.state.value.StateValue in project Almura by AlmuraDev.
the class StatefulLazyBlockState method resolveProperties.
private <T extends Comparable<T>> Map<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> resolveProperties(final Map<String, StateValue<? extends Comparable<?>>> source) {
final Block block = (Block) this.block.require();
final Map<IProperty<? extends Comparable<?>>, StateValue<? extends Comparable<?>>> target = new HashMap<>();
final BlockStateContainer definition = block.getBlockState();
for (final Map.Entry<String, StateValue<? extends Comparable<?>>> entry : source.entrySet()) {
@Nullable final IProperty<T> property = (IProperty<T>) definition.getProperty(entry.getKey());
if (property != null) {
target.put(property, entry.getValue());
}
}
return target;
}
Aggregations