Skip to content

Commit ce1ef90

Browse files
committed
various block fixes
1 parent a2884a8 commit ce1ef90

File tree

14 files changed

+185
-12
lines changed

14 files changed

+185
-12
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using MiNET.Utils.Vectors;
2+
using MiNET.Worlds;
3+
using System.Numerics;
4+
5+
namespace MiNET.Blocks
6+
{
7+
public partial class CarvedPumpkin : Block
8+
{
9+
public CarvedPumpkin() : base(410)
10+
{
11+
BlastResistance = 5;
12+
Hardness = 1;
13+
}
14+
15+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
16+
{
17+
Direction = player.GetCardinalDirection();
18+
return false;
19+
}
20+
}
21+
}

src/MiNET/MiNET/Blocks/HayBlock.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
#endregion
2525

26+
using MiNET.Utils.Vectors;
27+
using System.Numerics;
28+
using MiNET.Worlds;
29+
using MiNET.Items;
30+
2631
namespace MiNET.Blocks
2732
{
2833
public partial class HayBlock : Block
@@ -33,5 +38,22 @@ public HayBlock() : base(170)
3338
Hardness = 0.5f;
3439
IsFlammable = true;
3540
}
41+
42+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
43+
{
44+
switch (ItemBlock.GetPillarAxisFromFace(face))
45+
{
46+
case BlockAxis.X:
47+
PillarAxis = "x";
48+
break;
49+
case BlockAxis.Y:
50+
PillarAxis = "y";
51+
break;
52+
case BlockAxis.Z:
53+
PillarAxis = "z";
54+
break;
55+
}
56+
return false;
57+
}
3658
}
3759
}

src/MiNET/MiNET/Blocks/Log.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,44 @@ public Log() : base(17)
4141

4242
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
4343
{
44+
switch (ItemBlock.GetPillarAxisFromFace(face))
45+
{
46+
case BlockAxis.X:
47+
PillarAxis = "x";
48+
break;
49+
case BlockAxis.Y:
50+
PillarAxis = "y";
51+
break;
52+
case BlockAxis.Z:
53+
PillarAxis = "z";
54+
break;
55+
}
56+
return false;
57+
}
58+
59+
public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoord)
60+
{
61+
var itemInHand = player.Inventory.GetItemInHand();
62+
63+
if (itemInHand is ItemAxe)
64+
{
65+
switch (OldLogType)
66+
{
67+
case "oak":
68+
world.SetBlock(new StrippedOakLog { Coordinates = Coordinates, PillarAxis = PillarAxis});
69+
break;
70+
case "spruce":
71+
world.SetBlock(new StrippedSpruceLog { Coordinates = Coordinates, PillarAxis = PillarAxis });
72+
break;
73+
case "birch":
74+
world.SetBlock(new StrippedBirchLog { Coordinates = Coordinates, PillarAxis = PillarAxis });
75+
break;
76+
case "jungle":
77+
world.SetBlock(new StrippedJungleLog { Coordinates = Coordinates, PillarAxis = PillarAxis });
78+
break;
79+
}
80+
return true;
81+
}
4482
return false;
4583
}
4684

src/MiNET/MiNET/Blocks/Log2.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,40 @@ public Log2() : base(162)
3939
IsFlammable = true;
4040
}
4141

42+
public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoord)
43+
{
44+
var itemInHand = player.Inventory.GetItemInHand();
45+
46+
if (itemInHand is ItemAxe)
47+
{
48+
switch (NewLogType)
49+
{
50+
case "acacia":
51+
world.SetBlock(new StrippedAcaciaLog { Coordinates = Coordinates, PillarAxis = PillarAxis });
52+
break;
53+
case "dark_oak":
54+
world.SetBlock(new StrippedDarkOakLog { Coordinates = Coordinates, PillarAxis = PillarAxis });
55+
break;
56+
}
57+
return true;
58+
}
59+
return false;
60+
}
61+
4262
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
4363
{
64+
switch (ItemBlock.GetPillarAxisFromFace(face))
65+
{
66+
case BlockAxis.X:
67+
PillarAxis = "x";
68+
break;
69+
case BlockAxis.Y:
70+
PillarAxis = "y";
71+
break;
72+
case BlockAxis.Z:
73+
PillarAxis = "z";
74+
break;
75+
}
4476
return false;
4577
}
4678

