public static MetadataDictionary FromStream(BinaryReader stream) { var value = new MetadataDictionary(); while (true) { byte key = stream.ReadByte(); if (key == 127) { break; } byte type = (byte)((key & 0xE0) >> 5); byte index = (byte)(key & 0x1F); var entry = EntryTypes[type](); if (index == 17) { entry = new MetadataLong { id = type }; } entry.FromStream(stream); entry.Index = index; value[index] = entry; } return(value); }
public override MetadataDictionary GetMetadata() { var metadata = base.GetMetadata(); if (Shooter != null) { metadata[17] = new MetadataLong(Shooter.EntityId); } return metadata; }
public static MetadataDictionary FromStream(BinaryReader stream) { var value = new MetadataDictionary(); while (true) { byte key = stream.ReadByte(); if (key == 127) break; byte type = (byte) ((key & 0xE0) >> 5); byte index = (byte) (key & 0x1F); var entry = EntryTypes[type](); if (index == 17) { entry = new MetadataLong {id = type}; } entry.FromStream(stream); entry.Index = index; value[index] = entry; } return value; }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte) (HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(NameTag ?? Name); metadata[3] = new MetadataByte(!HideNameTag); metadata[4] = new MetadataByte(Silent); metadata[7] = new MetadataInt(0); // Potion Color metadata[8] = new MetadataByte(0); // Potion Ambient metadata[15] = new MetadataByte(NoAi); metadata[16] = new MetadataByte(0); // Player flags metadata[17] = new MetadataLong(0); return metadata; }
public override void SpawnEntity() { lock (_spawnSync) { if (IsSpawned) throw new Exception("Invalid state. Tried to spawn projectile more than one time."); Level.AddEntity(this); IsSpawned = true; if (Shooter == null) { var addEntity = McpeAddEntity.CreateObject(); addEntity.entityType = EntityTypeId; addEntity.entityId = EntityId; addEntity.x = KnownPosition.X; addEntity.y = KnownPosition.Y; addEntity.z = KnownPosition.Z; addEntity.yaw = KnownPosition.Yaw; addEntity.pitch = KnownPosition.Pitch; addEntity.metadata = GetMetadata(); addEntity.speedX = (float) Velocity.X; addEntity.speedY = (float) Velocity.Y; addEntity.speedZ = (float) Velocity.Z; Level.RelayBroadcast(addEntity); McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.entityId = EntityId; mcpeSetEntityData.metadata = GetMetadata(); Level.RelayBroadcast(mcpeSetEntityData); } else { { var addEntity = McpeAddEntity.CreateObject(); addEntity.entityType = EntityTypeId; addEntity.entityId = EntityId; addEntity.x = KnownPosition.X; addEntity.y = KnownPosition.Y; addEntity.z = KnownPosition.Z; addEntity.yaw = KnownPosition.Yaw; addEntity.pitch = KnownPosition.Pitch; addEntity.metadata = GetMetadata(); addEntity.speedX = (float)Velocity.X; addEntity.speedY = (float)Velocity.Y; addEntity.speedZ = (float)Velocity.Z; Level.RelayBroadcast(Shooter, addEntity); McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.entityId = EntityId; mcpeSetEntityData.metadata = GetMetadata(); Level.RelayBroadcast(Shooter, mcpeSetEntityData); } { MetadataDictionary metadata = GetMetadata(); metadata[17] = new MetadataLong(0); var addEntity = McpeAddEntity.CreateObject(); addEntity.entityType = EntityTypeId; addEntity.entityId = EntityId; addEntity.x = KnownPosition.X; addEntity.y = KnownPosition.Y; addEntity.z = KnownPosition.Z; addEntity.yaw = KnownPosition.Yaw; addEntity.pitch = KnownPosition.Pitch; addEntity.metadata = metadata; addEntity.speedX = (float) Velocity.X; addEntity.speedY = (float) Velocity.Y; addEntity.speedZ = (float) Velocity.Z; Shooter.SendPackage(addEntity); McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.entityId = EntityId; mcpeSetEntityData.metadata = metadata; Shooter.SendPackage(mcpeSetEntityData); } } } }
public override MetadataDictionary GetMetadata() { MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte) (HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(NameTag ?? Username); metadata[3] = new MetadataByte(1); metadata[4] = new MetadataByte(0); metadata[7] = new MetadataInt(0); metadata[8] = new MetadataByte(0); metadata[15] = new MetadataByte(0); metadata[16] = new MetadataByte(0); metadata[17] = new MetadataLong(0); return metadata; }
public override void SpawnEntity() { Level.AddEntity(this); if (Shooter == null) { var addEntity = McpeAddEntity.CreateObject(); addEntity.entityType = EntityTypeId; addEntity.entityId = EntityId; addEntity.x = KnownPosition.X; addEntity.y = KnownPosition.Y; addEntity.z = KnownPosition.Z; addEntity.yaw = KnownPosition.Yaw; addEntity.pitch = KnownPosition.Pitch; //addEntity.metadata = GetMetadata(); addEntity.speedX = (float) Velocity.X; addEntity.speedY = (float) Velocity.Y; addEntity.speedZ = (float) Velocity.Z; Level.RelayBroadcast(addEntity); IsSpawned = true; McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.entityId = EntityId; mcpeSetEntityData.metadata = GetMetadata(); Level.RelayBroadcast(mcpeSetEntityData); } else { { var addEntity = McpeAddEntity.CreateObject(); addEntity.entityType = EntityTypeId; addEntity.entityId = EntityId; addEntity.x = KnownPosition.X; addEntity.y = KnownPosition.Y; addEntity.z = KnownPosition.Z; addEntity.yaw = KnownPosition.Yaw; addEntity.pitch = KnownPosition.Pitch; //addEntity.metadata = GetMetadata(); addEntity.speedX = (float) Velocity.X; addEntity.speedY = (float) Velocity.Y; addEntity.speedZ = (float) Velocity.Z; Level.RelayBroadcast(Shooter, addEntity); McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.entityId = EntityId; mcpeSetEntityData.metadata = GetMetadata(); Level.RelayBroadcast(Shooter, mcpeSetEntityData); } { MetadataDictionary metadata = GetMetadata(); metadata[17] = new MetadataLong(0); var addEntity = McpeAddEntity.CreateObject(); addEntity.entityType = EntityTypeId; addEntity.entityId = EntityId; addEntity.x = KnownPosition.X; addEntity.y = KnownPosition.Y; addEntity.z = KnownPosition.Z; addEntity.yaw = KnownPosition.Yaw; addEntity.pitch = KnownPosition.Pitch; //addEntity.metadata = metadata; addEntity.speedX = (float) Velocity.X; addEntity.speedY = (float) Velocity.Y; addEntity.speedZ = (float) Velocity.Z; Shooter.SendPackage(addEntity); McpeSetEntityData mcpeSetEntityData = McpeSetEntityData.CreateObject(); mcpeSetEntityData.entityId = EntityId; mcpeSetEntityData.metadata = metadata; Shooter.SendPackage(mcpeSetEntityData); } } }
public override MetadataDictionary GetMetadata() { //[0] byte 0 0, //[1] short 1 300, //[2] string 4 Client12, //[3] byte 0 1, //[4] byte 0 0, //[7] int 2 0, //[8] byte 0 0, //[15] byte 0 0, //[16] byte 0 0, //[17] long 6 0 MetadataDictionary metadata = new MetadataDictionary(); metadata[0] = new MetadataByte((byte) (HealthManager.IsOnFire ? 1 : 0)); metadata[1] = new MetadataShort(HealthManager.Air); metadata[2] = new MetadataString(Username); metadata[3] = new MetadataByte(1); metadata[4] = new MetadataByte(0); metadata[7] = new MetadataInt(0); metadata[8] = new MetadataByte(0); metadata[15] = new MetadataByte(0); metadata[16] = new MetadataByte(0); metadata[17] = new MetadataLong(0); return metadata; }