Example #1
0
        public static ItemStack FromStream(MinecraftStream stream)
        {
            var slot = ItemStack.EmptyStack;

            slot.Id = stream.ReadInt16();
            if (slot.Empty)
            {
                return(slot);
            }
            slot.Count    = stream.ReadInt8();
            slot.Metadata = stream.ReadInt16();
            var length = stream.ReadInt16();

            if (length == -1)
            {
                return(slot);
            }
            slot.Nbt = new NbtCompound();
            var buffer = stream.ReadUInt8Array(length);
            var nbt    = new NbtFile();

            nbt.LoadFromBuffer(buffer, 0, length, NbtCompression.GZip, null);
            slot.Nbt = nbt.RootTag;
            return(slot);
        }
Example #2
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     EntityId = stream.ReadVarInt();
     Type = stream.ReadUInt8();
     X = stream.ReadInt32();
     Y = stream.ReadInt32();
     Z = stream.ReadInt32();
     Yaw = stream.ReadUInt8();
     Pitch = stream.ReadUInt8();
     Data = stream.ReadInt32();
     if (Data != 0)
     {
         SpeedX = stream.ReadInt16();
         SpeedY = stream.ReadInt16();
         SpeedZ = stream.ReadInt16();
     }
     return mode;
 }
Example #3
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     if (direction == PacketDirection.Clientbound)
         Slot = stream.ReadInt8();
     else
         Slot = stream.ReadInt16();
     return mode;
 }
Example #4
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     Slot = stream.ReadInt16();
     Item = ItemStack.FromStream(stream);
     return mode;
 }
Example #5
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     TeamName = stream.ReadString();
     PacketMode = (TeamMode)stream.ReadUInt8();
     if (PacketMode == TeamMode.CreateTeam || PacketMode == TeamMode.UpdateTeam)
     {
         DisplayName = stream.ReadString();
         TeamPrefix = stream.ReadString();
         TeamSuffix = stream.ReadString();
         EnableFriendlyFire = stream.ReadBoolean();
     }
     if (PacketMode == TeamMode.CreateTeam || PacketMode == TeamMode.AddPlayers ||
         PacketMode == TeamMode.RemovePlayers)
     {
         var playerCount = stream.ReadInt16();
         Players = new string[playerCount];
         for (int i = 0; i < playerCount; i++)
             Players[i] = stream.ReadString();
     }
     return mode;
 }
Example #6
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     var ssLength = stream.ReadInt16();
     SharedSecret = stream.ReadUInt8Array(ssLength);
     var vtLength = stream.ReadInt16();
     VerificationToken = stream.ReadUInt8Array(vtLength);
     return mode;
 }
Example #7
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     X = stream.ReadInt32();
     Y = stream.ReadInt16();
     Z = stream.ReadInt32();
     Text1 = stream.ReadString();
     Text2 = stream.ReadString();
     Text3 = stream.ReadString();
     Text4 = stream.ReadString();
     return mode;
 }
Example #8
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     WindowId = stream.ReadUInt8();
     PropertyId = stream.ReadInt16();
     Value = stream.ReadInt16();
     return mode;
 }
Example #9
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     ChunkX = stream.ReadInt32();
     ChunkZ = stream.ReadInt32();
     RecordCount = stream.ReadInt16();
     stream.ReadInt32();
     Data = stream.ReadInt32Array(RecordCount);
     return mode;
 }
Example #10
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     EntityId = stream.ReadInt32();
     var count = stream.ReadInt32();
     if (count < 0)
         throw new InvalidOperationException("Cannot specify less than zero properties.");
     Properties = new EntityProperty[count];
     for (int i = 0; i < count; i++)
     {
         var property = new EntityProperty();
         property.Key = stream.ReadString();
         property.Value = stream.ReadDouble();
         var listLength = stream.ReadInt16();
         property.UnknownList = new EntityPropertyListItem[listLength];
         for (int j = 0; j < listLength; j++)
         {
             var item = new EntityPropertyListItem();
             item.UnknownMSB = stream.ReadInt64();
             item.UnknownLSB = stream.ReadInt64();
             item.UnknownDouble = stream.ReadDouble();
             item.UnknownByte = stream.ReadUInt8();
             property.UnknownList[j] = item;
         }
         Properties[i] = property;
     }
     return mode;
 }
Example #11
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     ExperienceBar = stream.ReadSingle();
     Level = stream.ReadInt16();
     TotalExperience = stream.ReadInt16();
     return mode;
 }
Example #12
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     EntityId = stream.ReadInt32();
     EffectId = stream.ReadUInt8();
     Amplifier = stream.ReadUInt8();
     Duration = stream.ReadInt16();
     return mode;
 }
