• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

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

First Machine Age's Mods (Combined repo.)


Commit MetaInfo

Revisiónf1188402afc64dcd42bf22797be7bed544e5ec11 (tree)
Tiempo2021-05-28 10:51:22
Autormelchior <melchior@user...>
Commitermelchior

Log Message

W.I.P., More Work II

Cambiar Resumen

Diferencia incremental

--- a/ConstructionSupport/Blocks/Common/BlockHelpers.cs
+++ b/ConstructionSupport/Blocks/Common/BlockHelpers.cs
@@ -32,6 +32,14 @@ namespace ConstructionSupport
3232
3333 return false;
3434 }
35+
36+ public static string DiagonalInitial(this BlockPos pos, BlockPos other)
37+ {
38+ //Subtract, to Normal; then 'Cardinals'...
39+ var normal = pos.SubCopy(other);
40+ var diagonal = Cardinal.FromNormali(normal.ToVec3i( ));
41+ return diagonal?.Initial ?? "?";
42+ }
3543 }
3644 }
3745
--- a/ConstructionSupport/Blocks/Common/GenericScaffold.cs
+++ b/ConstructionSupport/Blocks/Common/GenericScaffold.cs
@@ -82,22 +82,27 @@ namespace ConstructionSupport
8282 return false;
8383 }
8484
85- public bool CheckCornerSolid(IBlockAccessor world, BlockPos checkPos )
85+ public bool CheckCornerSolid(IBlockAccessor world, BlockPos checkPos, out BlockPos foundCorner )
8686 {
8787 //Visit all diagonal combinations
8888 Stack<BlockPos> checkList = new Stack<BlockPos>( );
8989
90- checkList.Push(checkPos.Copy( ).Add( 1, 1, 0));
91- checkList.Push(checkPos.Copy( ).Add( 1,-1, 0));
92- checkList.Push(checkPos.Copy( ).Add(-1, 1, 0));
93- checkList.Push(checkPos.Copy( ).Add(-1,-1, 0));
90+ checkList.Push(checkPos.Copy( ).Add( 1, 0, 1));
91+ checkList.Push(checkPos.Copy( ).Add( 1, 0,-1));
92+ checkList.Push(checkPos.Copy( ).Add(-1, 0, 1));
93+ checkList.Push(checkPos.Copy( ).Add(-1, 0,-1));
9494 Block toCheck;
9595 while (checkList.Count > 0 )
9696 {
97- toCheck = world.GetBlock(checkList.Pop( ));
98- if (toCheck != null && toCheck.IsSolid()) return true;
99- }
100-
97+ var here = checkList.Pop( );
98+ toCheck = world.GetBlock(here);
99+ if (toCheck != null && toCheck.IsSolid( ))
100+ {
101+ foundCorner = here;
102+ return true;
103+ }
104+ }
105+ foundCorner = null;
101106 return false;
102107 }
103108
--- a/ConstructionSupport/Blocks/DeckworkCornerBlock.cs
+++ b/ConstructionSupport/Blocks/DeckworkCornerBlock.cs
@@ -32,21 +32,22 @@ namespace ConstructionSupport
3232
3333 public override bool TryPlaceBlock(IWorldAccessor world, IPlayer byPlayer, ItemStack itemstack, BlockSelection blockSel, ref string failureCode)
3434 {
35- var placeSpot = blockSel.Position.AddCopy(blockSel.Face.Opposite, 1);
35+ var placeSpot = blockSel.Position.AddCopy(blockSel.Face, 1);
3636 var lookSpot = blockSel.Position.Copy( ).Offset(blockSel.Face.Opposite);
3737 var surfaceBlock = world.BlockAccessor.GetBlock(lookSpot);
38+ BlockPos cornerPos;
3839
3940 if (base.ValidAttachmentFaces.Contains(blockSel.Face)) {
4041
4142 //of the 4 Corners - any 1 a solid block; AND attachment to deckwork on faces...
4243 if (IsDeckwork(world.BlockAccessor, lookSpot)
43- && CheckCornerSolid(world.BlockAccessor, placeSpot ))
44+ && CheckCornerSolid(world.BlockAccessor, placeSpot, out cornerPos))
4445 {
46+
47+ if (CanPlaceBlock(world, byPlayer, blockSel, ref failureCode)) {
4548 #if DEBUG
46- api.World.Logger.VerboseDebug($"Success: {blockSel.Face} for {this.Code} onto {surfaceBlock.Code} @ {blockSel.Position}");
49+ api.World.Logger.VerboseDebug($"Valid: {blockSel.Face} for {this.Code} onto {surfaceBlock.Code} @ {blockSel.Position}");
4750 #endif
48-
49- if (CanPlaceBlock(world, byPlayer, blockSel, ref failureCode)) {
5051 return DoPlaceBlock(world, byPlayer, blockSel, itemstack);
5152 }
5253 }
@@ -79,13 +80,27 @@ namespace ConstructionSupport
7980 }
8081
8182 if (preventDefault) return result;
83+ //Find Corner;
84+ var lookSpot = blockSel.Position.Copy( ).Offset(blockSel.Face.Opposite);
85+ var placeSpot = blockSel.Position.AddCopy(blockSel.Face, 1);
86+ BlockPos cornerPos;
87+ CheckCornerSolid(world.BlockAccessor, placeSpot, out cornerPos);
88+ var realCornerInitial = placeSpot.DiagonalInitial(cornerPos);
89+
90+ #if DEBUG
91+ api.World.Logger.VerboseDebug($"Diagonal Changed: {realCornerInitial} for {this.Code}, Look: {lookSpot} ,Place: {placeSpot}, Corner: {cornerPos}");
92+ #endif
8293
83- var rotatedBlockId = RotateToFace(blockSel.Face.Opposite);
84- //Switcheroo!
85- world.BlockAccessor.SetBlock(rotatedBlockId.BlockId, blockSel.Position, byItemStack);
94+ var blockAssetCode = this.CodeWithVariant(@"corner", realCornerInitial);
8695
96+ var rotatedBlock = api.World.BlockAccessor.GetBlock(blockAssetCode);
97+ if (rotatedBlock != null)
98+ {
99+ world.BlockAccessor.SetBlock(rotatedBlock.BlockId, placeSpot, byItemStack);
100+ return true;
101+ }
87102
88- return true;
103+ return false;
89104 }
90105
91106
--- a/ConstructionSupport/assets/fma/blocktypes/frames/deckwork_corner.json
+++ b/ConstructionSupport/assets/fma/blocktypes/frames/deckwork_corner.json
@@ -19,7 +19,7 @@
1919 drops: [{ code: "deckwork_corner-ne" }],
2020 shapebytype: {
2121 "*-ne": { base: "block/frames/deckwork_diag", rotateY: 0 },
22- "*-nw": { base: "block/frames/deckwork_diag", rotateY: 90 },
22+ "*-nw": { base: "block/frames/deckwork_diag", rotateY: -90 },
2323 "*-se": { base: "block/frames/deckwork_diag", rotateY: 180 },
2424 "*-sw": { base: "block/frames/deckwork_diag", rotateY: 270 },
2525 },
--- a/ConstructionSupport/assets/fma/shapes/block/frames/deckwork_diag.json
+++ b/ConstructionSupport/assets/fma/shapes/block/frames/deckwork_diag.json
@@ -15,15 +15,15 @@
1515 {
1616 "name": "Deck",
1717 "from": [ 0.0, 15.0, 0.0 ],
18- "to": [ 16.0, 16.0, 14.0 ],
18+ "to": [ 15.0, 16.0, 14.0 ],
1919 "rotationOrigin": [ 0.0, 4.0, 0.0 ],
2020 "faces": {
21- "north": { "texture": "#generic", "uv": [ 0.0, 5.0, 16.0, 6.0 ] },
21+ "north": { "texture": "#generic", "uv": [ 0.0, 5.0, 15.0, 6.0 ] },
2222 "east": { "texture": "#generic", "uv": [ 0.0, 1.0, 1.0, 15.0 ], "rotation": 90 },
23- "south": { "texture": "#generic", "uv": [ 0.0, 4.0, 16.0, 5.0 ] },
23+ "south": { "texture": "#generic", "uv": [ 0.0, 4.0, 15.0, 5.0 ] },
2424 "west": { "texture": "#generic", "uv": [ 0.0, 2.0, 1.0, 16.0 ], "rotation": 90 },
25- "up": { "texture": "#generic", "uv": [ 0.0, 1.0, 16.0, 15.0 ] },
26- "down": { "texture": "#generic", "uv": [ 0.0, 1.0, 16.0, 15.0 ] }
25+ "up": { "texture": "#generic", "uv": [ 0.0, 1.0, 15.0, 15.0 ] },
26+ "down": { "texture": "#generic", "uv": [ 0.0, 1.0, 15.0, 15.0 ] }
2727 },
2828 "children": [
2929 {