예제 #1
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId         = stream.ReadInt();
            IsHardcore       = stream.ReadBool();
            Gamemode         = (byte)stream.ReadByte();
            PreviousGamemode = (byte)stream.ReadByte();

            int worldCount = stream.ReadVarInt();

            WorldNames = new string[worldCount];
            for (int i = 0; i < worldCount; i++)
            {
                WorldNames[i] = stream.ReadString();
            }

            DimensionCodec = stream.ReadNbtCompound();

            Dimension = stream.ReadNbtCompound();             //stream.ReadString();
            WorldName = stream.ReadString();

            HashedSeed = stream.ReadLong();
            //Difficulty = (byte) stream.ReadByte();
            stream.ReadByte();
            ViewDistance        = stream.ReadVarInt();
            ReducedDebugInfo    = stream.ReadBool();
            EnableRespawnScreen = stream.ReadBool();
            IsDebug             = stream.ReadBool();
            IsFlat = stream.ReadBool();
        }
예제 #2
0
 public void ReadPacket(MinecraftStream stream)
 {
     ProtocolVersion = stream.ReadUInt8();
     PartyName       = stream.ReadString();
     KeyOrMOTD       = stream.ReadString();
     IsOP            = stream.ReadUInt8() == 0x64;
 }
예제 #3
0
 public virtual void Read(MinecraftStream stream)
 {
     TeamDisplayName   = stream.ReadChatObject();
     Flags             = (byte)stream.ReadByte();
     NameTagVisibility = stream.ReadString();
     CollisionRule     = stream.ReadString();
     TeamColor         = (TeamsPacket.TeamColor)stream.ReadVarInt();
     TeamPrefix        = stream.ReadChatObject();
     TeamSuffix        = stream.ReadChatObject();
 }
예제 #4
0
 public override void Decode(MinecraftStream stream)
 {
     Dimension        = stream.ReadString();
     WorldName        = stream.ReadString();
     HashedSeed       = stream.ReadLong();
     Gamemode         = (Gamemode)stream.ReadByte();
     PreviousGamemode = (Gamemode)stream.ReadByte();
     IsDebug          = stream.ReadBool();
     IsFlat           = stream.ReadBool();
     CopyMetadata     = stream.ReadBool();
 }
예제 #5
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            EntityName    = stream.ReadString();
            Action        = (UpdateScoreAction)stream.ReadByte();
            ObjectiveName = stream.ReadString();

            if (Action == UpdateScoreAction.CreateOrUpdate)
            {
                Value = stream.ReadVarInt();
            }
        }
예제 #6
0
 public override void Decode(MinecraftStream stream)
 {
     Dimension  = stream.ReadInt();
     Difficulty = (byte)stream.ReadByte();
     Gamemode   = (Gamemode)stream.ReadByte();
     LevelType  = stream.ReadString();
 }
예제 #7
0
        public override void Decode(MinecraftStream stream)
        {
            Channel = stream.ReadString();
            var l = stream.ReadVarInt();

            Data = stream.Read(l);
        }
예제 #8
0
 public override void Decode(MinecraftStream stream)
 {
     ProtocolVersion = stream.ReadVarInt();
     ServerAddress   = stream.ReadString();
     ServerPort      = stream.ReadUShort();
     NextState       = (ConnectionState)stream.ReadVarInt();
 }
예제 #9
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            TeamName   = stream.ReadString();
            PacketMode = (Mode)stream.ReadByte();

            switch (PacketMode)
            {
            case Mode.CreateTeam:
                var a = new CreateTeam();
                a.Read(stream);
                Payload = a;
                break;

            case Mode.RemoveTeam:
                break;

            case Mode.UpdateTeam:
                var upd = new UpdateTeam();
                upd.Read(stream);
                Payload = upd;
                break;

            case Mode.AddPlayer:
                var add = new AddPlayers();
                add.Read(stream);
                Payload = add;
                break;

            case Mode.RemovePlayer:
                var remove = new RemovePlayers();
                remove.Read(stream);
                Payload = remove;
                break;
            }
        }
