public void Load(DataReader dr, Func<byte[], ItemStackBase> getItem) { Count = dr.ReadInt(); Datum = dr.ReadInt(); Weight = dr.ReadFloat(); Volume = dr.ReadFloat(); Temperature = dr.ReadFloat(); DrawColor = System.Drawing.Color.FromArgb(dr.ReadInt()); SetName(dr.ReadFullString()); string secondary_name = dr.ReadFullString(); SecondaryName = secondary_name.Length == 0 ? null : secondary_name; DisplayName = dr.ReadFullString(); Description = dr.ReadFullString(); string tex = dr.ReadFullString(); SetModelName(dr.ReadFullString()); SetTextureName(tex); RenderAsComponent = dr.ReadByte() == 1; ComponentRenderOffset.X = dr.ReadFloat(); ComponentRenderOffset.Y = dr.ReadFloat(); ComponentRenderOffset.Z = dr.ReadFloat(); int attribs = dr.ReadInt(); for (int i = 0; i < attribs; i++) { string cattrib = dr.ReadFullString(); byte b = dr.ReadByte(); if (b == 0) { SharedAttributes.Add(cattrib, new IntegerTag(dr.ReadInt64())); } else if (b == 1) { SharedAttributes.Add(cattrib, new NumberTag(dr.ReadDouble())); } else if (b == 2) { SharedAttributes.Add(cattrib, new BooleanTag(dr.ReadByte() == 1)); } else { SharedAttributes.Add(cattrib, new TextTag(dr.ReadFullString())); } } int comps = dr.ReadInt(); for (int i = 0; i < comps; i++) { Components.Add(getItem(dr.ReadFullBytes())); } }
public ItemStack(byte[] data, Server tserver) { TheServer = tserver; DataStream ds = new DataStream(data); DataReader dr = new DataReader(ds); int attribs = dr.ReadInt(); for (int i = 0; i < attribs; i++) { string cattrib = dr.ReadFullString(); byte b = dr.ReadByte(); if (b == 0) { Attributes.Add(cattrib, new IntegerTag(dr.ReadInt64())); } else if (b == 1) { Attributes.Add(cattrib, new NumberTag(dr.ReadDouble())); } else if (b == 2) { Attributes.Add(cattrib, new BooleanTag(dr.ReadByte() == 1)); } else { Attributes.Add(cattrib, new TextTag(dr.ReadFullString())); } } Load(dr, (b) => new ItemStack(b, tserver)); }