private void CollectFromWorldProperties(CollectibleVariantGroup variantGroup, CollectibleVariantGroup[] variantgroups, OrderedDictionary <string, BlockVariant[]> blockvariantsMul, List <ResolvedBlockVariant> blockvariantsFinal, AssetLocation location) { StandardWorldProperty property = GetWorldPropertyByCode(variantGroup.LoadFromProperties); if (property == null) { api.Server.LogError( "Error in item or block {0}, worldproperty {1} does not exist (or is empty). Ignoring.", location, variantGroup.LoadFromProperties ); return; } string typename = variantGroup.Code == null ? property.Code.Path : variantGroup.Code; if (variantGroup.Combine == EnumCombination.Add) { foreach (WorldPropertyVariant variant in property.Variants) { ResolvedBlockVariant resolved = new ResolvedBlockVariant(); resolved.Codes.Add(typename, variant.Code.Path); blockvariantsFinal.Add(resolved); } } if (variantGroup.Combine == EnumCombination.Multiply) { blockvariantsMul.Add(typename, worldPropertiesVariants[property.Code]); } }
private void CollectFromStateList(CollectibleVariantGroup variantGroup, CollectibleVariantGroup[] variantgroups, OrderedDictionary <string, BlockVariant[]> blockvariantsMul, List <ResolvedBlockVariant> blockvariantsFinal, AssetLocation filename) { if (variantGroup.Code == null) { api.Server.LogError( "Error in itemtype {0}, a variantgroup using a state list must have a code. Ignoring.", filename ); return; } string[] states = variantGroup.States; string type = variantGroup.Code; // Additive state list if (variantGroup.Combine == EnumCombination.Add) { for (int j = 0; j < states.Length; j++) { ResolvedBlockVariant resolved = new ResolvedBlockVariant(); resolved.Codes.Add(type, states[j]); blockvariantsFinal.Add(resolved); } } // Multiplicative state list if (variantGroup.Combine == EnumCombination.Multiply) { List <BlockVariant> stateList = new List <BlockVariant>(); for (int j = 0; j < states.Length; j++) { stateList.Add(new BlockVariant() { Code = states[j] }); } for (int i = 0; i < variantgroups.Length; i++) { CollectibleVariantGroup cvg = variantgroups[i]; if (cvg.Combine == EnumCombination.SelectiveMultiply && cvg.OnVariant == variantGroup.Code) { for (int k = 0; k < stateList.Count; k++) { if (cvg.Code != stateList[k].Code) { continue; } BlockVariant old = stateList[k]; stateList.RemoveAt(k); for (int j = 0; j < cvg.States.Length; j++) { List <string> codes = old.Codes == null ? new List <string>() { old.Code } : old.Codes; List <string> types = old.Types == null ? new List <string>() { variantGroup.Code } : old.Types; codes.Add(cvg.States[j]); types.Add(cvg.Code); stateList.Insert(k, new BlockVariant() { Code = old.Code + "-" + cvg.States[j], Codes = codes, Types = types }); } } } } if (blockvariantsMul.ContainsKey(type)) { stateList.AddRange(blockvariantsMul[type]); blockvariantsMul[type] = stateList.ToArray(); } else { blockvariantsMul.Add(type, stateList.ToArray()); } } }