Example #13
0
 public override void FromStream(MinecraftStream stream)
 {
     Value = stream.ReadInt16();
 }
Example #14
0
 public override void FromStream(MinecraftStream stream)
 {
     Value = stream.ReadInt16();
 }
Example #15
0
 public void ReadPacket(MinecraftStream stream)
 {
     EntityId = stream.ReadInt32();
     Type = stream.ReadUInt8();
     X = stream.ReadInt32();
     Y = stream.ReadInt32();
     Z = stream.ReadInt32();
     Yaw = stream.ReadUInt8();
     Pitch = stream.ReadUInt8();
     HeadYaw = stream.ReadUInt8();
     VelocityX = stream.ReadInt16();
     VelocityY = stream.ReadInt16();
     VelocityZ = stream.ReadInt16();
     Metadata = MetadataDictionary.FromStream(stream);
 }
Example #16
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     Health = stream.ReadSingle();
     Food = stream.ReadInt16();
     FoodSaturation = stream.ReadSingle();
     return mode;
 }
Example #17
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     WindowId = stream.ReadUInt8();
     short count = stream.ReadInt16();
     Items = new ItemStack[count];
     for (int i = 0; i < count; i++)
         Items[i] = ItemStack.FromStream(stream);
     return mode;
 }
Example #18
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     EntityId = stream.ReadVarInt();
     X = stream.ReadInt32();
     Y = stream.ReadInt32();
     Z = stream.ReadInt32();
     Count = stream.ReadInt16();
     return mode;
 }
Example #19
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     WindowId = stream.ReadUInt8();
     ActionNumber = stream.ReadInt16();
     Accepted = stream.ReadBoolean();
     return mode;
 }
Example #20
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction) {
     EntityId = stream.ReadVarInt();
     VelocityX = stream.ReadInt16();
     VelocityY = stream.ReadInt16();
     VelocityZ = stream.ReadInt16();
     return mode;
 }
Example #21
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     X = stream.ReadInt32();
     Y = stream.ReadInt16();
     Z = stream.ReadInt32();
     Action = stream.ReadUInt8();
     var length = stream.ReadInt16();
     var data = stream.ReadUInt8Array(length);
     Nbt = new NbtFile();
     Nbt.LoadFromBuffer(data, 0, length, NbtCompression.GZip, null);
     return mode;
 }
Example #22
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     X = stream.ReadInt32();
     Y = stream.ReadInt16();
     Z = stream.ReadInt32();
     Data1 = stream.ReadUInt8();
     Data2 = stream.ReadUInt8();
     BlockId = stream.ReadVarInt();
     return mode;
 }
Example #23
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     PlayerName = stream.ReadString();
     Online = stream.ReadBoolean();
     Ping = stream.ReadInt16();
     return mode;
 }
Example #24
0
        public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
        {
            ChunkCount = stream.ReadInt16();
            var length = stream.ReadInt32();
            LightIncluded = stream.ReadBoolean();
            ChunkData = stream.ReadUInt8Array(length);

            ChunkMetadata = new Metadata[ChunkCount];
            for (int i = 0; i < ChunkCount; i++)
            {
                var metadata = new Metadata();
                metadata.ChunkX = stream.ReadInt32();
                metadata.ChunkZ = stream.ReadInt32();
                metadata.PrimaryBitMap = stream.ReadUInt16();
                metadata.AddBitMap = stream.ReadUInt16();
                ChunkMetadata[i] = metadata;
            }
            return mode;
        }
Example #25
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     Channel = stream.ReadString();
     var length = stream.ReadInt16();
     Data = stream.ReadUInt8Array(length);
     return mode;
 }
Example #26
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     ServerId = stream.ReadString();
     var pkLength = stream.ReadInt16();
     PublicKey = stream.ReadUInt8Array(pkLength);
     var vtLength = stream.ReadInt16();
     VerificationToken = stream.ReadUInt8Array(vtLength);
     return mode;
 }
Example #27
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction) {
     EntityId = stream.ReadVarInt();
     Slot = (EntityEquipmentSlot)stream.ReadInt16();
     Item = ItemStack.FromStream(stream);
     return mode;
 }
