Carbon Copy plugin for VS
修訂 | 2bd43bf791833937d7ad584005508e3be5d5c9dd (tree) |
---|---|
時間 | 2021-11-10 07:36:38 |
作者 | melchior <melchior@user...> |
Commiter | melchior |
select bugfix, msg improvements
Bugfix for Selection box, not matching exported area.
Somewhat improved command feedback messages.
@@ -20,7 +20,7 @@ | ||
20 | 20 | <ConsolePause>false</ConsolePause> |
21 | 21 | <CustomCommands> |
22 | 22 | <CustomCommands> |
23 | - <Command type="AfterBuild" command="7z -tzip a Carboncopy_${ProjectConfig}.zip" workingdir="${TargetDir}" /> | |
23 | + <Command type="AfterBuild" command="7z a -tzip -x!*.zip -aoa CarbonCopy_${ProjectConfig}.zip" workingdir="${TargetDir}" /> | |
24 | 24 | <Command type="AfterClean" command="rm -f *.zip" workingdir="${TargetDir}" /> |
25 | 25 | </CustomCommands> |
26 | 26 | </CustomCommands> |
@@ -39,7 +39,7 @@ namespace CarbonCopy | ||
39 | 39 | public CarbonCopyCommand(ICoreClientAPI clientAPI) |
40 | 40 | { |
41 | 41 | this.Command = _name; |
42 | - this.Syntax = @"mark: start/end/ (x/y/z), save [name], clear; dump [items/blocks] [domain?]"; | |
42 | + this.Syntax = @"mark[ start/end(x/y/z) ], save [name], clear; dump [items/blocks] [domain?]"; | |
43 | 43 | this.Description = @"Export carbon-copies of block selections locally.(as json export schematic) - also Block info..."; |
44 | 44 | |
45 | 45 | ClientAPI = clientAPI; |
@@ -57,7 +57,7 @@ namespace CarbonCopy | ||
57 | 57 | * mark start z+20 |
58 | 58 | * mark clear |
59 | 59 | * save {NAME} |
60 | - * | |
60 | + * dump blocks/items | |
61 | 61 | * |
62 | 62 | */ |
63 | 63 |
@@ -95,7 +95,7 @@ namespace CarbonCopy | ||
95 | 95 | break; |
96 | 96 | |
97 | 97 | default: |
98 | - ClientAPI.ShowChatMessage($"Unrecognised command: {command}"); | |
98 | + ClientAPI.ShowChatMessage($"Unrecognised command: '{command}' - try 'mark/save/clear'..."); | |
99 | 99 | break; |
100 | 100 | } |
101 | 101 | } |
@@ -117,7 +117,7 @@ namespace CarbonCopy | ||
117 | 117 | } |
118 | 118 | BendBlockPosition(this.start, args); |
119 | 119 | |
120 | - ClientAPI.ShowChatMessage(string.Format("Marked start; ({0}).", start)); | |
120 | + ClientAPI.ShowChatMessage(string.Format("Start@ ({0}).", start)); | |
121 | 121 | break; |
122 | 122 | |
123 | 123 | case "end": |
@@ -126,11 +126,11 @@ namespace CarbonCopy | ||
126 | 126 | } |
127 | 127 | BendBlockPosition(this.end, args); |
128 | 128 | |
129 | - ClientAPI.ShowChatMessage(string.Format("Marked end; ({0}).", end)); | |
129 | + ClientAPI.ShowChatMessage(string.Format("End@ ({0}).", end)); | |
130 | 130 | break; |
131 | 131 | |
132 | 132 | default: |
133 | - ClientAPI.ShowChatMessage("Mark: start or end ?"); | |
133 | + ClientAPI.ShowChatMessage("Mark synax: start or end"); | |
134 | 134 | break; |
135 | 135 | } |
136 | 136 |
@@ -138,61 +138,64 @@ namespace CarbonCopy | ||
138 | 138 | |
139 | 139 | if (this.start != null && |
140 | 140 | this.end != null && |
141 | - ClientAPI.World.BulkBlockAccessor.IsValidPos(this.start) && | |
142 | - ClientAPI.World.BulkBlockAccessor.IsValidPos(this.end) | |
141 | + ClientAPI.World.BulkBlockAccessor.IsValidPos(this.start) | |
142 | + && ClientAPI.World.BulkBlockAccessor.IsValidPos(this.end) | |
143 | 143 | ) { |
144 | 144 | |
145 | 145 | //Calc. Vol: |
146 | 146 | var size = start.DistanceTo(end); |
147 | 147 | |
148 | 148 | if (size > 1) { |
149 | - | |
150 | 149 | this.validSelection = true; |
151 | - | |
152 | 150 | this.markedBlocks.Clear( ); |
153 | 151 | |
154 | 152 | ClientAPI.World.BulkBlockAccessor.WalkBlocks(start, end, addToMarked); |
155 | 153 | |
156 | 154 | ClientAPI.World.HighlightBlocks(ClientAPI.World.Player, _highlightSlot, this.markedBlocks, colorList, EnumHighlightBlocksMode.Absolute, EnumHighlightShape.Arbitrary); |
157 | 155 | |
158 | - ClientAPI.ShowChatMessage(string.Format("Marked area: {0:f1}diag = {1} blocks", size, markedBlocks.Count)); | |
156 | + int X = Math.Abs(start.X - end.X) + 1; | |
157 | + int Y = Math.Abs(start.Y - end.Y) + 1; | |
158 | + int Z = Math.Abs(start.Z - end.Z) + 1; | |
159 | + | |
160 | + ClientAPI.ShowChatMessage($"Marked (X {X:#},Y {Y:#} ,Z {Z:#} ) {size:f1} diagonal = {markedBlocks.Count} cells"); | |
159 | 161 | } |
160 | 162 | else { |
161 | - ClientAPI.ShowChatMessage("Marked area: volume too small"); ; | |
162 | - } | |
163 | + ClientAPI.ShowChatMessage("Marked area: volume too small"); | |
163 | 164 | } |
165 | + } | |
164 | 166 | } |
165 | 167 | else { |
166 | - ClientAPI.ShowChatMessage("Mark: start / end (x,y,z +-1#)"); | |
168 | + ClientAPI.ShowChatMessage("(Needs args) Mark: start / end (x,y,z +-1#)"); | |
167 | 169 | } |
168 | 170 | |
169 | 171 | } |
170 | 172 | |
171 | 173 | private void BendBlockPosition(BlockPos position, CmdArgs args) |
172 | 174 | { |
173 | - char? axis = args.PopChar( ); | |
174 | - int? offset = args.PopInt( ); | |
175 | + if (args.Length == 0) return; | |
176 | + char? axis = args.PopChar(); | |
177 | + int? offset = args.PopInt(); | |
175 | 178 | |
176 | - if (axis.HasValue && offset.HasValue) { | |
179 | + if (axis.HasValue && offset.HasValue) { | |
177 | 180 | switch (Char.ToLowerInvariant(axis.Value)) { |
178 | 181 | |
179 | - case 'x': | |
180 | - ClientAPI.ShowChatMessage(string.Format("applied X offset {0},", offset.Value)); | |
182 | + case 'x': | |
181 | 183 | position.Add(dx: offset.Value, dy: 0, dz: 0); |
184 | + ClientAPI.ShowChatMessage(string.Format("altered {0}, offset {1}", axis.Value, offset.Value)); | |
182 | 185 | break; |
183 | 186 | |
184 | - case 'y': | |
185 | - ClientAPI.ShowChatMessage(string.Format("applied Y offset {0},", offset.Value)); | |
187 | + case 'y': | |
186 | 188 | position.Add(dx: 0, dy: offset.Value, dz: 0); |
189 | + ClientAPI.ShowChatMessage(string.Format("altered {0}, offset {1}", axis.Value, offset.Value)); | |
187 | 190 | break; |
188 | 191 | |
189 | - case 'z': | |
190 | - ClientAPI.ShowChatMessage(string.Format("applied Z offset {0},", offset.Value)); | |
192 | + case 'z': | |
191 | 193 | position.Add(dx: 0, dy: 0, dz: offset.Value); |
194 | + ClientAPI.ShowChatMessage(string.Format("altered {0}, offset {1}", axis.Value, offset.Value)); | |
192 | 195 | break; |
193 | 196 | |
194 | 197 | default: |
195 | - //Nothing to do. | |
198 | + ClientAPI.ShowChatMessage("Can't apply offset; not in \"x, y, z +1#\" form..."); | |
196 | 199 | break; |
197 | 200 | } |
198 | 201 | } |
@@ -206,16 +209,30 @@ namespace CarbonCopy | ||
206 | 209 | private void Process_SaveCommand(string filename) |
207 | 210 | { |
208 | 211 | if (validSelection) { |
209 | - | |
210 | 212 | BlockSchematic blockExport = new BlockSchematic( ); |
213 | + //Random Start / End | |
211 | 214 | |
212 | - blockExport.Init(ClientAPI.World.BlockAccessor); | |
215 | + //'Lower'-> South + Westmost corner of same volume | |
216 | + BlockPos seCorner = new BlockPos(Math.Max(start.X, end.X), Math.Min(start.Y, end.Y), Math.Max(start.Z, end.Z)); | |
217 | + //'Upper'-> North + Eastmost corner of same volume | |
218 | + BlockPos nwCorner = new BlockPos(Math.Min(start.X, end.X), Math.Max(start.Y, end.Y), Math.Min(start.Z, end.Z)); | |
219 | + | |
220 | + //diagonal 'left'; offset into 'upper' - adds corner | |
221 | + nwCorner.Up(); | |
213 | 222 | |
214 | - blockExport.AddArea(ClientAPI.World, this.start, this.end); | |
223 | + seCorner.X += 1; | |
224 | + seCorner.Z += 1; | |
225 | + | |
226 | + blockExport.Init(ClientAPI.World.BlockAccessor); | |
227 | + #if DEBUG | |
228 | + Logger.Debug("Start: {0}, End:{1}", start, end); | |
229 | + Logger.Debug("S.E C: {0}, N.W:{1} (offset)", seCorner, nwCorner); | |
230 | + #endif | |
231 | + blockExport.AddArea(ClientAPI.World, seCorner, nwCorner);//Off by 1 in XYZ | |
215 | 232 | |
216 | - if (blockExport.Pack(ClientAPI.World, this.start))//What should start Be? | |
233 | + if (blockExport.Pack(ClientAPI.World, seCorner))//? | |
217 | 234 | { |
218 | - ClientAPI.ShowChatMessage(string.Format("Export packed OK: {0} Blocks {1} Entities {2} BlockEntity", blockExport.BlockIds.Count, blockExport.Entities.Count, blockExport.BlockEntities.Count)); | |
235 | + ClientAPI.ShowChatMessage(string.Format("Export packed OK: {0} BlockIDs, {1}, Entities, {2} BlockEntities; ({3} total blocks)", blockExport.BlockIds.Count, blockExport.Entities.Count, blockExport.BlockEntities.Count, blockExport.Indices.Count)); | |
219 | 236 | |
220 | 237 | filename = Path.Combine(ClientAPI.GetOrCreateDataPath(_exportPath), filename); |
221 | 238 |
@@ -1,12 +1,12 @@ | ||
1 | 1 | { |
2 | 2 | "type": "code", |
3 | 3 | "name": "Carbon-Copy", |
4 | - "description" : "Export schematics, and more from SP/MP (clientside!)", | |
4 | + "description" : "Replicate builds, and more from SP/MP (clientside!)", | |
5 | 5 | "authors": ["Melchior"], |
6 | - "version": "0.1.6", | |
6 | + "version": "0.1.7", | |
7 | 7 | "side": "client", |
8 | 8 | "dependencies": { |
9 | - "game": "1.13.0" | |
9 | + "game": "1.15.0" | |
10 | 10 | }, |
11 | 11 | "website": "http://nowebsite.nope" |
12 | 12 | } |
\ No newline at end of file |