Example #1
0
        public byte[] GetBytes(bool unloader = false)
        {
            var writer = new MSGBuffer(new byte[0]);

            if (!unloader)
            {
                writer.WriteInt(X);
                writer.WriteInt(Z);
                writer.WriteBool(true);
                writer.WriteUShort(0xffff);                 // bitmap
                writer.WriteVarInt((Blocks.Length * 2) + Skylight.Data.Length + Blocklight.Data.Length + BiomeId.Length);

                for (var i = 0; i < Blocks.Length; i++)
                {
                    //if (i == null) writer.WriteUShort((0 << 4) | 0);
                    writer.WriteUShort((ushort)((Blocks[i] << 4) | Metadata[i]));
                }

                writer.Write(Blocklight.Data);
                writer.Write(Skylight.Data);

                writer.Write(BiomeId);
            }
            else
            {
                writer.WriteInt(X);
                writer.WriteInt(Z);
                writer.WriteBool(true);
                writer.WriteUShort(0);
                writer.WriteVarInt(0);
            }
            return(writer.ExportWriter);
        }
Example #2
0
        public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
        {
            int id = new Random().Next(0, 100);

            buffer.WriteVarInt(PacketID);
            buffer.WriteVarInt(id);
            buffer.FlushData();
        }
Example #3
0
 public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
 {
     if (state.PlayMode)
     {
         buffer.WriteVarInt(PacketID);
     }
     else
     {
         buffer.WriteVarInt(0x00);
     }
     buffer.WriteString(JsonConvert.SerializeObject((ChatMessage)Arguments[0]));
     buffer.FlushData();
 }
        private void HandleStatusRequest(ClientWrapper state, MSGBuffer buffer)
        {
            buffer.WriteVarInt(PacketID);

            Serverping serverlistping = new Serverping()
            {
                Version = new ServerpingVersion()
                {
                    Name     = Globals.ProtocolName,
                    Protocol = Globals.ProtocolVersion
                },
                Players = new ServerpingPlayers()
                {
                    Max    = Globals.MaxPlayers,
                    Online = Globals.PlayersOnline,
                },
                Description = new ServerpingDescription()
                {
                    Motd = Globals.Config.Motd
                },
                Favicon = (Globals.Favicon == null) ? "" : Globals.Favicon
            };

            buffer.WriteString(JsonConvert.SerializeObject(serverlistping));
            buffer.FlushData();
        }
Example #5
0
 public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
 {
     buffer.WriteVarInt(PacketID);
     buffer.WriteString(Arguments[0].ToString());
     buffer.WriteString(Arguments[1].ToString());
     buffer.FlushData();
 }
Example #6
0
 public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
 {
     buffer.WriteVarInt(PacketID);
     buffer.WriteLong(Globals.WorldAge);
     buffer.WriteLong(Globals.TimeOfDay);
     buffer.FlushData();
 }
Example #7
0
        public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
        {
            Vector3 D    = Globals.WorldGen.GetSpawnPoint();
            long    Data = (((long)D.X & 0x3FFFFFF) << 38) | (((long)D.Y & 0xFFF) << 26) | ((long)D.Z & 0x3FFFFFF);

            buffer.WriteVarInt(PacketID);
            buffer.WriteLong(Data);
            buffer.FlushData();
        }
Example #8
0
 public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
 {
     buffer.WriteVarInt(0x08);
     buffer.WriteDouble(Globals.WorldGen.GetSpawnPoint().X);
     buffer.WriteDouble(Globals.WorldGen.GetSpawnPoint().Y);
     buffer.WriteDouble(Globals.WorldGen.GetSpawnPoint().Z);
     buffer.WriteFloat(0f);
     buffer.WriteFloat(0f);
     buffer.WriteByte(111);
     buffer.FlushData();
 }
Example #9
0
 public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
 {
     buffer.WriteVarInt(PacketID);
     buffer.WriteInt(state.Player.UniqueServerID);
     buffer.WriteByte((byte)state.Player.Gamemode);
     buffer.WriteInt(state.Player.Dimension);
     buffer.WriteByte((byte)Globals.Difficulty);
     buffer.WriteByte((byte)Globals.MaxPlayers);
     buffer.WriteString(Globals.LVLType);
     buffer.WriteBool(false);
     Globals.Logger.Log(Utils.LogType.Error, Globals.LVLType);
     buffer.FlushData();
 }
Example #10
0
 public void Write(ClientWrapper state, MSGBuffer buffer, object[] Arguments)
 {
     buffer.WriteVarInt(PacketID);
     buffer.Write((byte[])Arguments[0]);
     buffer.FlushData();
 }