Skip to content
Permalink
Browse files

Fix MCSharp importer with door_wool blocks, also it now properly impo…

…rts MCGalaxy maps with custom blocks, fixing #20
  • Loading branch information...
UnknownShadow200 committed May 31, 2017
1 parent 6c998b8 commit f7ed37d2a66f6224f1405cc6e4be9906731584e1
Showing with 62 additions and 168 deletions.
  1. +0 −162 fCraft/MapConversion/MapMCF.cs
  2. +62 −6 fCraft/MapConversion/MapMCSharp.cs
@@ -85,167 +85,5 @@ public override bool Save( Map mapToSave, string fileName )
return true;
}
}

static MapMCF()
{
Mapping[70] = (byte) Block.BrownMushroom; //flagbase

Mapping[71] = (byte) Block.White; //fallsnow
Mapping[72] = (byte) Block.White; //snow

Mapping[73] = (byte) Block.StillLava; //fastdeathlava

Mapping[74] = (byte) Block.TNT; //c4
Mapping[75] = (byte) Block.Red; //c4det

//76-79 unused

Mapping[80] = (byte) Block.Cobblestone; //door_cobblestone
Mapping[81] = (byte) Block.Air; //door_cobblestone_air
//82 unused
Mapping[83] = (byte) Block.Red; //door_red;
Mapping[84] = (byte) Block.Air; //door_red_air

Mapping[85] = (byte) Block.Orange; //door_orange
Mapping[86] = (byte) Block.Yellow; //door_yellow
Mapping[87] = (byte)Block.Lime; //door_lightgreen
//88 unused
Mapping[89] = (byte)Block.Teal; //door_aquagreen
Mapping[90] = (byte)Block.Cyan; //door_cyan
Mapping[91] = (byte)Block.Aqua; //door_lightblue
Mapping[92] = (byte)Block.Indigo; //door_purple
Mapping[93] = (byte)Block.Violet; //door_lightpurple
Mapping[94] = (byte)Block.Magenta; //door_pink
Mapping[95] = (byte)Block.Pink; //door_darkpink
Mapping[96] = (byte)Block.Black; //door_darkgray
Mapping[97] = (byte)Block.Gray; //door_lightgray
Mapping[98] = (byte)Block.White; //door_white
//99 unused

Mapping[100] = (byte)Block.Glass; // op_glass
Mapping[101] = (byte)Block.Obsidian; // opsidian
Mapping[102] = (byte)Block.Brick; // op_brick
Mapping[103] = (byte)Block.Stone; // op_stone
Mapping[104] = (byte)Block.Cobblestone; // op_cobblestone
// 105 = op_air
Mapping[106] = (byte)Block.Water; // op_water

// 107-109 unused
Mapping[110] = (byte)Block.Wood; // wood_float
Mapping[111] = (byte)Block.Log; // door
Mapping[112] = (byte)Block.Lava; // lava_fast
Mapping[113] = (byte)Block.Obsidian; // door2
Mapping[114] = (byte)Block.Glass; // door3
Mapping[115] = (byte)Block.Stone; // door4
Mapping[116] = (byte)Block.Leaves; // door5
Mapping[117] = (byte)Block.Sand; // door6
Mapping[118] = (byte)Block.Wood; // door7
Mapping[119] = (byte)Block.Green; // door8
Mapping[120] = (byte)Block.TNT; // door9
Mapping[121] = (byte)Block.Slab; // door10

Mapping[122] = (byte)Block.Log; // tdoor
Mapping[123] = (byte)Block.Obsidian; // tdoor2
Mapping[124] = (byte)Block.Glass; // tdoor3
Mapping[125] = (byte)Block.Stone; // tdoor4
Mapping[126] = (byte)Block.Leaves; // tdoor5
Mapping[127] = (byte)Block.Sand; // tdoor6
Mapping[128] = (byte)Block.Wood; // tdoor7
Mapping[129] = (byte)Block.Green; // tdoor8

Mapping[130] = (byte)Block.White; // MsgWhite
Mapping[131] = (byte)Block.Black; // MsgBlack
Mapping[132] = (byte)Block.Air; // MsgAir
Mapping[133] = (byte)Block.Water; // MsgWater
Mapping[134] = (byte)Block.Lava; // MsgLava

Mapping[135] = (byte)Block.TNT; // tdoor9
Mapping[136] = (byte)Block.Slab; // tdoor10
Mapping[137] = (byte)Block.Air; // tdoor11
Mapping[138] = (byte)Block.Water; // tdoor12
Mapping[139] = (byte)Block.Lava; // tdoor13

Mapping[140] = (byte)Block.Water; // WaterDown
Mapping[141] = (byte)Block.Lava; // LavaDown
Mapping[143] = (byte)Block.Aqua; // WaterFaucet
Mapping[144] = (byte)Block.Orange; // LavaFaucet

// 143 unused
Mapping[145] = (byte)Block.Water; // finiteWater
Mapping[146] = (byte)Block.Lava; // finiteLava
Mapping[147] = (byte)Block.Cyan; // finiteFaucet

Mapping[148] = (byte)Block.Log; // odoor1
Mapping[149] = (byte)Block.Obsidian; // odoor2
Mapping[150] = (byte)Block.Glass; // odoor3
Mapping[151] = (byte)Block.Stone; // odoor4
Mapping[152] = (byte)Block.Leaves; // odoor5
Mapping[153] = (byte)Block.Sand; // odoor6
Mapping[154] = (byte)Block.Wood; // odoor7
Mapping[155] = (byte)Block.Green; // odoor8
Mapping[156] = (byte)Block.TNT; // odoor9
Mapping[157] = (byte)Block.Slab; // odoor10
Mapping[158] = (byte)Block.Lava; // odoor11
Mapping[159] = (byte)Block.Water; // odoor12

Mapping[160] = (byte)Block.Air; // air_portal
Mapping[161] = (byte)Block.Water; // water_portal
Mapping[162] = (byte)Block.Lava; // lava_portal

// 163 unused
Mapping[164] = (byte)Block.Air; // air_door
Mapping[165] = (byte)Block.Air; // air_switch
Mapping[166] = (byte)Block.Water; // water_door
Mapping[167] = (byte)Block.Lava; // lava_door

// 168-174 = odoor*_air
Mapping[175] = (byte)Block.Cyan; // blue_portal
Mapping[176] = (byte)Block.Orange; // orange_portal
// 177-181 = odoor*_air

Mapping[182] = (byte)Block.TNT; // smalltnt
Mapping[183] = (byte)Block.TNT; // bigtnt
Mapping[184] = (byte)Block.Lava; // tntexplosion
Mapping[185] = (byte)Block.Lava; // fire

// 186 unused
Mapping[187] = (byte)Block.Glass; // rocketstart
Mapping[188] = (byte)Block.Gold; // rockethead
Mapping[189] = (byte)Block.Iron; // firework

Mapping[190] = (byte)Block.Lava; // deathlava
Mapping[191] = (byte)Block.Water; // deathwater
Mapping[192] = (byte)Block.Air; // deathair
Mapping[193] = (byte)Block.Water; // activedeathwater
Mapping[194] = (byte)Block.Lava; // activedeathlava

Mapping[195] = (byte)Block.Lava; // magma
Mapping[196] = (byte)Block.Water; // geyser

// 197-210 = air
Mapping[211] = (byte)Block.Red; // door8_air
Mapping[212] = (byte)Block.Lava; // door9_air
// 213-229 = air

Mapping[230] = (byte)Block.Aqua; // train
Mapping[231] = (byte)Block.TNT; // creeper
Mapping[232] = (byte)Block.MossyCobble; // zombiebody
Mapping[233] = (byte)Block.Lime; // zombiehead

// 234 unused
Mapping[235] = (byte)Block.White; // birdwhite
Mapping[236] = (byte)Block.Black; // birdblack
Mapping[237] = (byte)Block.Lava; // birdlava
Mapping[238] = (byte)Block.Red; // birdred
Mapping[239] = (byte)Block.Water; // birdwater
Mapping[240] = (byte)Block.Blue; // birdblue
Mapping[242] = (byte)Block.Lava; // birdkill

Mapping[245] = (byte)Block.Gold; // fishgold
Mapping[246] = (byte)Block.Sponge; // fishsponge
Mapping[247] = (byte)Block.Gray; // fishshark
Mapping[248] = (byte)Block.Red; // fishsalmon
Mapping[249] = (byte)Block.Blue; // fishbetta
}
}
}
@@ -91,8 +91,8 @@ public class MapMCSharp : IMapImporter, IMapExporter {
L = bs.ReadByte(),
};

