Пример #1
0
        public void PostOLInit()
        {
            SwapSystem swapSystem = Api.ModLoader.GetModSystem <SwapSystem>();

            requireSneak   = properties["requireSneak"].AsBool(requireSneak);
            particleOrigin = properties["particleOrigin"].Exists ? properties["particleOrigin"].AsObject <Vec3d>() : particleOrigin;
            pRadius        = properties["particleRadius"].AsInt(pRadius);
            pQuantity      = properties["particleQuantity"].AsInt(pQuantity);
            playSound      = properties["playSound"].AsBool(true);
            allowPlaceOn   = properties["allowPlaceOn"].AsBool(false);

            if (properties["allowedVariants"].Exists)
            {
                string[] allowed = properties["allowedVariants"].AsArray <string>().WithDomain();

                disabled = true;
                if (allowed.Contains(block.Code.ToString()))
                {
                    disabled = false;
                }
                else
                {
                    return;
                }
            }
            if (properties["swapBlocks"].Exists)
            {
                if (Api.World.Side.IsServer())
                {
                    try
                    {
                        SwapBlocks[] swapBlocks = properties["swapBlocks"].AsObject <SwapBlocks[]>();
                        foreach (SwapBlocks val in swapBlocks)
                        {
                            if (swapSystem.SwapPairs.ContainsKey(GetKey(val.Tool)))
                            {
                                continue;
                            }

                            if (val.Tool.Contains("*"))
                            {
                                SwapBlocks tmp = val.Copy();

                                foreach (var block in Api.World.Blocks)
                                {
                                    if (block.WildCardMatch(val.Tool))
                                    {
                                        tmp.Tool = block.Code.ToString();
                                        string key = GetKey(tmp.Tool);
                                        if (swapSystem.SwapPairs.ContainsKey(key))
                                        {
                                            continue;
                                        }

                                        swapSystem.SwapPairs.Add(key, tmp.Copy());
                                    }
                                }
                                foreach (var item in Api.World.Items)
                                {
                                    if (item.WildCardMatch(val.Tool))
                                    {
                                        tmp.Tool = item.Code.ToString();
                                        string key = GetKey(tmp.Tool);
                                        if (swapSystem.SwapPairs.ContainsKey(key))
                                        {
                                            continue;
                                        }

                                        swapSystem.SwapPairs.Add(key, tmp.Copy());
                                    }
                                }
                            }
                            else
                            {
                                swapSystem.SwapPairs.Add(GetKey(val.Tool), val);
                            }
                        }
                    }
                    catch (Exception)
                    {
                        disabled = true;
                        Api.World.Logger.Notification("Deprecated or unsupported use of swapblocks in " + block.Code.ToString());
                    }
                }
            }
            else
            {
                disabled = true;
                return;
            }
        }
Пример #2
0
        public SwapBlocks Copy()
        {
            SwapBlocks copy = new SwapBlocks(Takes, Makes, Tool, Count);

            return(copy);
        }