示例#1
0
        private void ModWp(CmdArgs args, IServerPlayer player, int groupId)
        {
            if (args.Length == 0)
            {
                player.SendMessage(groupId, Lang.Get("command-modwaypoint-syntax"), EnumChatType.CommandError);
                return;
            }

            Waypoint[] ownwpaypoints = Waypoints.Where((p) => p.OwningPlayerUid == player.PlayerUID).ToArray();
            int?       wpIndex       = args.PopInt();

            if (wpIndex == null || wpIndex < 0 || ownwpaypoints.Length < (int)wpIndex - 1)
            {
                player.SendMessage(groupId, Lang.Get("command-modwaypoint-invalidindex", ownwpaypoints.Length), EnumChatType.CommandError);
                return;
            }

            string colorstring = args.PopWord();
            string icon        = args.PopWord();
            bool   pinned      = (bool)args.PopBool(false);
            string title       = args.PopAll();

            System.Drawing.Color parsedColor;

            if (colorstring.StartsWith("#"))
            {
                try
                {
                    int argb = Int32.Parse(colorstring.Replace("#", ""), NumberStyles.HexNumber);
                    parsedColor = System.Drawing.Color.FromArgb(argb);
                }
                catch (FormatException)
                {
                    player.SendMessage(groupId, Lang.Get("command-waypoint-invalidcolor"), EnumChatType.CommandError);
                    return;
                }
            }
            else
            {
                parsedColor = System.Drawing.Color.FromName(colorstring);
            }

            if (title == null || title.Length == 0)
            {
                player.SendMessage(groupId, Lang.Get("command-waypoint-notext"), EnumChatType.CommandError);
                return;
            }

            ownwpaypoints[(int)wpIndex].Color  = parsedColor.ToArgb() | (255 << 24);
            ownwpaypoints[(int)wpIndex].Title  = title;
            ownwpaypoints[(int)wpIndex].Pinned = pinned;

            if (icon != null)
            {
                ownwpaypoints[(int)wpIndex].Icon = icon;
            }

            player.SendMessage(groupId, Lang.Get("Ok, waypoint nr. {0} modified", (int)wpIndex), EnumChatType.CommandSuccess);
            ResendWaypoints(player);
        }
        public void SetPlayerPrivilege(IServerPlayer owningPlayer, int chatGroupId, string forPlayerUid, EnumBlockAccessFlags access)
        {
            ReinforcedPrivilegeGrants grants;

            if (!privGrantsByOwningPlayerUid.TryGetValue(owningPlayer.PlayerUID, out grants))
            {
                grants = new ReinforcedPrivilegeGrants();
                privGrantsByOwningPlayerUid[owningPlayer.PlayerUID] = grants;
            }

            if (access == EnumBlockAccessFlags.None)
            {
                if (grants.PlayerGrants.Remove(forPlayerUid))
                {
                    owningPlayer.SendMessage(chatGroupId, Lang.Get("Ok, privilege revoked from player."), EnumChatType.CommandSuccess);
                }
                else
                {
                    owningPlayer.SendMessage(chatGroupId, Lang.Get("No action taken. Player does not have any privilege to your reinforced blocks."), EnumChatType.CommandSuccess);
                }
            }
            else
            {
                grants.PlayerGrants[forPlayerUid] = access;
                owningPlayer.SendMessage(chatGroupId, Lang.Get("Ok, Privilege for player set."), EnumChatType.CommandSuccess);
            }

            SyncPrivData();
        }
        private void onSetTlPos(IServerPlayer player, int groupId, CmdArgs args)
        {
            BlockPos pos = player.CurrentBlockSelection.Position;
            BlockEntityStaticTranslocator bet = sapi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityStaticTranslocator;

            if (bet == null)
            {
                player.SendMessage(groupId, "Not looking at a translocator. Must look at one to set its target", EnumChatType.CommandError);
                return;
            }

            Vec3d spawnpos = sapi.World.DefaultSpawnPosition.XYZ;

            spawnpos.Y = 0;
            Vec3d targetpos = args.PopFlexiblePos(player.Entity.Pos.XYZ, spawnpos);

            if (targetpos == null)
            {
                player.SendMessage(groupId, "Invalid position supplied. Syntax: [coord] [coord] [coord] or =[abscoord] =[abscoord] =[abscoord]", EnumChatType.CommandError);
                return;
            }

            bet.tpLocation = targetpos.AsBlockPos;
            bet.MarkDirty(true);
            player.SendMessage(groupId, "Target position set.", EnumChatType.CommandError);
        }