Example #28
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     WindowId = stream.ReadInt8();
     SlotIndex = stream.ReadInt16();
     MouseButton = stream.ReadUInt8();
     TransactionId = stream.ReadInt16();
     Mode = stream.ReadUInt8();
     ClickedItem = ItemStack.FromStream(stream);
     if (Mode == 0)
     {
         if (MouseButton == 0)
         {
             if (SlotIndex == -999)
                 Action = ClickAction.DropAll;
             else
                 Action = ClickAction.LeftClick;
         }
         else if (MouseButton == 1)
         {
             if (SlotIndex == -999)
                 Action = ClickAction.Drop;
             else
                 Action = ClickAction.RightClick;
         }
         else
             Action = ClickAction.Invalid;
     }
     else if (Mode == 1)
     {
         if (MouseButton == 0)
             Action = ClickAction.ShiftLeftClick;
         else if (MouseButton == 1)
             Action = ClickAction.ShiftRightClick;
         else
             Action = ClickAction.Invalid;
     }
     else if (Mode == 2)
     {
         if (MouseButton == 0)
             Action = ClickAction.NumKey1;
         else if (MouseButton == 1)
             Action = ClickAction.NumKey2;
         else if (MouseButton == 2)
             Action = ClickAction.NumKey3;
         else if (MouseButton == 3)
             Action = ClickAction.NumKey4;
         else if (MouseButton == 4)
             Action = ClickAction.NumKey5;
         else if (MouseButton == 5)
             Action = ClickAction.NumKey6;
         else if (MouseButton == 6)
             Action = ClickAction.NumKey7;
         else if (MouseButton == 7)
             Action = ClickAction.NumKey8;
         else if (MouseButton == 8)
             Action = ClickAction.NumKey9;
         else
             Action = ClickAction.Invalid;
     }
     else if (Mode == 3)
     {
         if (MouseButton == 2)
             Action = ClickAction.MiddleClick;
         else
             Action = ClickAction.Invalid;
     }
     else if (Mode == 4)
     {
         if (SlotIndex == -999)
         {
             if (Mode == 0)
                 Action = ClickAction.LeftClickEdgeWithEmptyHand;
             else if (Mode == 1)
                 Action = ClickAction.RightClickEdgeWithEmptyHand;
             else
                 Action = ClickAction.Invalid;
         }
         else
         {
             if (Mode == 0)
                 Action = ClickAction.Drop;
             else if (Mode == 1)
                 Action = ClickAction.DropAll;
             else
                 Action = ClickAction.Invalid;
         }
     }
     else if (Mode == 5)
     {
         if (MouseButton == 0)
             Action = ClickAction.StartLeftClickPaint;
         else if (MouseButton == 1)
             Action = ClickAction.LeftMousePaintProgress;
         else if (MouseButton == 2)
             Action = ClickAction.EndLeftMousePaint;
         else if (MouseButton == 4)
             Action = ClickAction.StartRightClickPaint;
         else if (MouseButton == 5)
             Action = ClickAction.RightMousePaintProgress;
         else if (MouseButton == 6)
             Action = ClickAction.EndRightMousePaint;
         else
             Action = ClickAction.Invalid;
     }
     else if (Mode == 6)
         Action = ClickAction.DoubleClick;
     else
         Action = ClickAction.Invalid;
     return mode;
 }
Example #29
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     EntityId = stream.ReadVarInt();
     PlayerUuid = new Guid(stream.ReadUInt8Array(16)); 
     PlayerName = stream.ReadString();
     X = stream.ReadInt32();
     Y = stream.ReadInt32();
     Z = stream.ReadInt32();
     Yaw = stream.ReadUInt8();
     Pitch = stream.ReadUInt8();
     HeldItem = stream.ReadInt16();
     Metadata = MetadataDictionary.FromStream(stream);
     return mode;
 }
Example #30
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     WindowId = stream.ReadUInt8();
     SlotIndex = stream.ReadInt16();
     Item = ItemStack.FromStream(stream);
     return mode;
 }
Example #31
0
 public NetworkMode ReadPacket(MinecraftStream stream, NetworkMode mode, PacketDirection direction)
 {
     EntityId = stream.ReadVarInt();
     Type = stream.ReadUInt8();
     X = stream.ReadInt32();
     Y = stream.ReadInt32();
     Z = stream.ReadInt32();
     Yaw = stream.ReadUInt8();
     Pitch = stream.ReadUInt8();
     HeadYaw = stream.ReadUInt8();
     VelocityX = stream.ReadInt16();
     VelocityY = stream.ReadInt16();
     VelocityZ = stream.ReadInt16();
     Metadata = MetadataDictionary.FromStream(stream);
     return mode;
 }
Example #32
0
 public void ReadPacket(MinecraftStream stream)
 {
     EntityId = stream.ReadInt32();
     Type = stream.ReadUInt8();
     X = stream.ReadInt32();
     Y = stream.ReadInt32();
     Z = stream.ReadInt32();
     Yaw = stream.ReadUInt8();
     Pitch = stream.ReadUInt8();
     Data = stream.ReadInt32();
     if (Data != 0)
     {
         SpeedX = stream.ReadInt16();
         SpeedY = stream.ReadInt16();
         SpeedZ = stream.ReadInt16();
     }
 }