LanternBlockState(LanternBlockStateMap baseState, ImmutableMap<BlockTrait<?>, Comparable<?>> traitValues) {
this.traitValues = traitValues;
this.baseState = baseState;
ImmutableBiMap.Builder<Key<Value<?>>, BlockTrait<?>> builder = ImmutableBiMap.builder();
for (BlockTrait trait : traitValues.keySet()) {
builder.put(((LanternBlockTrait) trait).getKey(), trait);
}
this.keyToBlockTrait = builder.build();
final StringBuilder idBuilder = new StringBuilder();
idBuilder.append(baseState.getBlockType().getId().substring(baseState.getBlockType().getPluginId().length() + 1));
if (!traitValues.isEmpty()) {
idBuilder.append('[');
final Joiner joiner = Joiner.on(',');
final List<String> propertyValues = new ArrayList<>();
for (Map.Entry<BlockTrait<?>, Comparable<?>> entry : traitValues.entrySet()) {
propertyValues.add(entry.getKey().getName() + "=" + entry.getValue().toString().toLowerCase(Locale.ENGLISH));
}
idBuilder.append(joiner.join(propertyValues));
idBuilder.append(']');
}
this.name = idBuilder.toString();
this.id = baseState.getBlockType().getPluginId() + ':' + this.name;
}
LanternBlockState.java 文件源码
java
阅读 23
收藏 0
点赞 0
评论 0
项目:LanternServer
作者:
评论列表
文章目录