示例#4
0
        private void cmdWeatherServer(IServerPlayer player, int groupId, CmdArgs args)
        {
            string arg = args.PopWord();

            if (arg == "t")
            {
                weatherSim.TriggerTransition();

                player.SendMessage(groupId, "Ok transitioning to another weather pattern", EnumChatType.CommandSuccess);
                return;
            }

            if (arg == "c")
            {
                weatherSim.TriggerTransition(1f);
                player.SendMessage(groupId, "Ok selected another weatherpattern", EnumChatType.CommandSuccess);
                return;
            }

            player.SendMessage(
                groupId,
                string.Format("{0}% {1}, {2}% {3}", (int)(100 * weatherSim.Weight), weatherSim.NewPattern.GetWeatherName(), (int)(100 - 100 * weatherSim.Weight), weatherSim.OldPattern.GetWeatherName()),
                EnumChatType.Notification
                );
        }
        private void onSetChiselMat(IServerPlayer player, int groupId, CmdArgs args)
        {
            BlockPos pos = player.CurrentBlockSelection?.Position;

            if (pos == null)
            {
                player.SendMessage(groupId, "Look at a block first", EnumChatType.CommandError);
                return;
            }

            BlockEntityChisel bechisel = api.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityChisel;

            if (bechisel == null)
            {
                player.SendMessage(groupId, "Not looking at a chiseled block", EnumChatType.CommandError);
                return;
            }

            Block block = player.InventoryManager?.ActiveHotbarSlot?.Itemstack?.Block;

            if (block == null)
            {
                player.SendMessage(groupId, "You need a block in your active hand", EnumChatType.CommandError);
                return;
            }

            for (int i = 0; i < bechisel.MaterialIds.Length; i++)
            {
                bechisel.MaterialIds[i] = block.Id;
            }

            bechisel.MarkDirty(true);
            player.SendMessage(groupId, "Ok material set", EnumChatType.CommandError);
            return;
        }
        private void rainStopFunc(IServerPlayer player, int groupId, bool skipForward = false)
        {
            WeatherSystemServer wsys = api.ModLoader.GetModSystem <WeatherSystemServer>();

            if (wsys.OverridePrecipitation != null)
            {
                player.SendMessage(groupId, string.Format("Override precipitation set, rain pattern will not change. Fix by typing /weather setprecip auto."), EnumChatType.CommandSuccess);
                return;
            }

            Vec3d pos = player.Entity.Pos.XYZ;

            float days             = 0;
            float daysrainless     = 0f;
            float firstRainLessDay = 0f;
            bool  found            = false;

            while (days < 21)
            {
                float precip = wsys.GetPrecipitation(pos.X, pos.Y, pos.Z, sapi.World.Calendar.TotalDays + days);
                if (precip < 0.04f)
                {
                    if (!found)
                    {
                        firstRainLessDay = days;
                    }

                    found = true;

                    daysrainless += 1f / sapi.World.Calendar.HoursPerDay;
                }
                else
                {
                    if (found)
                    {
                        break;
                    }
                }

                days += 1f / sapi.World.Calendar.HoursPerDay;
            }


            if (daysrainless > 0)
            {
                if (skipForward)
                {
                    wsys.RainCloudDaysOffset += daysrainless;
                    player.SendMessage(groupId, string.Format("Ok, forwarded rain simulation by {0:0.##} days. The rain should stop for about {1:0.##} days now", firstRainLessDay, daysrainless), EnumChatType.CommandSuccess);
                    return;
                }

                player.SendMessage(groupId, string.Format("In about {0:0.##} days the rain should stop for about {1:0.##} days", firstRainLessDay, daysrainless), EnumChatType.CommandSuccess);
            }
            else
            {
                player.SendMessage(groupId, string.Format("No rain less days found for the next 3 in-game weeks :O"), EnumChatType.CommandSuccess);
            }
        }
