Beispiel #1
0
        public StandardWorldProperty GetWorldPropertyByCode(AssetLocation code)
        {
            StandardWorldProperty property = null;

            worldProperties.TryGetValue(code, out property);
            return(property);
        }
Beispiel #2
0
        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]);
            }
        }
Beispiel #3
0
        private void CollectFromWorldPropertiesCombine(AssetLocation[] propList, RegistryObjectVariantGroup variantGroup, RegistryObjectVariantGroup[] variantgroups, OrderedDictionary <string, VariantEntry[]> blockvariantsMul, List <ResolvedVariant> blockvariantsFinal, AssetLocation location)
        {
            if (propList.Length > 1 && variantGroup.Code == null)
            {
                api.Server.LogError(
                    "Error in item or block {0}, defined a variantgroup with loadFromPropertiesCombine (first element: {1}), but did not explicitly declare a code for this variant group, hence I do not know which code to use. Ignoring.",
                    location, propList[0]
                    );
                return;
            }

            foreach (var val in propList)
            {
                StandardWorldProperty property = GetWorldPropertyByCode(val);

                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)
                    {
                        ResolvedVariant resolved = new ResolvedVariant();
                        resolved.CodeParts.Add(typename, variant.Code.Path);
                        blockvariantsFinal.Add(resolved);
                    }
                }

                if (variantGroup.Combine == EnumCombination.Multiply)
                {
                    VariantEntry[] variants = null;
                    if (blockvariantsMul.TryGetValue(typename, out variants))
                    {
                        blockvariantsMul[typename] = variants.Append(worldPropertiesVariants[property.Code]);
                    }
                    else
                    {
                        blockvariantsMul.Add(typename, worldPropertiesVariants[property.Code]);
                    }
                }
            }
        }