예제 #10
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId = stream.ReadVarInt();
            int count = stream.ReadInt();

            for (int i = 0; i < count; i++)
            {
                string key   = stream.ReadString();
                double value = stream.ReadDouble();

                int        propCount = stream.ReadVarInt();
                Modifier[] modifiers = new Modifier[propCount];

                for (int y = 0; y < modifiers.Length; y++)
                {
                    UUID         uuid   = new UUID(stream.ReadUuid().ToByteArray());
                    double       amount = stream.ReadDouble();
                    ModifierMode op     = (ModifierMode)stream.ReadByte();

                    modifiers[y] = EntityProperty.Factory.CreateModifier(uuid, amount, op);
                }

                EntityProperty prop = EntityProperty.Factory.Create(key, value, modifiers);

                if (!Properties.ContainsKey(prop.Key))
                {
                    Properties.Add(prop.Key, prop);
                }
            }
        }
    public PluginMessageStore Handle()
    {
        using var stream = new MinecraftStream(PluginData);

        var result = Channel switch
        {
            "minecraft:brand" => new PluginMessageStore
            {
                Type  = PluginMessageType.Brand,
                Value = stream.ReadString()
            },
            "minecraft:register" => new PluginMessageStore // Payload should be a list of strings
            {
                Type  = PluginMessageType.Register,
                Value = Encoding.UTF8.GetString(PluginData)
            },
            "minecraft:unregister" => new PluginMessageStore
            {
                Type  = PluginMessageType.Unregister,
                Value = Encoding.UTF8.GetString(PluginData)
            },
            _ => null
        };

        return(result);
    }
예제 #12
0
 public State ReadFrom(MinecraftStream stream, State state)
 {
     ProtocolVersion = stream.ReadVarInt();
     ServerHostname  = stream.ReadString();
     ServerPort      = stream.Read <ushort>();
     NextState       = (State)stream.ReadVarInt();
     return(NextState);
 }
예제 #13
0
 public override void Decode(MinecraftStream stream)
 {
     Message = stream.ReadString();
     if (!ServerBound)
     {
         Position = (byte)stream.ReadByte();
     }
 }
예제 #14
0
 public override void Decode(MinecraftStream stream)
 {
     Locale       = stream.ReadString();
     ViewDistance = (byte)stream.ReadByte();
     ChatMode     = stream.ReadVarInt();
     ChatColors   = stream.ReadBool();
     SkinParts    = (byte)stream.ReadByte();
     MainHand     = stream.ReadVarInt();
 }
예제 #15
0
        public override void Decode(MinecraftStream stream)
        {
            ServerId = stream.ReadString();
            int publicKeyLength = stream.ReadVarInt();

            PublicKey = stream.Read(publicKeyLength);
            int verifyTokenLength = stream.ReadVarInt();

            VerifyToken = stream.Read(verifyTokenLength);
        }
예제 #16
0
        public override void Decode(MinecraftStream stream)
        {
            MessageId = stream.ReadVarInt();
            Channel   = stream.ReadString();

            long length = stream.Length - stream.Position;

            byte[] buffer = new byte[length];
            Data = stream.Read(buffer.Length);
        }
예제 #17
0
 public void ReadPacket(MinecraftStream stream)
 {
     PlayerID = stream.ReadInt8();
     Username = stream.ReadString();
     X        = stream.ReadInt16();
     Y        = stream.ReadInt16();
     Z        = stream.ReadInt16();
     Yaw      = stream.ReadUInt8();
     Pitch    = stream.ReadUInt8();
 }
예제 #18
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId   = stream.ReadInt();
     Gamemode   = (byte)stream.ReadByte();
     Dimension  = stream.ReadInt();
     Difficulty = (byte)stream.ReadByte();
     stream.ReadByte();
     LevelType        = stream.ReadString();
     ReducedDebugInfo = stream.ReadBool();
 }
예제 #19
0
            public void Read(MinecraftStream stream)
            {
                int count = stream.ReadVarInt();

                Entities = new string[count];

                for (int i = 0; i < count; i++)
                {
                    Entities[i] = stream.ReadString();
                }
            }
예제 #20
0
        /// <inheritdoc />
        public override void Decode(MinecraftStream stream)
        {
            ObjectiveName = stream.ReadString();
            Mode          = (ObjectiveMode)stream.ReadByte();

            if (Mode == ObjectiveMode.Create || Mode == ObjectiveMode.UpdateText)
            {
                Value = stream.ReadChatObject();
                Type  = (ObjectiveType)stream.ReadByte();
            }
        }
예제 #21
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId   = stream.ReadInt();
     Gamemode   = (byte)stream.ReadByte();
     Dimension  = stream.ReadInt();
     HashedSeed = stream.ReadLong();
     //Difficulty = (byte) stream.ReadByte();
     stream.ReadByte();
     LevelType           = stream.ReadString();
     ReducedDebugInfo    = stream.ReadBool();
     EnableRespawnScreen = stream.ReadBool();
 }
예제 #22
0
 public override void MessageRecieved(RemoteClient client, byte[] data)
 {
     if (ServerPingReceived != null)
     {
         var stream    = new MinecraftStream(new MemoryStream(data));
         var eventArgs = new ServerPingEventArgs(
             stream.ReadInt32(),
             stream.ReadString(),
             stream.ReadInt32());
         ServerPingReceived(this, eventArgs);
     }
 }
예제 #23
0
        public override Packet Read(byte[] data)
        {
            var ms = new MinecraftStream(data);
            var re = new LoginStart()
            {
                ID = ms.ReadVarInt()
            };
            var l = ms.ReadVarInt();

            re.Name = ms.ReadString(l);
            return(re);
        }