示例#7
0
        public void CmdCollectibleExchange(IServerPlayer byPlayer, int id, CmdArgs args)
        {
            BlockPos pos = byPlayer?.CurrentBlockSelection?.Position;
            string   arg = args.PopWord();

            switch (arg)
            {
            case "create":
                if (pos != null)
                {
                    if (!sapi.World.Claims.TryAccess(byPlayer, pos, EnumBlockAccessFlags.Use))
                    {
                        break;
                    }
                    BlockEntityGenericTypedContainer be = (sapi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityGenericTypedContainer);
                    if (be != null)
                    {
                        List <Exchange> exchanges = GetExchanges(be.Inventory);
                        sapi.World.BlockAccessor.RemoveBlockEntity(pos);
                        sapi.World.BlockAccessor.SpawnBlockEntity("Shop", pos);
                        BlockEntityShop beShop = (sapi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityShop);
                        beShop.inventory = (InventoryGeneric)be.Inventory;
                        beShop.Exchanges = exchanges;
                        sapi.World.PlaySoundAt(AssetLocation.Create("sounds/effect/latch"), pos.X, pos.Y, pos.Z);
                    }
                }
                break;

            case "update":
                if (!sapi.World.Claims.TryAccess(byPlayer, pos, EnumBlockAccessFlags.Use))
                {
                    break;
                }
                BlockEntityShop shop = (sapi.World.BlockAccessor.GetBlockEntity(pos) as BlockEntityShop);
                if (shop != null)
                {
                    shop.Exchanges = GetExchanges(shop.inventory);
                }
                sapi.World.PlaySoundAt(AssetLocation.Create("sounds/effect/latch"), pos.X, pos.Y, pos.Z);
                break;

            case "list":
                if (sapi.World.BlockAccessor.GetBlockEntity(pos) is BlockEntityShop)
                {
                    StringBuilder builder = new StringBuilder();
                    ((BlockEntityShop)sapi.World.BlockAccessor.GetBlockEntity(pos)).GetBlockInfo(byPlayer, builder);
                    byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, builder.ToString(), EnumChatType.OwnMessage);
                }
                break;

            case "trade":
                ExchangeEvent(byPlayer, byPlayer.CurrentBlockSelection);
                break;

            default:
                byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, syntaxMsg, EnumChatType.OwnMessage);
                break;
            }
        }
示例#8
0
        private void AddWp(Vec3d pos, CmdArgs args, IServerPlayer player, int groupId, string icon, bool pinned)
        {
            if (args.Length == 0)
            {
                player.SendMessage(groupId, Lang.Get("command-waypoint-syntax"), EnumChatType.CommandError);
                return;
            }

            string colorstring = args.PopWord();
            string title       = args.PopAll();

            System.Drawing.Color parsedColor;

            if (colorstring.StartsWith("#"))
            {
                try
                {
                    int argb = Int32.Parse(colorstring.Replace("#", ""), NumberStyles.HexNumber);
                    parsedColor = System.Drawing.Color.FromArgb(argb);
                }
                catch (FormatException)
                {
                    player.SendMessage(groupId, Lang.Get("command-waypoint-invalidcolor"), EnumChatType.CommandError);
                    return;
                }
            }
            else
            {
                parsedColor = System.Drawing.Color.FromName(colorstring);
            }

            if (title == null || title.Length == 0)
            {
                player.SendMessage(groupId, Lang.Get("command-waypoint-notext"), EnumChatType.CommandError);
                return;
            }



            Waypoint waypoint = new Waypoint()
            {
                Color           = parsedColor.ToArgb() | (255 << 24),
                OwningPlayerUid = player.PlayerUID,
                Position        = pos,
                Title           = title,
                Icon            = icon,
                Pinned          = pinned
            };


            Waypoints.Add(waypoint);

            Waypoint[] ownwpaypoints = Waypoints.Where((p) => p.OwningPlayerUid == player.PlayerUID).ToArray();

            player.SendMessage(groupId, Lang.Get("Ok, waypoint nr. {0} added", ownwpaypoints.Length - 1), EnumChatType.CommandSuccess);
            ResendWaypoints(player);
        }
示例#9
0
        private void TestNoise(IServerPlayer player, CmdArgs arguments)
        {
            bool use3d   = false;
            int  octaves = 1;

            if (arguments.Length > 1)
            {
                if (!int.TryParse(arguments[1], out octaves))
                {
                    octaves = 1;
                }
            }


            Random rnd  = new Random();
            long   seed = rnd.Next();

            NormalizedSimplexNoise noise = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 5, 0.7, seed);
            int    size = 800;
            Bitmap bmp  = new Bitmap(size, size);

            int   underflows = 0;
            int   overflows  = 0;
            float min        = 1;
            float max        = 0;

            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    double value = use3d ? noise.Noise((double)x / size, 0, (double)y / size) : noise.Noise((double)x / size, (double)y / size);
                    if (value < 0)
                    {
                        underflows++;
                        value = 0;
                    }
                    if (value > 1)
                    {
                        overflows++;
                        value = 1;
                    }

                    min = Math.Min((float)value, min);
                    max = Math.Max((float)value, max);

                    int light = (int)(value * 255);
                    bmp.SetPixel(x, y, Color.FromArgb(255, light, light, light));
                }
            }

            bmp.Save("noise.png");
            player.SendMessage(groupId, (use3d ? "3D" : "2D") + " Noise (" + octaves + " Octaves) saved to noise.png. Overflows: " + overflows + ", Underflows: " + underflows, EnumChatType.CommandSuccess);
            player.SendMessage(groupId, "Noise min = " + min.ToString("0.##") + ", max= " + max.ToString("0.##"), EnumChatType.CommandSuccess);
        }
