Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 57 additions & 11 deletions src/MiNET/MiNET.Client/MiNetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ private static void Main(string[] args)
int threads;
int iothreads;
ThreadPool.GetMinThreads(out threads, out iothreads);
//var client = new MiNetClient(new IPEndPoint(IPAddress.Parse("10.0.0.6"), 19132), "RagnokBot", new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount)));
var client = new MiNetClient(new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132), "TheGrey", new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount)));
//var client = new MiNetClient(new IPEndPoint(IPAddress.Loopback, 19132), "TheGrey", new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount)));

var client = new MiNetClient(new IPEndPoint(Dns.GetHostEntry("yodamine.com").AddressList[0], 19132), "TheGrey", new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount)));
//var client = new MiNetClient(new IPEndPoint(IPAddress.Loopback, 19132), "TheGrey", new DedicatedThreadPool(new DedicatedThreadPoolSettings(Environment.ProcessorCount)));

client.StartClient();
client.StartClient();
Log.Warn("Client listening for connecting on: " + client._clientEndpoint);
Console.WriteLine("Server started.");

Expand Down Expand Up @@ -613,19 +613,16 @@ private void HandleConnectedPacket(ConnectedPacket packet)

public void AddToProcessing(Packet message)
{
if (Session.CryptoContext == null || Session.CryptoContext.UseEncryption == false || message.Reliability != Reliability.ReliableOrdered)
if (message.Reliability != Reliability.ReliableOrdered)
{
HandlePacket(message);
return;
}

//Log.Error("DO NOT USE THIS");
//throw new Exception("DO NOT USE THIS");

lock (_eventSync)
{
if (_lastSequenceNumber < 0) _lastSequenceNumber = 1;

if (_queue.Count == 0 && message.OrderingIndex == _lastSequenceNumber + 1)
{
_lastSequenceNumber = message.OrderingIndex;
Expand Down Expand Up @@ -1123,10 +1120,27 @@ private void HandlePacket(Packet message)
else if (typeof (McpeUpdateEquipment) == message.GetType())
{
OnMcpeUpdateEquipment((McpeUpdateEquipment) message);

return;

}

else if (typeof(McpeSetDisplayObjective) == message.GetType())
{
OnMcpeSetDisplayObjective((McpeSetDisplayObjective)message);
return;
}

else if (typeof(McpeSetScoreboardIdentity) == message.GetType())
{
OnMcpeSetScoreboardIdentity((McpeSetScoreboardIdentity)message);
return;
}

else if(typeof (McpeSetScore) == message.GetType())
{
OnMcpeSetScore((McpeSetScore)message);
return;
}


else if (typeof (UnknownPacket) == message.GetType())
{
Expand All @@ -1140,6 +1154,38 @@ private void HandlePacket(Packet message)
}
}

private void OnMcpeSetDisplayObjective(McpeSetDisplayObjective message)
{
Log.Warn($"Criterium {message.criteriaName}");
Log.Warn($"DisplayName {message.displayName}");
Log.Warn($"Slot {message.displaySlot}");
Log.Warn($"Obj {message.objectiveName}");
Log.Warn($"Sort {message.sortOrder}");
}

private void OnMcpeSetScoreboardIdentity(McpeSetScoreboardIdentity message)
{
Log.Warn($"Type {message.type}");
foreach (var id in message.scoreboardIdentityPackets)
{
Log.Warn($"ScoreboardId {id.ScoreboardId}");
Log.Warn($"EntityId {id.EntityId}");
}
}

private void OnMcpeSetScore(McpeSetScore message)
{
Log.Warn($"Type {message.type}");
foreach(var scores in message.scorePacketInfos)
{
Log.Warn($"Id {scores.scoreboardId}");
Log.Warn($"Obj {scores.objectiveName}");
Log.Warn($"Score {scores.score}");
Log.Warn($"IdentityType {scores.addType}");
Log.Warn($"FakeName {scores.fakePlayer}");
}
}

private void OnMcpeInventoryTransaction(McpeInventoryTransaction message)
{
}
Expand Down Expand Up @@ -1427,7 +1473,7 @@ private void OnMcpeServerToClientHandshake(McpeServerToClientHandshake message)
string x5u = headers["x5u"];

ECPublicKeyParameters remotePublicKey = (ECPublicKeyParameters)
PublicKeyFactory.CreateKey(x5u.DecodeBase64Url());
PublicKeyFactory.CreateKey(x5u.DecodeBase64());


var signParam = new ECParameters
Expand Down
5 changes: 5 additions & 0 deletions src/MiNET/MiNET.Test.Console/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MiNET.fnbt" version="1.0.13" targetFramework="net461" />
<package id="Topshelf" version="4.0.3" targetFramework="net461" />
</packages>
11 changes: 10 additions & 1 deletion src/MiNET/MiNET/Entities/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ public enum DataFlags
Charged,

Tamed,
Orphaned,
Leashed,
Sheared,
FlagAllFlying,
Expand All @@ -369,7 +370,15 @@ public enum DataFlags
AffectedByGravity,
FireImmune,
Dancing,
Enchanted
Enchanted,

ShowTridentRope,
ContainerPrivate,
SpinAttack = 55,
Swimming = 56,
Bribed = 57,
Pregnant = 58,
LayingEgg = 59
}

protected virtual BitArray GetFlags()
Expand Down
49 changes: 42 additions & 7 deletions src/MiNET/MiNET/LoginMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public void DecodeCert(McpeLogin message)
_playerInfo.PlatformChatId = payload.PlatformChatId;
_playerInfo.ServerAddress = payload.ServerAddress;
_playerInfo.UIProfile = payload.UIProfile;
_playerInfo.ThirdPartyName = payload.ThirdPartyName;
_playerInfo.TenantId = payload.TenantId;

_playerInfo.Skin = new Skin()
Expand Down Expand Up @@ -361,9 +360,9 @@ public void DecodeCert(McpeLogin message)
{
X = pubAsyKey.Q.AffineXCoord.GetEncoded(),
Y = pubAsyKey.Q.AffineYCoord.GetEncoded()
},
D = privAsyKey.D.ToByteArrayUnsigned()
}
};
signParam.D = CryptoUtils.FixDSize(privAsyKey.D.ToByteArrayUnsigned(), signParam.Q.X.Length);
signParam.Validate();

