Ejemplo n.º 1
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteInt((int)Dimension);
     writer.WriteByte((byte)Difficulty);
     writer.WriteByte((byte)Gamemode);
     writer.WriteStringProto(LevelType.Name);
 }
Ejemplo n.º 2
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteBlockPosProto(Location);
     writer.WriteByte(Action);
     writer.WriteByte(Param);
     writer.WriteVarint(Block.Id);
 }
Ejemplo n.º 3
0
        public override void Write(PrimitiveWriter writer)
        {
            writer.WriteStringProto(TeamName);
            writer.WriteByte((byte)Mode);
            if (Mode == ModeEnum.Create || Mode == ModeEnum.UpdateInfo)
            {
                writer.WriteStringProto(Team.DisplayName);
                writer.WriteStringProto(Team.Prefix);
                writer.WriteStringProto(Team.Suffix);
                byte x = 0;
                if (Team.AllowFriendlyFire)
                {
                    x |= 0x01;
                }
                if (Team.CanSeeInvisTeamMates)
                {
                    x |= 0x02;
                }
                writer.WriteByte(x);
                writer.WriteStringProto(Team.NameTagVisibility.Name);
                writer.WriteStringProto(Team.CollisionRule.Name);
                writer.WriteSByte(Team.Color.Numeric);
            }

            if (Mode == ModeEnum.Create || Mode == ModeEnum.AddPlayers || Mode == ModeEnum.RemovePlayers)
            {
                writer.WriteVarint(Team.Entities.Count);
                foreach (var e in Team.Entities)
                {
                    writer.WriteStringProto(e);
                }
            }
        }
Ejemplo n.º 4
0
        public override void Write(PrimitiveWriter writer)
        {
            writer.WriteUuidProto(Bossbar.Uuid);
            writer.WriteVarint((int)Action);
            switch (Action)
            {
            case ActionEnum.Add:
                writer.WriteChatRootProto(Bossbar.Title);
                writer.WriteFloat(Bossbar.Health);
                writer.WriteVarint((int)Bossbar.Color);
                writer.WriteVarint((int)Bossbar.Division);
                byte x = 0;
                if (Bossbar.ShouldDarkenSky)
                {
                    x |= 0x1;
                }
                if (Bossbar.IsDragonBar)
                {
                    x |= 0x02;
                }
                writer.WriteByte(x);
                break;

            case ActionEnum.Remove:
                break;

            case ActionEnum.UpdateHealth:
                writer.WriteFloat(Bossbar.Health);
                break;

            case ActionEnum.UpdateTitle:
                writer.WriteChatRootProto(Bossbar.Title);
                break;

            case ActionEnum.UpdateStyle:
                writer.WriteVarint((int)Bossbar.Color);
                writer.WriteVarint((int)Bossbar.Division);
                break;

            case ActionEnum.UpdateFlags:
                byte z = 0;
                if (Bossbar.ShouldDarkenSky)
                {
                    z |= 0x1;
                }
                if (Bossbar.IsDragonBar)
                {
                    z |= 0x02;
                }
                writer.WriteByte(z);
                break;

            default:
                throw new InvalidOperationException($"Invalid ActionEnum: {Action}");
            }
        }
Ejemplo n.º 5
0
 public static void WriteEntityMetadataProto(this PrimitiveWriter writer, EntityMetadata entityMetadata)
 {
     foreach (var pair in entityMetadata.Map)
     {
         writer.WriteByte(pair.Key);
         writer.WriteByte(pair.Value.Type);
         pair.Value.Write(writer);
     }
     writer.WriteByte(0xff);
 }
Ejemplo n.º 6
0
 internal override void Write(PrimitiveWriter writer)
 {
     foreach (var pair in Value)
     {
         writer.WriteByte(pair.Value.ID);
         writer.WriteStringNbt(pair.Key);
         pair.Value.Write(writer);
     }
     writer.WriteByte(EndId);
 }