示例#10
0
 void DrawMapRegion(DebugDrawMode mode, IServerPlayer player, IntMap map, string prefix, bool lerp, int regionX, int regionZ, int scale)
 {
     if (lerp)
     {
         int[] lerped = GameMath.BiLerpColorMap(map, scale);
         NoiseBase.DebugDrawBitmap(mode, lerped, map.InnerSize * scale, prefix + "-" + regionX + "-" + regionZ + "-l");
         player.SendMessage(groupId, "Lerped " + prefix + " map generated.", EnumChatType.CommandSuccess);
     }
     else
     {
         NoiseBase.DebugDrawBitmap(mode, map.Data, map.Size, prefix + "-" + regionX + "-" + regionZ);
         player.SendMessage(groupId, "Original " + prefix + " map generated.", EnumChatType.CommandSuccess);
     }
 }
示例#11
0
        private void onAnvilDebug(IServerPlayer player, int groupId, CmdArgs args)
        {
            if (player.CurrentBlockSelection?.Position != null)
            {
                BlockEntityAnvil bea = api.World.BlockAccessor.GetBlockEntity(player.CurrentBlockSelection.Position) as BlockEntityAnvil;

                if (bea == null)
                {
                    player.SendMessage(groupId, "Not looking at an anvil", EnumChatType.CommandError);
                    return;
                }

                player.SendMessage(groupId, bea.PrintDebugText(), EnumChatType.CommandSuccess);
            }
        }
示例#12
0
        public void reset(EntityPlayer entity, bool message)
        {
            foreach (var stats in entity.Stats)
            {
                entity.Stats.Remove(stats.Key, "potionmod");
            }
            EntityBehaviorHealth ebh = entity.GetBehavior <EntityBehaviorHealth>();

            ebh.MarkDirty();
            if (entity.WatchedAttributes.HasAttribute("glow"))
            {
                entity.WatchedAttributes.RemoveAttribute("glow");
            }
            if (entity.WatchedAttributes.HasAttribute("potionid"))
            {
                long effectIdGametick = entity.WatchedAttributes.GetLong("potionid");
                entity.World.UnregisterGameTickListener(effectIdGametick);
                effectDuration = 0;
                effectHealth   = 0;
                effectTickSec  = 0;
                entity.WatchedAttributes.RemoveAttribute("potionid");
            }
            if (message)
            {
                IServerPlayer player = (entity.World.PlayerByUid((entity as EntityPlayer).PlayerUID) as IServerPlayer);
                player.SendMessage(GlobalConstants.InfoLogChatGroup, "You feel the effects of the potion disapate", EnumChatType.Notification);
            }
        }
示例#13
0
        void TreeLineup(IServerPlayer player, CmdArgs arguments)
        {
            if (arguments.Length < 2)
            {
                player.SendMessage(groupId, "/wgen treelineup {treeWorldPropertyCode} [0.1 - 3]", EnumChatType.CommandError);
                return;
            }

            EntityPos      pos           = player.Entity.Pos;
            BlockPos       center        = pos.HorizontalAheadCopy(25).AsBlockPos;
            IBlockAccessor blockAccessor = api.WorldManager.GetBlockAccessorBulkUpdate(true, true, true);

            int size = 12;

            for (int dx = -2 * size; dx < 2 * size; dx++)
            {
                for (int dz = -size; dz < size; dz++)
                {
                    for (int dy = 0; dy < 2 * size; dy++)
                    {
                        blockAccessor.SetBlock(0, center.AddCopy(dx, dy, dz));
                    }
                }
            }


            treeGenerators.ReloadTreeGenerators();
            treeGenerators.RunGenerator(new AssetLocation(arguments[1]), blockAccessor, center.AddCopy(0, -1, 0));
            treeGenerators.RunGenerator(new AssetLocation(arguments[1]), blockAccessor, center.AddCopy(-9, -1, 0));
            treeGenerators.RunGenerator(new AssetLocation(arguments[1]), blockAccessor, center.AddCopy(9, -1, 0));

            blockAccessor.Commit();
        }
