public override void SpawnEntity() { Level.AddEntity(this); Random random = Level.Random; //double f = 0.7; //float xr = (float)(random.NextDouble() * f + (1.0 - f) * 0.5); //float yr = (float)(random.NextDouble() * f + (1.0 - f) * 0.5); //float zr = (float)(random.NextDouble() * f + (1.0 - f) * 0.5); float xr = 0; float yr = 0; float zr = 0; McpeAddItemEntity mcpeAddItemEntity = McpeAddItemEntity.CreateObject(); mcpeAddItemEntity.entityId = EntityId; mcpeAddItemEntity.item = GetMetadataSlot(); mcpeAddItemEntity.x = KnownPosition.X + xr; mcpeAddItemEntity.y = KnownPosition.Y + yr; mcpeAddItemEntity.z = KnownPosition.Z + zr; mcpeAddItemEntity.speedX = (float)Velocity.X; mcpeAddItemEntity.speedY = (float)Velocity.Y; mcpeAddItemEntity.speedZ = (float)Velocity.Z; Level.RelayBroadcast(mcpeAddItemEntity); IsSpawned = true; }
public override void SpawnToPlayer(Player player) { McpeAddItemEntity mcpeAddItemEntity = McpeAddItemEntity.CreateObject(); mcpeAddItemEntity.entityId = EntityId; mcpeAddItemEntity.item = GetMetadataSlot(); mcpeAddItemEntity.x = KnownPosition.X; mcpeAddItemEntity.y = KnownPosition.Y; mcpeAddItemEntity.z = KnownPosition.Z; mcpeAddItemEntity.speedX = (float)Velocity.X; mcpeAddItemEntity.speedY = (float)Velocity.Y; mcpeAddItemEntity.speedZ = (float)Velocity.Z; player.SendPackage(mcpeAddItemEntity); }
//public override void SpawnEntity() //{ // //double f = 0.7; // //float xr = (float)(random.NextDouble() * f + (1.0 - f) * 0.5); // //float yr = (float)(random.NextDouble() * f + (1.0 - f) * 0.5); // //float zr = (float)(random.NextDouble() * f + (1.0 - f) * 0.5); // Level.AddEntity(this); // IsSpawned = true; //} public override void SpawnToPlayers(Player[] players) { McpeAddItemEntity mcpeAddItemEntity = McpeAddItemEntity.CreateObject(); mcpeAddItemEntity.entityId = EntityId; mcpeAddItemEntity.item = GetItemStack(); mcpeAddItemEntity.x = KnownPosition.X; mcpeAddItemEntity.y = KnownPosition.Y; mcpeAddItemEntity.z = KnownPosition.Z; mcpeAddItemEntity.speedX = (float)Velocity.X; mcpeAddItemEntity.speedY = (float)Velocity.Y; mcpeAddItemEntity.speedZ = (float)Velocity.Z; Level.RelayBroadcast(players, mcpeAddItemEntity); BroadcastSetEntityData(); }
public void SendAddEntityToPlayer(Entity entity, Player player) { if (entity is ItemEntity) { ItemEntity itemEntity = (ItemEntity)entity; McpeAddItemEntity mcpeAddItemEntity = McpeAddItemEntity.CreateObject(); mcpeAddItemEntity.entityId = itemEntity.EntityId; mcpeAddItemEntity.item = itemEntity.GetMetadataSlot(); mcpeAddItemEntity.x = itemEntity.KnownPosition.X; mcpeAddItemEntity.y = itemEntity.KnownPosition.Y; mcpeAddItemEntity.z = itemEntity.KnownPosition.Z; player.SendPackage(mcpeAddItemEntity); } else { entity.SpawnToPlayer(player); } }
public override void SpawnToPlayers(Player[] players) { McpeAddItemEntity mcpeAddItemEntity = McpeAddItemEntity.CreateObject(); mcpeAddItemEntity.entityIdSelf = EntityId; mcpeAddItemEntity.runtimeEntityId = EntityId; mcpeAddItemEntity.item = GetItemStack(); mcpeAddItemEntity.x = KnownPosition.X; mcpeAddItemEntity.y = KnownPosition.Y; mcpeAddItemEntity.z = KnownPosition.Z; mcpeAddItemEntity.speedX = Velocity.X; mcpeAddItemEntity.speedY = Velocity.Y; mcpeAddItemEntity.speedZ = Velocity.Z; mcpeAddItemEntity.metadata = GetMetadata(); LastSentPosition = (PlayerLocation)KnownPosition.Clone(); Level.RelayBroadcast(players, mcpeAddItemEntity); BroadcastSetEntityData(); }