Allow changing 'clouds height' and 'max fog' in /os env. (Thanks goodlyay)

This commit is contained in:
UnknownShadow200 2016-04-02 11:11:06 +11:00
parent 860087d104
commit eac5ea6794
3 changed files with 47 additions and 80 deletions

View File

@ -32,12 +32,44 @@ namespace MCGalaxy {
internal static HandlePlace[] placeHandlers = new Block.HandlePlace[256];
static void SetupCoreHandlers() {
deleteHandlers[Block.rocketstart] = RocketStartDelete;
deleteHandlers[Block.firework] = FireworkDelete;
}
}
static bool RocketStartDelete(Player p, byte block, ushort x, ushort y, ushort z) {
if (p.level.physics < 2 || p.level.physics == 5) { p.RevertBlock(x, y, z); return true; }
int newZ = 0, newX = 0, newY = 0;
p.SendBlockchange(x, y, z, Block.rocketstart);
if ( p.rot[0] < 48 || p.rot[0] > ( 256 - 48 ) )
newZ = -1;
else if ( p.rot[0] > ( 128 - 48 ) && p.rot[0] < ( 128 + 48 ) )
newZ = 1;
if ( p.rot[0] > ( 64 - 48 ) && p.rot[0] < ( 64 + 48 ) )
newX = 1;
else if ( p.rot[0] > ( 192 - 48 ) && p.rot[0] < ( 192 + 48 ) )
newX = -1;
if ( p.rot[1] >= 192 && p.rot[1] <= ( 192 + 32 ) )
newY = 1;
else if ( p.rot[1] <= 64 && p.rot[1] >= 32 )
newY = -1;
if ( 192 <= p.rot[1] && p.rot[1] <= 196 || 60 <= p.rot[1] && p.rot[1] <= 64 ) { newX = 0; newZ = 0; }
byte b1 = p.level.GetTile((ushort)( x + newX * 2 ), (ushort)( y + newY * 2 ), (ushort)( z + newZ * 2 ));
byte b2 = p.level.GetTile((ushort)( x + newX ), (ushort)( y + newY ), (ushort)( z + newZ ));
if ( b1 == Block.air && b2 == Block.air && p.level.CheckClear((ushort)( x + newX * 2 ), (ushort)( y + newY * 2 ), (ushort)( z + newZ * 2 ))
&& p.level.CheckClear((ushort)( x + newX ), (ushort)( y + newY ), (ushort)( z + newZ )) ) {
p.level.Blockchange((ushort)( x + newX * 2 ), (ushort)( y + newY * 2 ), (ushort)( z + newZ * 2 ), Block.rockethead);
p.level.Blockchange((ushort)( x + newX ), (ushort)( y + newY ), (ushort)( z + newZ ), Block.fire);
}
return false;
}
static bool FireworkDelete(Player p, byte block, ushort x, ushort y, ushort z) {
if (p.level.physics == 5) { p.RevertBlock(x, y, z); return true; }
if (p.level.physics == 0) { p.RevertBlock(x, y, z); return true; }
if (p.level.physics == 0 || p.level.physics == 5) { p.RevertBlock(x, y, z); return true; }
Random rand = new Random();
ushort x2 = (ushort)(x + rand.Next(0, 2) - 1);
@ -45,12 +77,12 @@ namespace MCGalaxy {
byte b1 = p.level.GetTile(x2, (ushort)(y + 2), z2);
byte b2 = p.level.GetTile(x2, (ushort)(y + 1), z2);
if (b1 == Block.air && b2 == Block.air && p.level.CheckClear(x2, (ushort)(y + 1), z2)
if (b1 == Block.air && b2 == Block.air && p.level.CheckClear(x2, (ushort)(y + 1), z2)
&& p.level.CheckClear(x2, (ushort)(y + 2), z2)) {
p.level.Blockchange(x2, (ushort)(y + 2), z2, Block.firework);
p.level.Blockchange(x2, (ushort)(y + 1), z2, Block.lavastill, false, "wait 1 dissipate 100");
}
p.RevertBlock(x, y, z); return true;
}
p.RevertBlock(x, y, z); return false;
}
}
}

View File