예제 #24
0
        public override void Decode(MinecraftStream stream)
        {
            TransactionId = stream.ReadVarInt();
            Start         = stream.ReadVarInt();
            Length        = stream.ReadVarInt();

            int c = stream.ReadVarInt();

            Matches = new TabCompleteMatch[c];
            for (int i = 0; i < c; i++)
            {
                var entry = new TabCompleteMatch();
                entry.Match      = stream.ReadString();
                entry.HasTooltip = stream.ReadBool();

                if (entry.HasTooltip)
                {
                    ChatObject.TryParse(stream.ReadString(), out entry.Tooltip);
                }

                Matches[i] = entry;
            }
        }
예제 #25
0
        private void ReadAddPlayerEntries(int count, MinecraftStream stream)
        {
            AddPlayerEntries = new AddPlayerEntry[count];
            for (int i = 0; i < count; i++)
            {
                var newEntry = new AddPlayerEntry();
                newEntry.UUID = stream.ReadUuid();
                newEntry.Name = stream.ReadString();
                int propertyLength = stream.ReadVarInt();
                newEntry.Properties = new PlayerListProperty[propertyLength];
                for (int ii = 0; ii < propertyLength; ii++)
                {
                    newEntry.Properties[ii] = new PlayerListProperty()
                    {
                        Name     = stream.ReadString(),
                        Value    = stream.ReadString(),
                        IsSigned = stream.ReadBool()
                    };

                    if (newEntry.Properties[ii].IsSigned)
                    {
                        newEntry.Properties[ii].Signature = stream.ReadString();
                    }
                }

                newEntry.Gamemode       = stream.ReadVarInt();
                newEntry.Ping           = stream.ReadVarInt();
                newEntry.HasDisplayName = stream.ReadBool();
                if (newEntry.HasDisplayName)
                {
                    newEntry.DisplayName = stream.ReadString();
                }

                AddPlayerEntries[i] = newEntry;
            }
        }
예제 #26
0
        private void ReadUpdateDisplayNameEntries(int count, MinecraftStream stream)
        {
            UpdateDisplayNameEntries = new UpdateDisplayNameEntry[count];
            for (int i = 0; i < count; i++)
            {
                var entry = new UpdateDisplayNameEntry();
                entry.UUID           = stream.ReadUuid();
                entry.HasDisplayName = stream.ReadBool();
                if (entry.HasDisplayName)
                {
                    entry.DisplayName = stream.ReadString();
                }

                UpdateDisplayNameEntries[i] = entry;
            }
        }
예제 #27
0
        public override Packet Read(byte[] data)
        {
            var re = new HandShake();

            MinecraftStream ms = new MinecraftStream(data);

            re.ID = ms.ReadVarInt();

            re.ProtocolVersion = ms.ReadVarInt();

            var l = ms.ReadVarInt();

            re.ServerAddress = ms.ReadString(l);

            re.ServerPort = ms.ReadUShort();

            re.NextState = ms.ReadVarInt();

            return(re);
        }
예제 #28
0
        public override void Decode(MinecraftStream stream)
        {
            EntityId = stream.ReadVarInt();
            int count = stream.ReadInt();

            for (int i = 0; i < count; i++)
            {
                Property prop  = new Property();
                string   key   = stream.ReadString();
                double   value = stream.ReadDouble();

                int        propCount = stream.ReadVarInt();
                Modifier[] modifiers = new Modifier[propCount];
                for (int y = 0; y < modifiers.Length; y++)
                {
                    UUID   uuid   = new UUID(stream.ReadUuid().ToByteArray());
                    double amount = stream.ReadDouble();
                    byte   op     = (byte)stream.ReadByte();

                    modifiers[y] = new Modifier()
                    {
                        Amount    = amount,
                        Operation = op,
                        Uuid      = uuid
                    };
                }

                prop.Value     = value;
                prop.Modifiers = modifiers;
                prop.Key       = key;

                if (!Properties.ContainsKey(key))
                {
                    Properties.Add(key, prop);
                }
            }
        }
예제 #29
0
        public override void Decode(MinecraftStream stream)
        {
            Event = (CombatEvent)stream.ReadVarInt();
            switch (Event)
            {
            case CombatEvent.EnterCombat:

                break;

            case CombatEvent.EndCombat:
                Duration = stream.ReadVarInt();
                EntityId = stream.ReadInt();
                break;

            case CombatEvent.EntityDead:
                PlayerId = stream.ReadVarInt();
                EntityId = stream.ReadInt();
                Message  = stream.ReadString();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
예제 #30
0
 public override void Decode(MinecraftStream stream)
 {
     Message = stream.ReadString();
 }
예제 #31
0
 public override void FromStream(MinecraftStream stream)
 {
     Value = stream.ReadString();
 }