示例#14
0
        private void OnLoreDiscovery(string eventName, ref EnumHandling handling, IAttribute data)
        {
            TreeAttribute tree      = data as TreeAttribute;
            string        playerUid = tree.GetString("playeruid");
            string        category  = tree.GetString("category");

            IServerPlayer plr = sapi.World.PlayerByUid(playerUid) as IServerPlayer;

            LoreDiscovery discovery = TryGetRandomLoreDiscovery(sapi.World, plr, category);

            if (discovery == null)
            {
                plr.SendMessage(GlobalConstants.GeneralChatGroup, Lang.Get("Nothing new in these pages"), EnumChatType.Notification);
                return;
            }

            ItemSlot itemslot = plr.InventoryManager.ActiveHotbarSlot;

            itemslot.TakeOut(1);
            itemslot.MarkDirty();
            plr.Entity.World.PlaySoundAt(new AssetLocation("sounds/effect/writing"), plr.Entity);

            handling = EnumHandling.PreventDefault;

            DiscoverLore(discovery, plr);
        }
示例#15
0
        private void OnCmdErrRep(IServerPlayer player, int groupId, CmdArgs args)
        {
            bool on = (bool)args.PopBool(true);

            player.ServerData.CustomPlayerData["errorReporting"] = on ? "1" : "0";
            player.SendMessage(groupId, Lang.Get("Error reporting now {0}", on ? "on" : "off"), EnumChatType.Notification);
        }
示例#16
0
        private void onCmdRiftTest(IServerPlayer player, int groupId, CmdArgs args)
        {
            Vec3d pos = player.Entity.Pos.XYZ;

            string cmd = args.PopWord();

            if (cmd == null)
            {
                player.SendMessage(groupId, rifts.Count + " rifts loaded", EnumChatType.Notification);
                return;
            }

            if (cmd == "clear")
            {
                rifts.Clear();
            }

            if (cmd == "fade")
            {
                foreach (var rift in rifts)
                {
                    rift.DieAtTotalHours = Math.Min(rift.DieAtTotalHours, api.World.Calendar.TotalHours + 0.2);
                }
            }

            if (cmd == "spawn")
            {
                for (int i = 0; i < 200; i++)
                {
                    double distance = spawnMinDistance + api.World.Rand.NextDouble() * spawnAddDistance;
                    double angle    = api.World.Rand.NextDouble() * GameMath.TWOPI;

                    double dz = distance * Math.Sin(angle);
                    double dx = distance * Math.Cos(angle);

                    Vec3d riftPos = pos.AddCopy(dx, 0, dz);

                    BlockPos bpos = new BlockPos((int)riftPos.X, 0, (int)riftPos.Z);
                    bpos.Y = api.World.BlockAccessor.GetTerrainMapheightAt(bpos);

                    var block = api.World.BlockAccessor.GetBlock(bpos);
                    if (block.IsLiquid() && api.World.Rand.NextDouble() > 0.1)
                    {
                        continue;
                    }

                    float size = 2 + (float)api.World.Rand.NextDouble() * 4f;

                    riftPos.Y = bpos.Y + size / 2f + 1;
                    rifts.Add(new Rift()
                    {
                        Position          = riftPos, Size = size,
                        SpawnedTotalHours = api.World.Calendar.TotalHours,
                        DieAtTotalHours   = api.World.Calendar.TotalHours + 8 + api.World.Rand.NextDouble() * 48
                    });
                }
            }

            BroadCastRifts();
        }
示例#17
0
        private void onChiselSetMatCmd(IServerPlayer player, int groupId, CmdArgs args)
        {
            var wmod = sapi.ModLoader.GetModSystem <WorldEdit.WorldEdit>();

            var workspace = wmod.GetWorkSpace(player.PlayerUID);

            if (workspace == null || workspace.StartMarker == null || workspace.EndMarker == null)
            {
                player.SendMessage(groupId, "Select an area with worldedit first", EnumChatType.CommandError);
                return;
            }

            int startx = Math.Min(workspace.StartMarker.X, workspace.EndMarker.X);
            int endx   = Math.Max(workspace.StartMarker.X, workspace.EndMarker.X);
            int starty = Math.Min(workspace.StartMarker.Y, workspace.EndMarker.Y);
            int endy   = Math.Max(workspace.StartMarker.Y, workspace.EndMarker.Y);
            int startz = Math.Min(workspace.StartMarker.Z, workspace.EndMarker.Z);
            int endZ   = Math.Max(workspace.StartMarker.Z, workspace.EndMarker.Z);

            for (int x = startx; x < endx; x++)
            {
                for (int y = starty; y < endy; y++)
                {
                    for (int z = startz; z < endZ; z++)
                    {
                    }
                }
            }
        }
