public virtual void HandleMcpeChangeDimension(McpeChangeDimension message) { Thread.Sleep(3000); McpePlayerAction action = McpePlayerAction.CreateObject(); action.runtimeEntityId = Client.EntityId; action.actionId = (int)PlayerAction.DimensionChangeAck; Client.SendPacket(action); }
public void SendPlayerAction(PlayerAction action, BlockCoordinates?coordinates, int?blockFace) { McpePlayerAction packet = McpePlayerAction.CreateObject(); packet.actionId = (int)action; if (coordinates.HasValue) { packet.coordinates = new MiNET.Utils.BlockCoordinates(coordinates.Value.X, coordinates.Value.Y, coordinates.Value.Z); } if (blockFace.HasValue) { packet.face = blockFace.Value; } SendPacket(packet); }
public override void HandleMcpeAddEntity(McpeAddEntity message) { if (Client.IsEmulator) { return; } if (!Client.Entities.ContainsKey(message.entityIdSelf)) { var entity = new Entity(message.entityType, null); entity.EntityId = message.runtimeEntityId; entity.KnownPosition = new PlayerLocation(message.x, message.y, message.z, message.yaw, message.yaw, message.pitch); entity.Velocity = new Vector3(message.speedX, message.speedY, message.speedZ); Client.Entities.TryAdd(entity.EntityId, entity); } Log.DebugFormat("McpeAddEntity Entity ID: {0}", message.entityIdSelf); Log.DebugFormat("McpeAddEntity Runtime Entity ID: {0}", message.runtimeEntityId); Log.DebugFormat("Entity Type: {0}", message.entityType); Log.DebugFormat("X: {0}", message.x); Log.DebugFormat("Y: {0}", message.y); Log.DebugFormat("Z: {0}", message.z); Log.DebugFormat("Yaw: {0}", message.yaw); Log.DebugFormat("Pitch: {0}", message.pitch); Log.DebugFormat("Velocity X: {0}", message.speedX); Log.DebugFormat("Velocity Y: {0}", message.speedY); Log.DebugFormat("Velocity Z: {0}", message.speedZ); Log.DebugFormat("Metadata: {0}", Client.MetadataToCode(message.metadata)); Log.DebugFormat("Links count: {0}", message.links?.Count); if (message.metadata.Contains(0)) { long?value = ((MetadataLong)message.metadata[0])?.Value; if (value != null) { long dataValue = (long)value; Log.Debug($"Bit-array datavalue: dec={dataValue} hex=0x{dataValue:x2}, bin={Convert.ToString(dataValue, 2)}b "); } } if (Log.IsDebugEnabled) { foreach (var attribute in message.attributes) { Log.Debug($"Entity attribute {attribute}"); } } Log.DebugFormat("Links count: {0}", message.links); if (Log.IsDebugEnabled && Client._mobWriter != null) { Client._mobWriter.WriteLine("Entity Type: {0}", message.entityType); Client._mobWriter.Indent++; Client._mobWriter.WriteLine("Metadata: {0}", Client.MetadataToCode(message.metadata)); Client._mobWriter.Indent--; Client._mobWriter.WriteLine(); Client._mobWriter.Flush(); } if (message.entityType == "minecraft:horse") { var id = message.runtimeEntityId; Vector3 pos = new Vector3(message.x, message.y, message.z); Task.Run(BotHelpers.DoWaitForSpawn(Client)) .ContinueWith(t => Task.Delay(3000).Wait()) //.ContinueWith(task => //{ // Log.Warn("Sending jump for player"); // McpeInteract action = McpeInteract.CreateObject(); // action.targetRuntimeEntityId = id; // action.actionId = (int) 3; // SendPackage(action); //}) //.ContinueWith(t => Task.Delay(2000).Wait()) //.ContinueWith(task => //{ // for (int i = 0; i < 10; i++) // { // Log.Warn("Mounting horse"); // McpeInventoryTransaction transaction = McpeInventoryTransaction.CreateObject(); // transaction.transaction = new Transaction() // { // TransactionType = McpeInventoryTransaction.TransactionType.ItemUseOnEntity, // TransactionRecords = new List<TransactionRecord>(), // EntityId = id, // ActionType = 0, // Slot = 0, // Item = new ItemAir(), // //Item = new ItemBlock(new Cobblestone()) { Count = 64 }, // Position = BlockCoordinates.Zero, // FromPosition = CurrentLocation, // ClickPosition = pos, // }; // SendPackage(transaction); // Thread.Sleep(4000); // } //}) .ContinueWith(task => { Log.Warn("Sending sneak for player"); McpePlayerAction action = McpePlayerAction.CreateObject(); action.runtimeEntityId = Client.EntityId; action.actionId = (int)PlayerAction.StartSneak; Client.SendPacket(action); }) .ContinueWith(t => Task.Delay(2000).Wait()) .ContinueWith(task => { Log.Warn("Sending transaction for horse"); var transaction = McpeInventoryTransaction.CreateObject(); transaction.transaction = new ItemUseOnEntityTransaction() { TransactionRecords = new List <TransactionRecord>(), EntityId = id, ActionType = 0, Slot = 0, Item = new ItemAir(), FromPosition = Client.CurrentLocation, ClickPosition = pos, }; Client.SendPacket(transaction); }); } }