@ -77,7 +77,7 @@ namespace MCGalaxy.Commands
} else if (cmd == "ZONE") {
HandleZoneCommand(p, arg, arg2);
} else if (cmd == "KICKALL") {
Player[] players = PlayerInfo.Online.Items;
Player[] players = PlayerInfo.Online.Items;
foreach (Player pl in players) {
if (pl.level == p.level && pl.name != p.name)
Command.all.Find("goto").Use(pl, Server.mainLevel.name);
@ -98,45 +98,10 @@ namespace MCGalaxy.Commands
}
void HandleEnvCommand(Player p, string type, string value) {
if (type == "FOG") {
if (value.Length != 6 && value != "") {
Player.SendMessage(p, "Fog color must be a 6 digit color hex code."); return;
}
string col = value == "" ? "-1" : value;
Command.all.Find("env").Use(p, "l fog " + col);
} else if (type == "CLOUD") {
if (value.Length != 6 && value != "") {
Player.SendMessage(p, "Clouds color must be a 6 digit color hex code."); return;
}
string col = value == "" ? "-1" : value;
Command.all.Find("env").Use(p, "l clouds " + col);
} else if (type == "SKY") {
if (value.Length != 6 && value != "") {
Player.SendMessage(p, "Sky color must be a 6 digit color hex code."); return;
}
string col = value == "" ? "-1" : value;
Command.all.Find("env").Use(p, "l sky " + col);
} else if (type == "SHADOW") {
if (value.Length != 6 && value != "") {
Player.SendMessage(p, "Shadow color must be a 6 digit color hex code."); return;
}
string col = value == "" ? "-1" : value;
Command.all.Find("env").Use(p, "l shadow " + col);
} else if (type == "SUN") {
if (value.Length != 6 && value != "") {
Player.SendMessage(p, "Sun color must be a 6 digit color hex code."); return;
}
string col = value == "" ? "-1" : value;
Command.all.Find("env").Use(p, "l sun " + col);
} else if (type == "LEVEL") {
string level = value == "" ? "normal" : value;
Command.all.Find("env").Use(p, "l level " + level);
} else if (type == "HORIZON") {
string block = value == "" ? "normal" : value;
Command.all.Find("env").Use(p, "l horizon " + block);
} else if (type == "BORDER") {
string block = value == "" ? "normal" : value;
Command.all.Find("env").Use(p, "l border " + block);
if (type == "FOG" || type == "CLOUD" || type == "SKY" || type == "SHADOW" || type == "SUN" ||
type == "LEVEL" || type == "CLOUDHEIGHT" || type == "HORIZON" || type == "BORDER" || type == "MAXFOG") {
string col = value == "" ? "normal" : value;
Command.all.Find("env").Use(p, "l " + type.ToLower() + " " + col);
} else if (type == "WEATHER") {
if (value == "SUN" || value == "NORMAL") {
Command.all.Find("env").Use(p, "weather 0");
@ -150,8 +115,10 @@ namespace MCGalaxy.Commands
} else {
Player.SendMessage(p, "/os env [fog/cloud/sky/shadow/sun] [hex color code] -- Changes env colors of your map");
Player.SendMessage(p, "/os env level -- Sets the water height of your map");
Player.SendMessage(p, "/os env cloudheight -- Sets the cloud height of your map");
Player.SendMessage(p, "/os env maxcfog -- Sets the max fog distance in your map");
Player.SendMessage(p, "/os env horizon -- Sets what block the \"ocean\" shows outside your map");
Player.SendMessage(p, "/os env border -- Sets what block replaces the bedrock below sea level in your map");
Player.SendMessage(p, "/os env border -- Sets what block replaces the \"bedrock\" below sea level in your map");
Player.SendMessage(p, "/os env weather [sun/rain/snow/normal] -- Changes the weather of your map.");
Player.SendMessage(p, " Warning: Shrub,Flowers,Mushroom,Rope,Fire cannot be used for horizon/bedrock.");
Player.SendMessage(p, " Note: If no hex or block is given, the default will be used.");
@ -171,7 +138,7 @@ namespace MCGalaxy.Commands
string level = p.name.ToLower();
if (LevelInfo.ExistsOffline(level) || LevelInfo.ExistsOffline(level + "00")) {
for (int i = 2; i < p.group.OverseerMaps + 2; i++) {
if (LevelInfo.ExistsOffline(p.name.ToLower() + i)) continue;
if (LevelInfo.ExistsOffline(p.name.ToLower() + i)) continue;
if(i > p.group.OverseerMaps) {
p.SendMessage("You have reached the limit for your overseer maps."); return;
}

View File

@ -778,38 +778,6 @@ namespace MCGalaxy {
case Block.door_blue_air:
case Block.door_book_air:
break;
case Block.rocketstart:
if ( level.physics < 2 || level.physics == 5 ) {
RevertBlock(x, y, z);
} else {
int newZ = 0, newX = 0, newY = 0;
SendBlockchange(x, y, z, Block.rocketstart);
if ( rot[0] < 48 || rot[0] > ( 256 - 48 ) )
newZ = -1;
else if ( rot[0] > ( 128 - 48 ) && rot[0] < ( 128 + 48 ) )
newZ = 1;
if ( rot[0] > ( 64 - 48 ) && rot[0] < ( 64 + 48 ) )
newX = 1;
else if ( rot[0] > ( 192 - 48 ) && rot[0] < ( 192 + 48 ) )
newX = -1;
if ( rot[1] >= 192 && rot[1] <= ( 192 + 32 ) )
newY = 1;
else if ( rot[1] <= 64 && rot[1] >= 32 )
newY = -1;
if ( 192 <= rot[1] && rot[1] <= 196 || 60 <= rot[1] && rot[1] <= 64 ) { newX = 0; newZ = 0; }
byte b1 = level.GetTile((ushort)( x + newX * 2 ), (ushort)( y + newY * 2 ), (ushort)( z + newZ * 2 ));
byte b2 = level.GetTile((ushort)( x + newX ), (ushort)( y + newY ), (ushort)( z + newZ ));
if ( b1 == Block.air && b2 == Block.air && level.CheckClear((ushort)( x + newX * 2 ), (ushort)( y + newY * 2 ), (ushort)( z + newZ * 2 )) && level.CheckClear((ushort)( x + newX ), (ushort)( y + newY ), (ushort)( z + newZ )) ) {
level.Blockchange((ushort)( x + newX * 2 ), (ushort)( y + newY * 2 ), (ushort)( z + newZ * 2 ), Block.rockethead);
level.Blockchange((ushort)( x + newX ), (ushort)( y + newY ), (ushort)( z + newZ ), Block.fire);
}
}
break;
case Block.c4det:
Level.C4.BlowUp(new ushort[] { x, y, z }, level);