示例#18
0
        private void OnCmdNpcs(IServerPlayer player, int groupId, CmdArgs args)
        {
            string cmd  = args.PopWord();
            bool   exec = cmd == "startall" || cmd == "startallrandom";

            if (cmd != "startall" && cmd == "stopall" || cmd == "startallrandom")
            {
                player.SendMessage(groupId, "Unknown command", EnumChatType.Notification);
            }

            foreach (var val in sapi.World.LoadedEntities)
            {
                EntityAnimalBot npc = val.Value as EntityAnimalBot;
                if (npc != null)
                {
                    if (exec)
                    {
                        if (cmd == "startallrandom")
                        {
                            sapi.Event.RegisterCallback((dt) => npc.StartExecuteCommands(), (int)(sapi.World.Rand.NextDouble() * 200));
                        }
                        else
                        {
                            npc.StartExecuteCommands();
                        }
                    }
                    else
                    {
                        npc.StopExecuteCommands();
                    }
                }
            }
        }
示例#19
0
        public override void OnHeldAttackStart(IItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, ref EnumHandHandling handling)
        {
            if (byEntity.World.Side == EnumAppSide.Client)
            {
                handling = EnumHandHandling.PreventDefaultAction;
                return;
            }

            if (blockSel == null)
            {
                return;
            }

            ModSystemBlockReinforcement bre = byEntity.Api.ModLoader.GetModSystem <ModSystemBlockReinforcement>();
            IServerPlayer player            = (byEntity as EntityPlayer).Player as IServerPlayer;

            if (player == null)
            {
                return;
            }

            string errorCode = "";

            if (!bre.TryRemoveReinforcement(blockSel.Position, player, ref errorCode))
            {
                player.SendMessage(GlobalConstants.CurrentChatGroup, "Cannot remove reinforcement: " + errorCode, EnumChatType.Notification);
                return;
            }

            BlockPos pos = blockSel.Position;

            byEntity.World.PlaySoundAt(new AssetLocation("blockreinforcement", "sounds/reinforce"), pos.X, pos.Y, pos.Z, null);

            handling = EnumHandHandling.PreventDefaultAction;
        }
 private void Event_PlayerNowPlaying(IServerPlayer byPlayer)
 {
     if (sapi.WorldManager.SaveGame.IsNew && stormsEnabled)
     {
         double nextStormDaysLeft = data.nextStormTotalDays - api.World.Calendar.TotalDays;
         byPlayer.SendMessage(GlobalConstants.GeneralChatGroup, Lang.Get("{0} days until the first temporal storm.", (int)nextStormDaysLeft), EnumChatType.Notification);
     }
 }
示例#21
0
 void ReadChunk(IServerPlayer player, CmdArgs arguments)
 {
     if (arguments.Length < 2)
     {
         player.SendMessage(groupId, "Nothing implemented here", EnumChatType.CommandError);
         return;
     }
 }
示例#22
0
        public override void OnHeldInteractStop(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel)
        {
            ItemStack content = GetContent(slot.Itemstack);

            if (secondsUsed > 1.45f && byEntity.World.Side == EnumAppSide.Server && content != null)
            {
                if (essencesDic.TryGetValue("duration", out duration))
                {
                    if (!essencesDic.ContainsKey("health"))
                    {
                        TempEffect potionEffect = new TempEffect();
                        potionEffect.tempEntityStats((byEntity as EntityPlayer), essencesDic);
                    }
                    else
                    {
                        TempEffect potionEffect = new TempEffect();
                        potionEffect.tempTickEntityStats((byEntity as EntityPlayer), essencesDic, tickSec, essencesDic["health"]);
                    }
                    if (byEntity is EntityPlayer)
                    {
                        IServerPlayer sPlayer = (byEntity.World.PlayerByUid((byEntity as EntityPlayer).PlayerUID) as IServerPlayer);
                        if (essencesDic.ContainsKey("recall"))
                        {
                            if (api.Side.IsServer())
                            {
                                FuzzyEntityPos spawn = sPlayer.GetSpawnPosition(false);
                                byEntity.TeleportTo(spawn);
                            }
                        }
                        sPlayer.SendMessage(GlobalConstants.InfoLogChatGroup, "You feel the effects of the " + content.GetName(), EnumChatType.Notification);
                    }
                    IPlayer player = null;
                    if (byEntity is EntityPlayer)
                    {
                        player = byEntity.World.PlayerByUid(((EntityPlayer)byEntity).PlayerUID);
                    }
                    if (slot.StackSize > 1)
                    {
                        ItemStack newStack = slot.Itemstack.Clone();
                        newStack.StackSize = slot.StackSize - 1;
                        ItemStack newContent = GetContent(newStack);
                        api.World.SpawnItemEntity(newStack, byEntity.Pos.XYZ);
                        slot.TakeOut(slot.StackSize - 1);
                    }
                    splitStackAndPerformAction(byEntity, slot, (stack) => TryTakeLiquid(stack, 0.25f)?.StackSize ?? 0);
                    slot.MarkDirty();

                    EntityPlayer entityPlayer = byEntity as EntityPlayer;
                    if (entityPlayer == null)
                    {
                        return;
                    }
                    entityPlayer.Player.InventoryManager.BroadcastHotbarSlot();
                }
            }
            base.OnHeldInteractStop(secondsUsed, slot, byEntity, blockSel, entitySel);
        }
