public StateContainer(List<IProperty<?>> properties) { List<IProperty<?>> sortedProperties = Lists.newArrayList(properties); Collections.sort(sortedProperties, PROPERTY_NAME_COMPARATOR); List<Collection<? extends Comparable<?>>> allAlowedValues = Lists.newArrayList(); for (IProperty<?> property : sortedProperties) allAlowedValues.add(property.getAllowedValues()); final Map<Map<IProperty<?>, Comparable<?>>, State> valuesToStateMap = Maps.newHashMap(); final List<State> allStates = Lists.newArrayList(); for (List<Comparable<?>> values : Cartesian.cartesianProduct(allAlowedValues)) { final Map<IProperty<?>, Comparable<?>> propertyValueMap = joinLists(sortedProperties, values); final State itemState = new State(propertyValueMap); allStates.add(itemState); valuesToStateMap.put(propertyValueMap, itemState); } for (State state : allStates) state.updateNeighbours(valuesToStateMap); this.allStates = ImmutableList.copyOf(allStates); this.baseState = allStates.get(0); }
protected BlockStateContainer(Block p_i9_1_, IProperty<?>[] p_i9_2_, ImmutableMap < IUnlistedProperty<?>, Optional<? >> p_i9_3_) { this.block = p_i9_1_; Map < String, IProperty<? >> map = Maps. < String, IProperty<? >> newHashMap(); for (IProperty<?> iproperty : p_i9_2_) { validateProperty(p_i9_1_, iproperty); map.put(iproperty.getName(), iproperty); } this.properties = ImmutableSortedMap. < String, IProperty<? >> copyOf(map); Map < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > map2 = Maps. < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > newLinkedHashMap(); List<BlockStateContainer.StateImplementation> list = Lists.<BlockStateContainer.StateImplementation>newArrayList(); for (List < Comparable<? >> list1 : Cartesian.cartesianProduct(this.getAllowedValues())) { Map < IProperty<?>, Comparable<? >> map1 = MapPopulator. < IProperty<?>, Comparable<? >> createMap(this.properties.values(), list1); BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation = this.createState(p_i9_1_, ImmutableMap. < IProperty<?>, Comparable<? >> copyOf(map1), p_i9_3_); map2.put(map1, blockstatecontainer$stateimplementation); list.add(blockstatecontainer$stateimplementation); } for (BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation1 : list) { blockstatecontainer$stateimplementation1.buildPropertyValueTable(map2); } this.validStates = ImmutableList.copyOf(list); }
protected BlockStateContainer(Block blockIn, IProperty<?>[] properties, ImmutableMap<net.minecraftforge.common.property.IUnlistedProperty<?>, com.google.common.base.Optional<?>> unlistedProperties) { this.block = blockIn; Map < String, IProperty<? >> map = Maps. < String, IProperty<? >> newHashMap(); for (IProperty<?> iproperty : properties) { validateProperty(blockIn, iproperty); map.put(iproperty.getName(), iproperty); } this.properties = ImmutableSortedMap. < String, IProperty<? >> copyOf(map); Map < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > map2 = Maps. < Map < IProperty<?>, Comparable<? >> , BlockStateContainer.StateImplementation > newLinkedHashMap(); List<BlockStateContainer.StateImplementation> list1 = Lists.<BlockStateContainer.StateImplementation>newArrayList(); for (List < Comparable<? >> list : Cartesian.cartesianProduct(this.getAllowedValues())) { Map < IProperty<?>, Comparable<? >> map1 = MapPopulator. < IProperty<?>, Comparable<? >> createMap(this.properties.values(), list); BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation = createState(blockIn, ImmutableMap.copyOf(map1), unlistedProperties); map2.put(map1, blockstatecontainer$stateimplementation); list1.add(blockstatecontainer$stateimplementation); } for (BlockStateContainer.StateImplementation blockstatecontainer$stateimplementation1 : list1) { blockstatecontainer$stateimplementation1.buildPropertyValueTable(map2); } this.validStates = ImmutableList.<IBlockState>copyOf(list1); }