src/MiNET/MiNET/Blocks/Observer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Observer() : base(251)
4141

4242
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
4343
{
44-
FacingDirection = ItemBlock.GetFacingDirectionFromEntity(player);
44+
FacingDirection = ItemBlock.GetReverseFacingDirectionFromEntity(player);
4545
return false;
4646
}
4747
}

src/MiNET/MiNET/Blocks/PartialBlocks.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2291,16 +2291,11 @@ public override BlockStateContainer GetState()
22912291
} // method
22922292
} // class
22932293

2294-
public partial class CarvedPumpkin : Block // 410 typeof=CarvedPumpkin
2294+
public partial class CarvedPumpkin // 410 typeof=CarvedPumpkin
22952295
{
22962296
public override string Name => "minecraft:carved_pumpkin";
22972297
[StateRange(0, 3)] public int Direction { get; set; } = 0;
22982298

2299-
public CarvedPumpkin() : base(410)
2300-
{
2301-
IsGenerated = true;
2302-
}
2303-
23042299
public override void SetState(List<IBlockState> states)
23052300
{
23062301
foreach (var state in states)

src/MiNET/MiNET/Blocks/Piston.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public Piston() : base(33)
4040

4141
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
4242
{
43-
FacingDirection = ItemBlock.GetFacingDirectionFromEntity(player);
43+
FacingDirection = ItemBlock.GetReverseFacingDirectionFromEntity(player);
4444

4545
return false;
4646
}

src/MiNET/MiNET/Blocks/PurpurBlock.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323

2424
#endregion
2525

26+
using MiNET.Items;
27+
using MiNET.Utils.Vectors;
28+
using System.Numerics;
29+
using MiNET.Worlds;
30+
2631
namespace MiNET.Blocks
2732
{
2833
public partial class PurpurBlock : Block
@@ -32,5 +37,22 @@ public PurpurBlock() : base(201)
3237
BlastResistance = 30;
3338
Hardness = 1.5f;
3439
}
40+
41+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
42+
{
43+
switch (ItemBlock.GetPillarAxisFromFace(face))
44+
{
45+
case BlockAxis.X:
46+
PillarAxis = "x";
47+
break;
48+
case BlockAxis.Y:
49+
PillarAxis = "y";
50+
break;
51+
case BlockAxis.Z:
52+
PillarAxis = "z";
53+
break;
54+
}
55+
return false;
56+
}
3557
}
3658
}

src/MiNET/MiNET/Blocks/QuartzBlock.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
#endregion
2525

26+
using System.Numerics;
2627
using MiNET.Items;
28+
using MiNET.Utils.Vectors;
29+
using MiNET.Worlds;
2730

2831
namespace MiNET.Blocks
2932
{
@@ -35,6 +38,23 @@ public QuartzBlock() : base(155)
3538
Hardness = 0.8f;
3639
}
3740

41+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
42+
{
43+
switch (ItemBlock.GetPillarAxisFromFace(face))
44+
{
45+
case BlockAxis.X:
46+
PillarAxis = "x";
47+
break;
48+
case BlockAxis.Y:
49+
PillarAxis = "y";
50+
break;
51+
case BlockAxis.Z:
52+
PillarAxis = "z";
53+
break;
54+
}
55+
return false;
56+
}
57+
3858
public override Item GetSmelt()
3959
{
4060
if (ChiselType == "default")

src/MiNET/MiNET/Blocks/Smoker.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
#endregion
2525

26-
using System;
2726
using System.Numerics;
28-
using MiNET.Items;
2927
using MiNET.Utils.Vectors;
3028
using MiNET.Worlds;
3129

0 commit comments

Comments
 (0)