Ejemplo n.º 7
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteByte(WindowId);
     writer.WriteStringProto(WindowType);
     writer.WriteChatRootProto(WindowTitle);
     writer.WriteByte(SlotCount);
     if (WindowType == Horse.WindowType)
     {
         writer.WriteInt(EntityId);
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Writes an Uncompressed NbtBlob.
        /// </summary>
        /// <exception cref="NBTException">Invalid Nbt.</exception>
        public static void WriteNbtBlob(this PrimitiveWriter writer, NbtBlob blob)
        {
            if (blob.IsEmpty)
            {
                writer.WriteByte(Tag.EndId);
                return;
            }

            writer.WriteByte(blob.Root.ID);
            writer.WriteStringNbt(blob.Name);
            blob.Root.Write(writer);
        }
Ejemplo n.º 9
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteInt(ChunkPos.X);
     writer.WriteInt(ChunkPos.Z);
     writer.WriteVarint(Records.Count);
     foreach (var r in Records)
     {
         writer.WriteByte((byte)(r.BlockPosInChunk.X << 4 | r.BlockPosInChunk.Z));
         writer.WriteByte(r.BlockPosInChunk.Y);
         writer.WriteVarint(r.BlockStateId.ToShort());
     }
 }
Ejemplo n.º 10
0
        public override void Write(PrimitiveWriter writer)
        {
            writer.WriteInt(EntityId);
            var gamemode = (byte)Gamemode;

            if (IsHardcore)
            {
                gamemode |= 0x8;
            }
            writer.WriteByte(gamemode);
            writer.WriteInt((int)Dimension);
            writer.WriteByte((byte)Difficulty);
            writer.WriteByte(MaxPlayers);
            writer.WriteStringProto(LevelType.Name);
            writer.WriteBool(ReducedDebugInfo);
        }
Ejemplo n.º 11
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteVarint(EntityId);
     writer.WriteByte(Type);
     writer.WriteDouble(X);
     writer.WriteDouble(Y);
     writer.WriteDouble(Z);
 }
Ejemplo n.º 12
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteFloat((float)Location.X);
     writer.WriteFloat((float)Location.Y);
     writer.WriteFloat((float)Location.Z);
     writer.WriteFloat(Radius);
     writer.WriteInt(Records.Count);
     foreach (var r in Records)
     {
         writer.WriteByte((byte)(r.X - (int)Location.X));
         writer.WriteByte((byte)(r.Y - (int)Location.Y));
         writer.WriteByte((byte)(r.Z - (int)Location.Z));
     }
     writer.WriteFloat((float)PlayerVelocity.X);
     writer.WriteFloat((float)PlayerVelocity.Y);
     writer.WriteFloat((float)PlayerVelocity.Z);
 }
Ejemplo n.º 13
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteVarint(EntityId);
     writer.WriteUuidProto(Uuid);
     writer.WriteStringProto(Painting.Name);
     writer.WriteBlockPosProto(Location);
     writer.WriteByte((byte)Direction);
 }
Ejemplo n.º 14
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteByte(WindowId);
     writer.WriteShort((short)Items.Count);
     foreach (var i in Items)
     {
         writer.WriteItemStackProto(i);
     }
 }
Ejemplo n.º 15
0
        public override void Write(PrimitiveWriter writer)
        {
            writer.WriteVarint(EntityId);
            writer.WriteByte(Effect.Id);
            writer.WriteByte(Amplifier);
            writer.WriteVarint(Duration);
            byte x = 0;

            if (IsAmbient)
            {
                x |= 0x01;
            }
            if (ShowParticles)
            {
                x |= 0x02;
            }
            writer.WriteByte(x);
        }
Ejemplo n.º 16
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteDouble(Position.X);
     writer.WriteDouble(Position.Y);
     writer.WriteDouble(Position.Z);
     writer.WriteFloat(Yaw);
     writer.WriteFloat(Pitch);
     writer.WriteByte((byte)Flags);
     writer.WriteVarint(TeleportId);
 }
Ejemplo n.º 17
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteStringProto(EntityName);
     writer.WriteByte((byte)Action);
     writer.WriteStringProto(ObjectiveName);
     if (Action != ActionEnum.Remove)
     {
         writer.WriteVarint(Value);
     }
 }