string signedToken = null;
Expand Down Expand Up @@ -600,10 +599,46 @@ public void HandleMcpeLabTable(McpeLabTable messae)

}

public void HandleMcpeSetLocalPlayerAsInitializedPacket(McpeSetLocalPlayerAsInitializedPacket message)
{
}
}
public void HandleMcpeSetLocalPlayerAsInitializedPacket(McpeSetLocalPlayerAsInitialized message)
{

}

public void HandleSetScoreboardIdentity(McpeSetScoreboardIdentity message)
{

}

public void HandleUpdateEnumSoft(McpeUpdateSoftEnum message)
{

}

public void HandleNetworkStackLatency(McpeNetworkStackLatency message)
{

}

public void HandleScriptCustomEvent(McpeScriptCustomEvent message)
{

}

public void HandleMcpeRemoveObjective(McpeRemoveObjective mesage)
{

}

public void HandleMcpeSetDisplayObjective(McpeSetDisplayObjective message)
{

}

public void HandleMcpeSetScore(McpeSetScore message)
{

}
}

public interface IServerManager
{
Expand Down
8 changes: 6 additions & 2 deletions src/MiNET/MiNET/Net/MCPE Protocol Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Read more about packets and this specification on the [Protocol Wiki](https://gi
| Data type |
|:--- |
| BlockCoordinates [(wiki)](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-Type-BlockCoordinates) |
| Blockstates [(wiki)](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-Type-Blockstates) |
| bool [(wiki)](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-Type-bool) |
| byte [(wiki)](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-Type-byte) |
| byte[] [(wiki)](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-Type-byte[]) |
Expand Down Expand Up @@ -427,6 +428,8 @@ Wiki: [Start Game](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-StartG
|Is Trial | bool | |
|Current Tick | long | |
|Enchantment Seed | SignedVarInt | |
|Blockstates | Blockstates | |
|Multiplayer Correlation ID | string | |
-----------------------------------------------------------------------
### Add Player (0x0c)
Wiki: [Add Player](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-AddPlayer)
Expand Down Expand Up @@ -466,6 +469,7 @@ Wiki: [Add Player](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-AddPla
|Custom stored permissions | UnsignedVarInt | |
|User Id | long | |
|Links | Links | |
|Device ID | string | |
-----------------------------------------------------------------------
### Add Entity (0x0d)
Wiki: [Add Entity](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-AddEntity)
Expand Down Expand Up @@ -503,6 +507,7 @@ val2 float
|Speed Z | float | |
|Pitch | float | |
|Yaw | float | |
|Head Yaw | float | |
|Attributes | EntityAttributes | |
|Metadata | MetadataDictionary | |
|Links | Links | |
Expand Down Expand Up @@ -577,9 +582,8 @@ Wiki: [Move Entity](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-MoveE
| Name | Type | Size |
|:-----|:-----|:-----|
|Runtime Entity ID | UnsignedVarLong | |
|Flags | byte | |
|Position | PlayerLocation | |
|On Ground | bool | |
|Teleport | bool | |
-----------------------------------------------------------------------
### Move Player (0x13)
Wiki: [Move Player](https://github.com/NiclasOlofsson/MiNET/wiki//Protocol-MovePlayer)
Expand Down
Loading