Fix placing grass under grass not changing bottom grass to dirt (Thanks Mirzuuuh), fix placing dirt at top layer not changing to grass, fix level env and level properties not saving.

This commit is contained in:
UnknownShadow200 2016-06-26 11:36:23 +10:00
parent 5449f32ca7
commit 59b0d8efc7
4 changed files with 16 additions and 14 deletions

View File

@ -49,7 +49,8 @@ namespace MCGalaxy {
deleteHandlers[Block.firework] = DeleteBehaviour.Firework;
deleteHandlers[Block.c4det] = DeleteBehaviour.C4Det;
placeHandlers[Block.dirt] = PlaceBehaviour.Dirt;
placeHandlers[Block.dirt] = PlaceBehaviour.Grass;
placeHandlers[Block.grass] = PlaceBehaviour.Grass;
placeHandlers[Block.staircasestep] = PlaceBehaviour.Stairs;
placeHandlers[Block.c4] = PlaceBehaviour.C4;
placeHandlers[Block.c4det] = PlaceBehaviour.C4Det;

View File

@ -22,19 +22,19 @@ namespace MCGalaxy.BlockBehaviour {
internal static class PlaceBehaviour {
internal static bool Dirt(Player p, byte block, ushort x, ushort y, ushort z) {
if (!(p.level.physics == 0 || p.level.physics == 5)) {
p.ChangeBlock(x, y, z, Block.dirt, 0); return false;
internal static bool Grass(Player p, byte block, ushort x, ushort y, ushort z) {
Level lvl = p.level;
if (!(lvl.physics == 0 || lvl.physics == 5)) {
p.ChangeBlock(x, y, z, block, 0); return false;
}
byte above = p.level.GetTile(x, (ushort)(y + 1), z), extAbove = 0;
byte above = lvl.GetTile(x, (ushort)(y + 1), z), extAbove = 0;
if (above == Block.custom_block)
extAbove = p.level.GetExtTile(x, (ushort)(y + 1), z);
extAbove = lvl.GetExtTile(x, (ushort)(y + 1), z);
if (Block.LightPass(above, extAbove, p.level.CustomBlockDefs))
p.ChangeBlock(x, y, z, Block.grass, 0);
else
p.ChangeBlock(x, y, z, Block.dirt, 0);
byte type = (above == Block.Zero || Block.LightPass(above, extAbove, lvl.CustomBlockDefs))
? Block.grass : Block.dirt;
p.ChangeBlock(x, y, z, type, 0);
return false;
}

View File

@ -24,7 +24,7 @@ namespace MCGalaxy.Levels.IO {
public static void Save(Level level, string path) {
try {
using (CP437Writer writer = new CP437Writer(path + ".properties"))
using (CP437Writer writer = new CP437Writer(path))
WriteLevelProperties(level, writer);
} catch (Exception ex) {
Server.s.Log("Failed to save level properties!");
@ -32,8 +32,9 @@ namespace MCGalaxy.Levels.IO {
return;
}
path = Path.ChangeExtension(path, ".env");
try {
using (CP437Writer writer = new CP437Writer(path + ".env"))
using (CP437Writer writer = new CP437Writer(path))
WriteEnvProperties(level, writer);
} catch (Exception ex) {
Server.s.Log("Failed to save environment properties");

View File

@ -45,7 +45,7 @@ namespace MCGalaxy {
}
public void ManualChange(ushort x, ushort y, ushort z, byte action, byte type, byte extType = 0) {
ManualChange(x, y, z, action, type, extType, true);
ManualChange(x, y, z, action, type, extType, true);
}
public void ManualChange(ushort x, ushort y, ushort z, byte action,