stream.ReadByte();
stream.ReadByte();
stream.ReadByte(); // pervisit permission
stream.ReadByte(); // perbuild permission
return map;
}

@@ -110,11 +110,35 @@ public class MapMCSharp : IMapImporter, IMapExporter {

map.ConvertBlockTypes( Mapping );

if( gs.ReadByte() != 0xBD ) return map;
ReadCustomBlocks( gs, map );
return map;
}
}
}

const byte customTile = 163;
static void ReadCustomBlocks( Stream s, Map map) {
byte[] chunk = new byte[16 * 16 * 16];

for( int z = 0; z < map.Height; z += 16 )
for( int y = 0; y < map.Length; y += 16 )
for( int x = 0; x < map.Width; x += 16 )
{
if( s.ReadByte() != 1 ) continue;
s.Read( chunk, 0, chunk.Length );

int baseIndex = map.Index( x, y, z );
for( int i = 0; i < chunk.Length; i++ ) {
int xx = i & 0xF, yy = (i >> 4) & 0xF, zz = (i >> 8) & 0xF;
int index = baseIndex + map.Index( xx, yy, zz );

if (map.Blocks[index] != customTile) continue;
map.Blocks[index] = chunk[i];
}
}
}


public virtual bool Save( Map mapToSave, string fileName ) {
if( mapToSave == null ) throw new ArgumentNullException( "mapToSave" );
@@ -140,7 +164,7 @@ public class MapMCSharp : IMapImporter, IMapExporter {
bs.Write( mapToSave.Spawn.R );
bs.Write( mapToSave.Spawn.L );

// Write the VistPermission and BuildPermission bytes
// Write the VisitPermission and BuildPermission bytes
bs.Write( (byte)0 );
bs.Write( (byte)0 );

@@ -157,11 +181,42 @@ public class MapMCSharp : IMapImporter, IMapExporter {
protected static readonly byte[] Mapping = new byte[256];

static MapMCSharp() {
Mapping[70] = (byte)Block.BrownMushroom;// flagbase
Mapping[71] = (byte)Block.White; // fallsnow
Mapping[72] = (byte)Block.White; // snow
Mapping[73] = (byte)Block.StillLava; // fastdeathlava
Mapping[74] = (byte)Block.TNT; // c4
Mapping[75] = (byte)Block.Red; // c4det

// 76-79 unused
Mapping[80] = (byte) Block.Cobblestone; // door_cobblestone
// 81 = door_cobblestone_air

// 82 unused
Mapping[83] = (byte)Block.Red; // door_red;
// 84 = door_red_air
Mapping[85] = (byte)Block.Orange; // door_orange
Mapping[86] = (byte)Block.Yellow; // door_yellow
Mapping[87] = (byte)Block.Lime; // door_lightgreen

// 88 unused
Mapping[89] = (byte)Block.Teal; // door_aquagreen
Mapping[90] = (byte)Block.Cyan; // door_cyan
Mapping[91] = (byte)Block.Aqua; // door_lightblue
Mapping[92] = (byte)Block.Indigo; // door_purple
Mapping[93] = (byte)Block.Violet; // door_lightpurple
Mapping[94] = (byte)Block.Magenta; // door_pink
Mapping[95] = (byte)Block.Pink; // door_darkpink
Mapping[96] = (byte)Block.Black; // door_darkgray
Mapping[97] = (byte)Block.Gray; // door_lightgray
Mapping[98] = (byte)Block.White; // door_white

// 99 unused
Mapping[100] = (byte)Block.Glass; // op_glass
Mapping[101] = (byte)Block.Obsidian; // opsidian
Mapping[102] = (byte)Block.Brick; // op_brick
Mapping[102] = (byte)Block.Brick; // op_brick
Mapping[103] = (byte)Block.Stone; // op_stone
Mapping[104] = (byte)Block.Cobblestone; // op_cobblestone
Mapping[104] = (byte)Block.Cobblestone; // op_cobblestone
// 105 = op_air
Mapping[106] = (byte)Block.Water; // op_water

@@ -227,7 +282,8 @@ public class MapMCSharp : IMapImporter, IMapExporter {
Mapping[161] = (byte)Block.Water; // water_portal
Mapping[162] = (byte)Block.Lava; // lava_portal

// 163 unused
Mapping[customTile] = customTile; // handled specially

Mapping[164] = (byte)Block.Air; // air_door
Mapping[165] = (byte)Block.Air; // air_switch
Mapping[166] = (byte)Block.Water; // water_door

0 comments on commit f7ed37d

Please sign in to comment.
You can’t perform that action at this time.