示例#23
0
        void Regen(IServerPlayer player, CmdArgs arguments, bool onlydelete)
        {
            int chunkMidX = api.WorldManager.MapSizeX / api.WorldManager.ChunkSize / 2;
            int chunkMidZ = api.WorldManager.MapSizeZ / api.WorldManager.ChunkSize / 2;

            List <Vec2i> coords = new List <Vec2i>();

            int rad = 2;

            if (arguments.Length > 1)
            {
                int.TryParse(arguments[1], out rad);
            }

            for (int x = -rad; x <= rad; x++)
            {
                for (int z = -rad; z <= rad; z++)
                {
                    coords.Add(new Vec2i(chunkMidX + x, chunkMidZ + z));
                }
            }



            foreach (Vec2i coord in coords)
            {
                api.WorldManager.DeleteChunkColumn(coord.X, coord.Y);
                if (!onlydelete)
                {
                    api.WorldManager.ForceLoadChunkColumn(coord.X, coord.Y, false);
                }
            }

            int diam = 2 * rad + 1;

            if (onlydelete)
            {
                player.SendMessage(groupId, "Deleted " + diam + "x" + diam + " columns", EnumChatType.CommandSuccess);
            }
            else
            {
                player.SendMessage(groupId, "Reloaded landforms and regenerating " + diam + "x" + diam + " columns", EnumChatType.CommandSuccess);
            }
        }
        void PrintProbeResults(IWorldAccessor world, IServerPlayer byPlayer, IItemSlot itemslot, BlockPos pos)
        {
            IBlockAccessor blockAccess = world.BlockAccessor;
            int            chunksize   = blockAccess.ChunkSize;
            int            regsize     = blockAccess.RegionSize;

            int mapheight    = blockAccess.GetTerrainMapheightAt(pos);
            int qchunkblocks = mapheight * chunksize * chunksize;

            IMapRegion reg = world.BlockAccessor.GetMapRegion(pos.X / regsize, pos.Z / regsize);
            int        lx  = pos.X % regsize;
            int        lz  = pos.Z % regsize;

            StringBuilder outtext = new StringBuilder();
            int           found   = 0;

            foreach (var val in reg.OreMaps)
            {
                IntMap map       = val.Value;
                int    noiseSize = map.InnerSize;

                float posXInRegionOre = (float)lx / regsize * noiseSize;
                float posZInRegionOre = (float)lz / regsize * noiseSize;

                int oreDist = map.GetUnpaddedColorLerped(posXInRegionOre, posZInRegionOre);

                double   absAvgq  = absAvgQuantity[val.Key];
                double   factor   = (oreDist & 0xff) / 255.0;
                double   quantity = factor * absAvgq;
                double   relq     = quantity / qchunkblocks;
                double   ppt      = relq * 1000;
                string[] names    = new string[] { "Very poor density", "Poor density", "Decent density", "High density", "Very high density", "Ultra high density" };

                if (factor > 0.05)
                {
                    if (found > 0)
                    {
                        outtext.Append("\n");
                    }
                    outtext.Append(string.Format("{1}: {2} ({0}‰)", ppt.ToString("0.#"), val.Key.Substring(0, 1).ToUpper() + val.Key.Substring(1), names[(int)GameMath.Clamp(factor * 5, 0, 5)]));
                    found++;
                }
            }

            IServerPlayer splr = byPlayer as IServerPlayer;

            if (outtext.Length == 0)
            {
                outtext.Append("No significant resources here.");
            }
            else
            {
                outtext.Insert(0, "Found " + found + " traces of ore\n");
            }
            splr.SendMessage(GlobalConstants.CurrentChatGroup, outtext.ToString(), EnumChatType.Notification);
        }
        private void onCmdNextStorm(IServerPlayer player, int groupId, CmdArgs args)
        {
            if (data.nowStormActive)
            {
                double daysleft = data.stormActiveTotalDays - api.World.Calendar.TotalDays;
                player.SendMessage(groupId, Lang.Get(data.nextStormStrength + " Storm still active for {0:0.##} days", daysleft), EnumChatType.Notification);
            }
            else
            {
                if (args.PopWord() == "now")
                {
                    data.nextStormTotalDays = api.World.Calendar.TotalDays;
                    return;
                }

                double nextStormDaysLeft = data.nextStormTotalDays - api.World.Calendar.TotalDays;
                player.SendMessage(groupId, Lang.Get("temporalstorm-cmd-daysleft", nextStormDaysLeft), EnumChatType.Notification);
            }
        }
