private void Interaction(MouseEvent e) { if (e.Button == EnumMouseButton.Right && capi?.World?.Player?.CurrentBlockSelection?.BlockEntity(capi) is BlockEntityContainer) { capi.SendChatMessage("/ce trade"); } }
/// <summary> /// Adds a waypoint at the a position within the world, relative to the global spawn point. /// </summary> /// <param name="api">The core game API this method was called from.</param> /// <param name="pos">The position to add the waypoint at.</param> /// <param name="icon">The icon to use for the waypoint.</param> /// <param name="colour">The colour of the waypoint.</param> /// <param name="title">The title to set.</param> /// <param name="pinned">if set to <c>true</c>, the waypoint will be pinned to the world map.</param> public static void AddWaypointAtPos( this ICoreClientAPI api, BlockPos pos, string icon, string colour, string title, bool pinned) { if (pos is null) { return; } api.SendChatMessage( $"/waypoint addati {icon} {pos.X} {pos.Y} {pos.Z} {(pinned ? "true" : "false")} {colour} {title}"); }
private void SendChatLine(string line) { if (line.StartsWith(".")) { ClientAPI.TriggerChatMessage(line); } else { ClientAPI.SendChatMessage(line); } }
public override void StartClientSide(ICoreClientAPI api) { capi = api; cChannel = capi.Network.RegisterChannel("remapperchannel") .RegisterMessageType(typeof(Message)) .SetMessageHandler <Message>(a => { capi = api; MostLikely = JsonConvert.DeserializeObject <Dictionary <AssetLocation, AssetLocation> >(a.Assets); foreach (var item in MostLikely) { if (item.Key.GetBlock(capi) != null && item.Value.GetBlock(capi) != null) { capi.SendChatMessage("/bir remap " + item.Value + " " + item.Key + " force"); } else if (item.Key.GetItem(capi) != null && item.Value.GetItem(capi) != null) { capi.SendChatMessage("/iir remap " + item.Value + " " + item.Key + " force"); } } }); }
private void onWorldMapLinkClicked(LinkTextComponent linkcomp) { string[] xyzstr = linkcomp.Href.Substring("worldmap://".Length).Split('='); int x = xyzstr[1].ToInt(); int y = xyzstr[2].ToInt(); int z = xyzstr[3].ToInt(); string text = xyzstr.Length >= 5 ? xyzstr[4] : ""; if (worldMapDlg == null || !worldMapDlg.IsOpened() || (worldMapDlg.IsOpened() && worldMapDlg.DialogType == EnumDialogType.HUD)) { ToggleMap(EnumDialogType.Dialog); } bool exists = false; var elem = (worldMapDlg.SingleComposer.GetElement("mapElem") as GuiElementMap); var wml = (elem?.mapLayers.FirstOrDefault(ml => ml is WaypointMapLayer) as WaypointMapLayer); Vec3d pos = new Vec3d(x, y, z); if (wml != null) { foreach (var wp in wml.ownWaypoints) { if (wp.Position.Equals(pos, 0.01)) { exists = true; break; } } } if (!exists) { capi.SendChatMessage(string.Format("/waypoint addati {0} ={1} ={2} ={3} {4} {5} {6}", "circle", x, y, z, false, "steelblue", text)); } elem?.CenterMapTo(new BlockPos(x, y, z)); }
public void MarkWP(WaypointClassification wp, Vec3d pos) { string str = string.Format(System.Globalization.CultureInfo.InvariantCulture, "/waypoint addati {0} ={1} ={2} ={3} {4} #{5} {6}", wp.Icon ?? "star1", pos.X, pos.Y, pos.Z, false, wp.Color, wp.Name); capi.SendChatMessage(str); }
private void OnSetValueControls(string elementCode, string newValue) { switch (elementCode) { case "undo": capi.SendChatMessage("/we undo"); break; case "redo": capi.SendChatMessage("/we redo"); break; } }
public CommandFloatyWaypoints(ICoreClientAPI capi, WaypointUtils utils) : base(capi) { Command = "wpcfg"; RegisterSubCommand("deathdebug", new SubCommand((player, groupId, args) => { Config.DebugDeathWaypoints = args.PopBool() ?? !Config.DebugDeathWaypoints; capi.ShowChatMessage(string.Format("Death waypoint debbuging set to {0}", Config.DebugDeathWaypoints)); }, "Debug sending of death waypoint string, true/false.")); RegisterSubCommand("dotrange", new SubCommand((player, groupId, args) => { double?dr = args.PopDouble(); Config.DotRange = dr != null ? (double)dr : Config.DotRange; capi.ShowChatMessage("Dot Range Set To " + Config.DotRange + " Meters."); }, "Sets the dot range of floaty waypoints, any decimal value.")); RegisterSubCommand("titlerange", new SubCommand((player, groupId, args) => { double?tr = args.PopDouble(); Config.TitleRange = tr != null ? (double)tr : Config.TitleRange; capi.ShowChatMessage("Title Range Set To " + Config.TitleRange + " Meters."); }, "Sets the title range of floaty waypoints, any decimal value.")); RegisterSubCommand("perblockwaypoints", new SubCommand((player, groupId, args) => { bool?pb = args.PopBool(); Config.PerBlockWaypoints = pb != null ? (bool)pb : !Config.PerBlockWaypoints; capi.ShowChatMessage("Per Block Waypoints Set To " + Config.PerBlockWaypoints + "."); }, "Whether or not floaty waypoints are clamped to block positions, true/false.")); RegisterSubCommand("pdw", new SubCommand((player, groupId, args) => { utils.PurgeWaypointsByStrings("Player Death Waypoint", "*Player Death Waypoint*"); }, "Purges death waypoints.")); RegisterSubCommand("plt", new SubCommand((player, groupId, args) => { utils.PurgeWaypointsByStrings("Limits Test"); }, "Purges waypoints created by the testlimits debug command.")); RegisterSubCommand("open", new SubCommand((player, groupId, args) => { utils.ViewWaypoints(new KeyCombination()); }, "Opens floaty waypoints uis.")); RegisterSubCommand("waypointprefix", new SubCommand((player, groupId, args) => { bool?wp = args.PopBool(); Config.WaypointPrefix = wp != null ? (bool)wp : !Config.WaypointPrefix; capi.ShowChatMessage("Waypoint Prefix Set To " + Config.WaypointPrefix + "."); }, "Whether or not waypoints are prefixed with \"Waypoint:\", true/false")); RegisterSubCommand("waypointid", new SubCommand((player, groupId, args) => { bool?wi = args.PopBool(); Config.WaypointID = wi != null ? (bool)wi : !Config.WaypointID; capi.ShowChatMessage("Waypoint ID Set To " + Config.WaypointID + "."); }, "Whether or not floaty waypoints are prefixed with their ID, true/false")); RegisterSubCommand("purge", new SubCommand((player, groupId, args) => { string s = args.PopWord(); if (s == "reallyreallyconfirm") { utils.Purge(); } else { capi.ShowChatMessage(Lang.Get("Are you sure you want to do that? It will remove ALL your waypoints, type \"reallyreallyconfirm\" to confirm.")); } }, "Deletes ALL your waypoints.")); RegisterSubCommand("enableall", new SubCommand((player, groupId, args) => { Config.DisabledColors.Clear(); }, "Enables all waypoint colors.")); RegisterSubCommand("save", new SubCommand((player, groupId, args) => { ConfigLoader.SaveConfig(capi); }, "Force save configuration file.")); RegisterSubCommand("export", new SubCommand((player, groupId, args) => { string filePath = Path.Combine(GamePaths.DataPath, args.PopWord() ?? "waypoints"); lock (MassFileExportSystem.toExport) { MassFileExportSystem.toExport.Push(new ExportableJsonObject(utils.WaypointsRel, filePath)); } }, "Exports waypoints as a JSON file located in your game data folder.")); RegisterSubCommand("import", new SubCommand((player, groupId, args) => { string path1 = Path.Combine(GamePaths.DataPath, args.PopWord() ?? "waypoints") + ".json"; if (File.Exists(path1)) { using (TextReader reader = new StreamReader(path1)) { DummyWaypoint[] relative = JsonConvert.DeserializeObject <DummyWaypoint[]>(reader.ReadToEnd(), new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); VSHUDTaskSystem.Actions.Enqueue(new Vintagestory.API.Common.Action(() => { for (int j = 0; j < relative.Length; j++) { var val = relative[j]; if (utils.WaypointsRel.Any(w => val.Position.AsBlockPos.X == w.Position.AsBlockPos.X && val.Position.AsBlockPos.Y == w.Position.AsBlockPos.Y && val.Position.AsBlockPos.Z == w.Position.AsBlockPos.Z )) { continue; } string str = string.Format(CultureInfo.InvariantCulture, "/waypoint addati {0} ={1} ={2} ={3} {4} #{5} {6}", val.Icon, val.Position.X, val.Position.Y, val.Position.Z, val.Pinned, ColorUtil.Int2Hex(val.Color), val.Title); capi.SendChatMessage(str); } capi.SendMyWaypoints(); })); reader.Close(); } } }, "Imports waypoints from a JSON file located in your game data folder, default name waypoints.json, if not, provide filename excluding .json.")); RegisterSubCommand("testlimits", new SubCommand((player, groupId, args) => { int amount = args.PopInt() ?? 30; int maxY = args.PopInt() ?? 10; double radius = (args.PopInt() ?? 1000); VSHUDTaskSystem.Actions.Enqueue(new Vintagestory.API.Common.Action(() => { for (int i = 0; i < amount; i++) { double x = (capi.World.Rand.NextDouble() - 0.5) * radius, z = (capi.World.Rand.NextDouble() - 0.5) * radius, y = capi.World.BlockAccessor.GetRainMapHeightAt((int)x, (int)z); double r = x * x + z * z; if (r <= (radius * 0.5) * (radius * 0.5)) { Vec3d pos = capi.World.Player.Entity.Pos.XYZ.AddCopy(new Vec3d(x, y, z)); bool deathWaypoint = capi.World.Rand.NextDouble() > 0.8; string icon = deathWaypoint ? "rocks" : WaypointUtils.iconKeys[(int)(capi.World.Rand.NextDouble() * (WaypointUtils.iconKeys.Length - 1))]; string title = deathWaypoint ? "Limits Test Player Death Waypoint" : "Limits Test Waypoint"; string str = string.Format(CultureInfo.InvariantCulture, "/waypoint addati {0} ={1} ={2} ={3} {4} #{5} {6}", icon, pos.X, pos.Y, pos.Z, deathWaypoint, ColorStuff.RandomHexColorVClamp(capi, 0.5, 0.8), title); capi.SendChatMessage(str); } else { i--; } } capi.SendMyWaypoints(); })); }, "Creates and uploads many waypoints to the server to debug the limits of VSHUD's floaty waypoint rendering system, inputs 3 integers (amount, maxY, radius).")); RegisterSubCommand("pillars", new SubCommand((player, groupId, args) => { Config.ShowPillars = args.PopBool() ?? !Config.ShowPillars; capi.ShowChatMessage("Waypoint Pillars Set To " + Config.ShowPillars + "."); }, "Toggles the rendering of the pillars that accompany the floaty waypoint UIs. True/False")); RegisterSubCommand("shuffle", new SubCommand((player, groupId, args) => { lock (FloatyWaypointManagement.WaypointElements) { if (FloatyWaypointManagement.WaypointElements != null && FloatyWaypointManagement.WaypointElements.Count > 1) { HudElementWaypoint[] wps = new HudElementWaypoint[FloatyWaypointManagement.WaypointElements.Count]; FloatyWaypointManagement.WaypointElements.TryPopRange(wps); wps.Shuffle(new LCGRandom(468963)); FloatyWaypointManagement.WaypointElements.PushRange(wps); } } }, "Shuffles the internal floaty waypoint UI stack to debug if changes are handled correctly.")); RegisterSubCommand("echo", new SubCommand((player, groupId, args) => { Config.Echo = (bool)args.PopBool(!Config.Echo); capi.ShowChatMessage(string.Format("Waypoint creation echoing set to {0}.", Config.Echo)); }, "Toggles the logging to chat of waypoint creation/deletion. Useful if you have a mod that creates many waypoints. True/False")); }
public override void StartClientSide(ICoreClientAPI api) { var settingsFile = api.RegisterFileManager().RegisterFile("EnvTweaks.config.json", FileScope.Global); EnvTweaksPatches.Api = api; EnvTweaksPatches.Settings = settingsFile.ParseJsonAsObject <ModSettings>(); var syntaxMessage = "[settings|lightning|rain|hail|snow|sounds|shake|fog|clouds] [on|off]"; void Handler(int _, CmdArgs args) { if (args.Length == 0) { api.ShowChatMessage($"Environmental Tweaks: {syntaxMessage}"); return; } var option = args.PopWord(); var state = args.PopWord("off").ToLowerInvariant() == "on"; switch (option) { case "settings": var sb = new StringBuilder(); sb.AppendLine("Environmental Tweaks:\n"); sb.AppendLine($"Lightning Effects: {EnvTweaksPatches.Settings.AllowLightning}"); sb.AppendLine($"Weather Sounds: {EnvTweaksPatches.Settings.AllowWeatherSounds}"); sb.AppendLine($"Rainfall Particles: {EnvTweaksPatches.Settings.AllowRain}"); sb.AppendLine($"Hail Particles: {EnvTweaksPatches.Settings.AllowHail}"); sb.AppendLine($"Snow Particles: {EnvTweaksPatches.Settings.AllowSnow}"); sb.AppendLine($"Camera Shake: {EnvTweaksPatches.Settings.AllowCameraShake}"); sb.AppendLine($"Fog Effects: {EnvTweaksPatches.Settings.AllowFog}"); sb.AppendLine($"Fog Effects: {EnvTweaksPatches.Settings.AllowFog}"); sb.AppendLine($"Show Clouds: {EnvTweaksPatches.Settings.AllowClouds}"); api.SendChatMessage(".clearchat"); api.ShowChatMessage(sb.ToString()); break; case "lightning": api.ShowChatMessage($"Lightning Effects: {state}"); EnvTweaksPatches.Settings.AllowLightning = state; break; case "sounds": api.ShowChatMessage($"Weather Sounds: {state}"); EnvTweaksPatches.Settings.AllowWeatherSounds = state; break; case "rain": api.ShowChatMessage($"Rainfall Particles: {state}"); EnvTweaksPatches.Settings.AllowRain = state; break; case "hail": api.ShowChatMessage($"Hail Particles: {state}"); EnvTweaksPatches.Settings.AllowHail = state; break; case "snow": api.ShowChatMessage($"Snow Particles: {state}"); EnvTweaksPatches.Settings.AllowSnow = state; break; case "shake": api.ShowChatMessage($"Camera Shake: {state}"); EnvTweaksPatches.Settings.AllowCameraShake = state; break; case "fog": api.ShowChatMessage($"Fog Effects: {state}"); EnvTweaksPatches.Settings.AllowFog = state; break; case "clouds": api.ShowChatMessage($"Show Clouds: {state}"); EnvTweaksPatches.Settings.AllowClouds = state; break; default: api.ShowChatMessage($"Environmental Tweaks: {syntaxMessage}"); break; } settingsFile.SaveAsJson(EnvTweaksPatches.Settings); } api.RegisterCommand("EnvTweaks", "Change settings for Environmental Tweaks.", syntaxMessage, Handler); api.RegisterCommand("et", "Change settings for Environmental Tweaks.", syntaxMessage, Handler); }