• R/O
  • HTTP
  • SSH
  • HTTPS

提交

標籤

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Carbon Copy plugin for VS


Commit MetaInfo

修訂a5cd9edb6a7d9b0acd4bb4ba4a4f13047cbefb8e (tree)
時間2020-12-25 09:54:27
作者melchior <melchior@user...>
Commitermelchior

Log Message

Improved Block/Item export command(s) - domain aware

Change Summary

差異

--- a/CarbonCopy/ClientCommands/CarbonCopyCommand.cs
+++ b/CarbonCopy/ClientCommands/CarbonCopyCommand.cs
@@ -8,6 +8,7 @@ using Vintagestory.API.Common;
88 using Vintagestory.API.Config;
99 using Vintagestory.API.MathTools;
1010
11+
1112 namespace CarbonCopy
1213 {
1314 public class CarbonCopyCommand : ClientChatCommand
@@ -25,12 +26,21 @@ namespace CarbonCopy
2526 private List<BlockPos> markedBlocks = new List<BlockPos>( );
2627 private List<int> colorList = new List<int> { ColorUtil.ToRgba(180, 0, 195, 0) };
2728
29+ internal ModInfo InternalVersion
30+ {
31+ get
32+ {
33+ var gameMod = ClientAPI.ModLoader.GetMod(@"survival");//TODO: Figure out which; Creative / Survival ?
34+ return gameMod.Info;
35+ }
36+ }
37+
2838
2939 public CarbonCopyCommand(ICoreClientAPI clientAPI)
3040 {
3141 this.Command = _name;
32- this.Syntax = @"mark: start/end/ (x/y/z), save [name], clear; dump {items/blocks}";
33- this.Description = "Export carbon-copies of block selections locally.(as json export schematic)";
42+ this.Syntax = @"mark: start/end/ (x/y/z), save [name], clear; dump [items/blocks] [domain?]";
43+ this.Description = @"Export carbon-copies of block selections locally.(as json export schematic) - also Block info...";
3444
3545 ClientAPI = clientAPI;
3646 Logger = clientAPI.Logger;
@@ -75,7 +85,13 @@ namespace CarbonCopy
7585
7686 case "dump":
7787 string ofType = args.PopWord("blocks");
78- if (ofType == "items") { Dump_ItemList( ); } else { Dump_BlockList( ); }
88+ string domainFilter = null;
89+ if (args.Length == 1)
90+ {
91+ domainFilter = args.PopWord( );
92+ }
93+
94+ if (ofType == "items") { Dump_ItemList(domainFilter); } else { Dump_BlockList(domainFilter); }
7995 break;
8096
8197 default:
@@ -225,18 +241,29 @@ namespace CarbonCopy
225241 ClientAPI.ShowChatMessage("Mark(s) Cleared.");
226242 }
227243
228- private void Dump_BlockList( )
244+ private void Dump_BlockList(string domainFilter )
229245 {
230- var filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), "vs_block_list_export_" + GameVersion.OverallVersion + ".tsv");
246+ var filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), "vs_block_list_export_" + InternalVersion.Version + ".tsv");
247+
248+ IEnumerable<Block> bQuery;
249+ if (string.IsNullOrWhiteSpace(domainFilter)) {
250+ bQuery = ClientAPI.World.Blocks.Where(blk => blk.Code != null);
251+ }
252+ else {
253+ bQuery = ClientAPI.World.Blocks.Where(blk => blk.Code != null && blk.Code.Domain.Equals(domainFilter, StringComparison.OrdinalIgnoreCase));
254+ filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), "vs_block_list_export_" + InternalVersion.Version+ "_["+domainFilter +"]" + ".tsv");
255+ }
231256
232257 using (StreamWriter reporter = new StreamWriter(filename, false)) {
233258
234- reporter.WriteLine("MC Block Name\tVS Block Name\tVS ID#\tMaterial\t");
259+ reporter.WriteLine("MC Block Name\tVS Block Name\tVS ID#\tDomain\tMaterial\t");
235260 Logger.VerboseDebug("Dumping {0} Blocks", ClientAPI.World.Blocks.Count);
236- foreach (var block in ClientAPI.World.Blocks.Where(blk => blk.Code != null && blk.Code.Domain == GlobalConstants.DefaultDomain)) {
237- if (block.Id != 0 && !block.IsMissing && block.Code.Path != "unknown" ) {
238- reporter.WriteLine($"____\t{block.Code.Path}\t{block.BlockId}\t{block.BlockMaterial}");
239261
262+
263+
264+ foreach (var block in bQuery) {
265+ if (block.Id != 0 && !block.IsMissing && block.Code.Path != "unknown" ) {
266+ reporter.WriteLine($"____\t{block.Code.Path}\t{block.BlockId}\t{block.Code.Domain}\t{block.BlockMaterial}");
240267 }
241268
242269 }
@@ -244,20 +271,32 @@ namespace CarbonCopy
244271 reporter.Flush( );
245272 }
246273
247- ClientAPI.ShowChatMessage("Created Block List....");
274+ ClientAPI.ShowChatMessage("Created Blocks List....");
248275 }
249276
250- private void Dump_ItemList( )
277+ private void Dump_ItemList(string domainFilter )
251278 {
252- var filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), "vs_item_list_export_" + GameVersion.OverallVersion + ".tsv");
279+ var filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), "vs_item_list_export_" + InternalVersion.Version + ".tsv");
280+
281+ IEnumerable<Item> iQuery;
282+ if (string.IsNullOrWhiteSpace(domainFilter)) {
283+ iQuery = ClientAPI.World.Items.Where(itm => itm.Code != null);
284+ }
285+ else {
286+ iQuery = ClientAPI.World.Items.Where(itm => itm.Code != null && itm.Code.Domain.Equals(domainFilter, StringComparison.OrdinalIgnoreCase));
287+ filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), "vs_item_list_export_" + InternalVersion.Version + "_[" + domainFilter + "]" + ".tsv");
288+ }
253289
254290 using (StreamWriter reporter = new StreamWriter(filename, false)) {
255291
256- reporter.WriteLine("MC Item Name\tVS Item Name\tVS ID#\tStorage Flags\tMax Stack Size\tC.I. Tabs\t");
292+ reporter.WriteLine("MC Item Name\tVS Item Name\tVS ID#\tDomain\tStorage Flags\tMax Stack Size\tC.I. Tabs\t");
257293 Logger.VerboseDebug("Dumping {0} Items", ClientAPI.World.Items.Count);
258- foreach (var item in ClientAPI.World.Items.Where(itm => itm.Code != null && itm.Code.Domain == GlobalConstants.DefaultDomain)) {
294+
295+
296+
297+ foreach (var item in iQuery ) {
259298 if (item.Id != 0 && !item.IsMissing && item.Code.Path != "unknown") {
260- reporter.WriteLine($"____\t{item.Code.Path}\t{item.ItemId}\t{String.Join(",", item.StorageFlags)}\t{item.MaxStackSize}\t{(item.CreativeInventoryTabs != null ? String.Join(",",item.CreativeInventoryTabs): " ")}");
299+ reporter.WriteLine($"____\t{item.Code.Path}\t{item.ItemId}\t{item.Code.Domain}\t{String.Join(",", item.StorageFlags)}\t{item.MaxStackSize}\t{(item.CreativeInventoryTabs != null ? String.Join(",",item.CreativeInventoryTabs): " ")}");
261300 }
262301
263302 }
--- a/CarbonCopy/modinfo.json
+++ b/CarbonCopy/modinfo.json
@@ -1,14 +1,12 @@
11 {
22 "type": "code",
33 "name": "Carbon-Copy",
4- "description" : "Export schematics from MP (clientside!)",
4+ "description" : "Export schematics, and more from SP/MP (clientside!)",
55 "authors": ["Melchior"],
6- "version": "0.1.5",
6+ "version": "0.1.6",
77 "side": "client",
88 "dependencies": {
99 "game": "1.13.0"
1010 },
1111 "website": "http://nowebsite.nope"
12-}
13-
14-
12+}
\ No newline at end of file