示例#26
0
        public void Update(IServerPlayer player, ICoreAPI api, CmdArgs args)
        {
            string type = args.PopWord();

            switch (type)
            {
            case "gs":
                GotoSpeed = (float)args.PopFloat(0);
                player.SendMessage(GlobalConstants.CurrentChatGroup, "Ok goto speed upated to " + GotoSpeed, EnumChatType.Notification);
                return;

            case "as":
                AnimSpeed = (float)args.PopFloat(0);
                player.SendMessage(GlobalConstants.CurrentChatGroup, "Ok goto speed upated to " + AnimSpeed, EnumChatType.Notification);
                return;
            }

            player.SendMessage(GlobalConstants.CurrentChatGroup, "Excpected gs or as", EnumChatType.Notification);
        }
示例#27
0
        public void ExportMatches(IServerPlayer player, bool DL = false)
        {
            FindMatches(player, DL);

            using (TextWriter tW = new StreamWriter("matches.json"))
            {
                tW.Write(JsonConvert.SerializeObject(MostLikely, Formatting.Indented));
                tW.Close();
            }
            player.SendMessage(GlobalConstants.GeneralChatGroup, "Okay, exported list of matching things.", EnumChatType.CommandError);
        }
        public static void SendMessage(this IServerPlayer player, string msg, int chatGroup = -1)
        {
            if (chatGroup == -1)
            {
                chatGroup = GlobalConstants.CurrentChatGroup;
            }
            ICoreAPI api = player.Entity.Api;

            player.SendMessage(chatGroup, msg, EnumChatType.Notification);
            api.World.Logger.Chat(msg);
        }
示例#29
0
        public void ExportMissing(IServerPlayer player, int groupID)
        {
            RePopulate();
            List <AssetLocation> combined = MissingBlocks.Concat(MissingItems).ToList();
            string a = JsonConvert.SerializeObject(combined, Formatting.Indented);

            using (TextWriter tW = new StreamWriter("missingcollectibles.json"))
            {
                tW.Write(a);
                tW.Close();
            }
            player.SendMessage(groupID, "Okay, exported list of missing things.", EnumChatType.CommandError);
        }
示例#30
0
        private void RegenChunks(IServerPlayer player, CmdArgs arguments, bool aroundPlayer = false, bool randomSeed = false)
        {
            int seedDiff = randomSeed ? api.World.Rand.Next(100000) : 0;

            if (randomSeed)
            {
                player.SendMessage(GlobalConstants.CurrentChatGroup, "Using random seed diff " + seedDiff, EnumChatType.Notification);
            }

            player.SendMessage(GlobalConstants.CurrentChatGroup, "Waiting for chunk thread to pause...", EnumChatType.Notification);

            if (api.Server.PauseThread("chunkdbthread"))
            {
                NoiseLandforms.ReloadLandforms(api);

                api.ModLoader.GetModSystem <GenTerra>().initWorldGen();
                api.ModLoader.GetModSystem <GenMaps>().initWorldGen();
                api.ModLoader.GetModSystem <GenRockStrataNew>().initWorldGen(seedDiff);

                if (ModStdWorldGen.DoDecorationPass)
                {
                    api.ModLoader.GetModSystem <GenVegetation>().initWorldGen();
                    api.ModLoader.GetModSystem <GenLakes>().initWorldGen();
                    api.ModLoader.GetModSystem <GenBlockLayers>().InitWorldGen();
                    api.ModLoader.GetModSystem <GenCaves>().initWorldGen();
                    api.ModLoader.GetModSystem <GenDeposits>().initWorldGen();
                }

                Regen(player, arguments, false, aroundPlayer);
            }
            else
            {
                player.SendMessage(GlobalConstants.CurrentChatGroup, "Unable to regenerate chunks. Was not able to pause the chunk gen thread", EnumChatType.Notification);
            }

            api.Server.ResumeThread("chunkdbthread");
            player.CurrentChunkSentRadius = 0;
        }