Skip to content

Commit eeca5e3

Browse files
committed
various fixes
1 parent f45743c commit eeca5e3

File tree

10 files changed

+218
-136
lines changed

10 files changed

+218
-136
lines changed

src/MiNET/MiNET.Client/McpeClientMessageHandlerBase.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ public virtual void HandleMcpeInventoryTransaction(McpeInventoryTransaction mess
273273

274274
public virtual void HandleMcpeMobEquipment(McpeMobEquipment message)
275275
{
276+
/*Log.Warn($"Entity with {message.runtimeEntityId} is holding {message.item.Name}");*/
276277
}
277278

278279
public virtual void HandleMcpeMobArmorEquipment(McpeMobArmorEquipment message)
@@ -289,6 +290,25 @@ public virtual void HandleMcpeHurtArmor(McpeHurtArmor message)
289290

290291
public virtual void HandleMcpeSetEntityData(McpeSetEntityData message)
291292
{
293+
/*if (message.metadata[0] == null) { return; }
294+
MetadataLong metadataLong = message.metadata[0] as MetadataLong;
295+
byte[] bytes = BitConverter.GetBytes(metadataLong.Value);
296+
BitArray bits = new BitArray(bytes);
297+
Log.Warn($"Got entity metadata flags from value: {metadataLong.Value}");
298+
Log.Warn($"start =============================================");
299+
for (int i = 0; i < Enum.GetValues(typeof(DataFlags)).Length; i++)
300+
{
301+
DataFlags flag = (DataFlags) i;
302+
if (i < 64)
303+
{
304+
Log.Warn($"{flag}: {bits[i]}");
305+
}
306+
else
307+
{
308+
Log.Warn($"{flag}: {bits[i - 64]}");
309+
}
310+
}
311+
Log.Warn($"end =============================================");*/
292312
}
293313

294314
public virtual void HandleMcpeSetEntityMotion(McpeSetEntityMotion message)

src/MiNET/MiNET/Blocks/Leaves.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
using System;
2727
using System.Collections.Generic;
28+
using System.Numerics;
2829
using log4net;
2930
using MiNET.Items;
3031
using MiNET.Utils;
@@ -127,5 +128,19 @@ private bool FindLog(Level level, BlockCoordinates coord, List<BlockCoordinates>
127128

128129
return false;
129130
}
131+
132+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
133+
{
134+
var itemInHand = player.Inventory.GetItemInHand();
135+
OldLeafType = itemInHand.Metadata switch
136+
{
137+
0 => "oak",
138+
1 => "spruce",
139+
2 => "birch",
140+
3 => "jungle",
141+
_ => throw new ArgumentOutOfRangeException()
142+
};
143+
return false;
144+
}
130145
}
131146
}

src/MiNET/MiNET/Blocks/Leaves2.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
using System;
2727
using System.Collections.Generic;
28+
using System.Numerics;
2829
using log4net;
2930
using MiNET.Items;
3031
using MiNET.Utils;
@@ -127,5 +128,17 @@ private bool FindLog(Level level, BlockCoordinates coord, List<BlockCoordinates>
127128

128129
return false;
129130
}
131+
132+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
133+
{
134+
var itemInHand = player.Inventory.GetItemInHand();
135+
NewLeafType = itemInHand.Metadata switch
136+
{
137+
0 => "acacia",
138+
1 => "dark_oak",
139+
_ => throw new ArgumentOutOfRangeException()
140+
};
141+
return false;
142+
}
130143
}
131144
}

src/MiNET/MiNET/Blocks/Sapling.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ protected override bool CanPlace(Level world, Player player, BlockCoordinates bl
5454
return false;
5555
}
5656

57+
public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
58+
{
59+
var itemInHand = player.Inventory.GetItemInHand();
60+
SaplingType = itemInHand.Metadata switch
61+
{
62+
0 => "oak",
63+
1 => "spruce",
64+
2 => "birch",
65+
3 => "jungle",
66+
4 => "acacia",
67+
5 => "dark_oak",
68+
_ => throw new ArgumentOutOfRangeException()
69+
};
70+
return false;
71+
}
72+
5773
public override bool Interact(Level level, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoord)
5874
{
5975
if (player.Inventory.GetItemInHand() is ItemDye inHand && inHand.Metadata == 15)

0 commit comments

Comments
 (0)