Ejemplo n.º 18
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteStringProto(Name);
     writer.WriteByte((byte)Mode);
     if (Mode == ModeEnum.Create || Mode == ModeEnum.UpdateDisplayName)
     {
         writer.WriteStringProto(Objective.DisplayName);
         writer.WriteStringProto(Objective.Type.Name);
     }
 }
Ejemplo n.º 19
0
 public static void WriteItemStackProto(this PrimitiveWriter writer, ItemStack itemStack)
 {
     if (itemStack.IsEmpty)
     {
         writer.WriteShort(-1);
         return;
     }
     writer.WriteShort(itemStack.Item.Id);
     writer.WriteByte(itemStack.Count);
     writer.WriteShort(itemStack.Damage);
     writer.WriteNbtBlob(itemStack.Nbt);
 }
Ejemplo n.º 20
0
 internal override void Write(PrimitiveWriter writer)
 {
     writer.WriteByte(Value.Any() ? Value[0].ID : EndId);
     writer.WriteInt(Value.Count);
     foreach (var tag in Value)
     {
         if (tag.ID != Value[0].ID)
         {
             throw new InvalidOperationException("Tags are not the same in the list.");
         }
         tag.Write(writer);
     }
 }
Ejemplo n.º 21
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteVarint(EntityId);
     writer.WriteUuidProto(Uuid);
     writer.WriteByte(Type);
     writer.WriteDouble(X);
     writer.WriteDouble(Y);
     writer.WriteDouble(Z);
     writer.WriteAngleProto(Pitch);
     writer.WriteAngleProto(Yaw);
     writer.WriteInt(Data);
     writer.WriteShort(VelocityX);
     writer.WriteShort(VelocityY);
     writer.WriteShort(VelocityZ);
 }
Ejemplo n.º 22
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteVarint(EntityId);
     writer.WriteInt(Properties.Count);
     foreach (var p in Properties)
     {
         writer.WriteStringProto(p.Key);
         writer.WriteDouble(p.Value);
         writer.WriteVarint(p.Modifiers.Count);
         foreach (var m in p.Modifiers)
         {
             writer.WriteUuidProto(m.Uuid);
             writer.WriteDouble(m.Amount);
             writer.WriteByte((byte)m.Operation);
         }
     }
 }
Ejemplo n.º 23
0
        public override void Write(PrimitiveWriter writer)
        {
            writer.WriteVarint(MapId);
            writer.WriteByte(Scale);
            writer.WriteBool(ShowIcons);
            writer.WriteVarint(Icons.Length);
            foreach (var i in Icons)
            {
                writer.WriteByte((byte)(((byte)i.Type << 4) | (i.Direction & 0x0f)));
                writer.WriteByte(i.X);
                writer.WriteByte(i.Z);
            }
            writer.WriteByte(Columns);
            if (Columns == 0)
            {
                return;
            }

            writer.WriteByte(Rows);
            writer.WriteByte(X);
            writer.WriteByte(Z);
            writer.WriteVarint(Data.Length);
            writer.Write(Data, 0, Data.Length);
        }
Ejemplo n.º 24
0
        public override void Write(PrimitiveWriter writer)
        {
            byte x = 0;

            if (Invulnerable)
            {
                x |= 0x01;
            }
            if (Flying)
            {
                x |= 0x02;
            }
            if (AllowFlying)
            {
                x |= 0x03;
            }
            if (CreativeMode)
            {
                x |= 0x08;
            }
            writer.WriteByte(x);
            writer.WriteFloat(FlyingSpeed);
            writer.WriteFloat(FieldOfView);
        }
Ejemplo n.º 25
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteByte(Reason);
     writer.WriteFloat(Value);
 }
Ejemplo n.º 26
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteByte((byte)Position);
     writer.WriteStringProto(ScoreName);
 }
Ejemplo n.º 27
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteInt(EntityId);
     writer.WriteByte(Status);
 }
Ejemplo n.º 28
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteChatRootProto(ChatRoot);
     writer.WriteByte((byte)Position);
 }
Ejemplo n.º 29
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteBlockPosProto(Location);
     writer.WriteByte(Action);
     writer.WriteNbtBlob(NbtData);
 }
Ejemplo n.º 30
0
 public override void Write(PrimitiveWriter writer)
 {
     writer.WriteByte(Slot);
 }