public Blueprint(byte[] binaryBlueprint) { using (ByteReader raw = ByteReader.Get(binaryBlueprint)) { playerMod = raw.ReadVariableVector3Int(); int typesC = raw.ReadVariableInt(); xSize = raw.ReadVariableInt(); ySize = raw.ReadVariableInt(); zSize = raw.ReadVariableInt(); //From one world to another Dictionary <ushort, ushort> typesTransformation = new Dictionary <ushort, ushort>(); using (ByteReader compressed = raw.ReadCompressed()) { for (int i = 0; i < typesC; i++) { ushort type_index = compressed.ReadVariableUShort(); string type_name = compressed.ReadString(); ushort new_type_index; if (!ItemTypes.IndexLookup.TryGetIndex(type_name, out new_type_index)) { new_type_index = BlockTypes.BuiltinBlocks.Indices.air; } typesTransformation.Add(type_index, new_type_index); types.Add(new_type_index, type_name); } blocks = new ushort[xSize, ySize, zSize]; for (int x = 0; x < xSize; x++) { for (int y = 0; y < ySize; y++) { for (int z = 0; z < zSize; z++) { blocks[x, y, z] = typesTransformation.GetValueOrDefault(compressed.ReadVariableUShort(), BlockTypes.BuiltinBlocks.Indices.air); } } } } } }
private static IEnumerable <IOData> GetIOData(ByteReader input, int eventBytes, bool extended) { List <IOData> data = new List <IOData>(); byte ioDataCount = input.GetOne(); for (int i = 0; i < ioDataCount; i++) { data.Add(new IOData { Id = extended ? input.GetLe <short>() : input.GetOne(), Value = input.Get(eventBytes) }); } return(data); }