Adjustor mod plugin for VS
Revision | 94eb9f434399b311e5f0a5b8e2ccdb9a0a6ed180 (tree) |
---|---|
Zeit | 2019-05-10 09:28:19 |
Autor | melchior <melchior@user...> |
Commiter | melchior |
Fixes for V1.9.2, got wooden logs rotatable.
@@ -31,19 +31,24 @@ namespace Adjustor | ||
31 | 31 | @"north", |
32 | 32 | @"south", |
33 | 33 | @"east", |
34 | - @"west" | |
35 | - };//mabey add: ns, ew, ect...? | |
34 | + @"west", | |
35 | + //tree logs | |
36 | + @"ud", | |
37 | + @"ns", | |
38 | + @"we" | |
39 | + }; | |
36 | 40 | |
37 | 41 | private static string[] blacklistedClasses =new string[] |
38 | 42 | { |
39 | 43 | @"BlockBed", |
40 | 44 | @"BlockDoor", |
41 | 45 | @"BlockTroughDoubleBlock", |
46 | + @"BlockFence" //Need to figure out a better way.. | |
42 | 47 | }; |
43 | 48 | |
44 | 49 | private static string[] whitelistedClasses =new string[] //BROEKN! |
45 | 50 | { |
46 | - @"BlockFence", | |
51 | + @"placeholder", | |
47 | 52 | }; |
48 | 53 | |
49 | 54 | private static string[] blacklistedEntityClasses =new string[] |
@@ -53,7 +58,7 @@ namespace Adjustor | ||
53 | 58 | |
54 | 59 | public ItemAdjustor( ) : base() |
55 | 60 | { |
56 | - //TODO: Fixed rotateion mode VS. Free-Rotation | |
61 | + //TODO: Fixed rotation mode VS. Free-Rotation | |
57 | 62 | } |
58 | 63 | |
59 | 64 | public override void OnLoaded(ICoreAPI api) |
@@ -178,16 +183,13 @@ namespace Adjustor | ||
178 | 183 | ServerApi.SendMessage( thePlayer, GlobalConstants.CurrentChatGroup, "Angle N/E/W/S.", EnumChatType.Notification ); |
179 | 184 | #endif |
180 | 185 | |
181 | - //Special Case for Slabs in N/E/S/W mode when trying to rotate them back 'up' | |
182 | - if ( IsSlabUD(thatBlock) ) { | |
183 | - #if DEBUG | |
184 | - Logger.VerboseDebug( "{0} Invokes Slab Special U/D case", thatBlock.Code ); | |
185 | - #endif | |
186 | + //So many HORIZONTAL Special Cases... | |
187 | + renamedAsset = thatBlock.GetRotatedBlockCode(90);//Except Fences | |
188 | + | |
189 | + if (IsSlabUD(thatBlock)) renamedAsset = SpecialSlabHorizontalFlipCase( thatBlock ); | |
190 | + | |
191 | + if (IsWoodLog(thatBlock)) renamedAsset = WoodOmniFlip( thatBlock , blockSel.Face.Axis, rotateHorizontal); //Wood logs also special | |
186 | 192 | |
187 | - renamedAsset = SpecialSlabHorizontalFlipCase( thatBlock ); | |
188 | - } else { | |
189 | - renamedAsset = thatBlock.GetRotatedBlockCode(90);//Except Fences | |
190 | - } | |
191 | 193 | |
192 | 194 | if (renamedAsset != thatBlock.Code) { |
193 | 195 | #if DEBUG |
@@ -206,16 +208,12 @@ namespace Adjustor | ||
206 | 208 | ServerApi.SendMessage( thePlayer, GlobalConstants.CurrentChatGroup, "Angle U/D.", EnumChatType.Notification ); |
207 | 209 | #endif |
208 | 210 | |
211 | + renamedAsset = thatBlock.GetVerticallyFlippedBlockCode( ); | |
212 | + | |
209 | 213 | //Special Case for Slabs in N/E/S/W mode when trying to rotate them back 'up' |
210 | - if ( IsSlabNEWS(thatBlock) ) { | |
211 | - #if DEBUG | |
212 | - Logger.VerboseDebug( "{0} Invokes Slab Special N/E/W/S case", thatBlock.Code ); | |
213 | - #endif | |
214 | + if ( IsSlabNEWS(thatBlock) ) renamedAsset = SpecialSlabVerticalFlipCase( thatBlock ); | |
214 | 215 | |
215 | - renamedAsset = SpecialSlabVerticalFlipCase( thatBlock ); | |
216 | - } else { | |
217 | - renamedAsset = thatBlock.GetVerticallyFlippedBlockCode( ); | |
218 | - } | |
216 | + if (IsWoodLog(thatBlock)) renamedAsset = WoodOmniFlip( thatBlock , blockSel.Face.Axis,rotateHorizontal ); //Wood logs also special | |
219 | 217 | |
220 | 218 | if (renamedAsset != thatBlock.Code) { |
221 | 219 |
@@ -271,7 +269,7 @@ namespace Adjustor | ||
271 | 269 | } |
272 | 270 | |
273 | 271 | /// <summary> |
274 | - /// Is it Rotatable, possibly? | |
272 | + /// Is it Rotatable, possibly with Known direction? | |
275 | 273 | /// </summary> |
276 | 274 | /// <returns><c>true</c>, if rotatable, <c>false</c> otherwise.</returns> |
277 | 275 | /// <param name="thatBlock">A block.</param> |
@@ -297,7 +295,7 @@ namespace Adjustor | ||
297 | 295 | } |
298 | 296 | |
299 | 297 | /// <summary> |
300 | - /// Is it Rotatable, possibly? | |
298 | + /// Is it Rotatable, possibly via Behavior? | |
301 | 299 | /// </summary> |
302 | 300 | /// <returns><c>true</c>, if rotatable, <c>false</c> otherwise.</returns> |
303 | 301 | /// <param name="thatBlock">A block.</param> |
@@ -356,6 +354,43 @@ namespace Adjustor | ||
356 | 354 | return new AssetLocation(thatBlock.Code.Domain,redirectionPath);//game or item tags? |
357 | 355 | } |
358 | 356 | |
357 | + private static AssetLocation WoodOmniFlip(Block thatBlock, EnumAxis axis, bool axisNormal) | |
358 | + { | |
359 | + string oppositeDirection = string.Empty; | |
360 | + | |
361 | + //wood Log by: ns / we - change to opposite | |
362 | + string directionName = thatBlock.Code.Path.Split( "-".ToCharArray( ) ).Last( ); | |
363 | + if ( axisNormal ) { | |
364 | + switch(directionName) { | |
365 | + case @"ud": | |
366 | + oppositeDirection = (axis == EnumAxis.X || axis == EnumAxis.Z) ? @"ns" : @"we"; | |
367 | + break; | |
368 | + case @"ns": | |
369 | + oppositeDirection = (axis == EnumAxis.Y) ? @"ud" : @"we"; | |
370 | + break; | |
371 | + case @"we": | |
372 | + oppositeDirection = (axis == EnumAxis.Y) ? @"ud" : @"ns"; | |
373 | + break; | |
374 | + } | |
375 | + } else { | |
376 | + switch(directionName) { | |
377 | + case @"ud": | |
378 | + oppositeDirection = (axis == EnumAxis.X) ? @"ns" : @"we"; | |
379 | + break; | |
380 | + case @"ns": | |
381 | + oppositeDirection = @"ud"; | |
382 | + break; | |
383 | + case @"we": | |
384 | + oppositeDirection = @"ud"; | |
385 | + break; | |
386 | + } | |
387 | + } | |
388 | + | |
389 | + var redirectionPath = thatBlock.Code.Path.Replace(directionName,oppositeDirection ); | |
390 | + | |
391 | + return new AssetLocation(thatBlock.Code.Domain,redirectionPath); | |
392 | + } | |
393 | + | |
359 | 394 | /// <summary> |
360 | 395 | /// Determines if is slab in N/E/W/S configuration |
361 | 396 | /// </summary> |
@@ -398,6 +433,11 @@ namespace Adjustor | ||
398 | 433 | } |
399 | 434 | return false; |
400 | 435 | } |
436 | + | |
437 | + private static bool IsWoodLog(Block thatBlock) | |
438 | + { | |
439 | + return thatBlock.Code.FirstPathPart( 0).StartsWith(@"log" ); | |
440 | + } | |
401 | 441 | } |
402 | 442 | |
403 | 443 |
@@ -1,11 +1,11 @@ | ||
1 | 1 | { |
2 | 2 | "type": "code", |
3 | 3 | "name": "Adjustment Tool", |
4 | - "description" : "Alter, Rotate blocks without breaking them.", | |
4 | + "description" : "Alter, Rotate blocks without breaking them. (Even wood-logs)", | |
5 | 5 | "authors": ["Melchior", ], |
6 | - "version": "0.1.5", | |
6 | + "version": "0.1.6", | |
7 | 7 | "dependencies": { |
8 | - "game": "1.9.0", | |
8 | + "game": "1.9.2", | |
9 | 9 | "survival": "" |
10 | 10 | }, |
11 | 11 | "website": "http://nowebsite.nope" |