mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-23 12:42:22 -04:00
Now /mode supports custom blocks, remove obsolete p.allowTnt
This commit is contained in:
parent
9fee23ebe6
commit
2c1698d7b6
@ -35,7 +35,7 @@ namespace MCGalaxy.Blocks {
|
||||
if (!lvl.GrassGrow || !(lvl.physics == 0 || lvl.physics == 5)) {
|
||||
p.ChangeBlock(x, y, z, block); return;
|
||||
}
|
||||
if (p.modeType == Block.dirt || p.modeType == Block.grass) {
|
||||
if (p.ModeBlock.BlockID == Block.dirt || p.ModeBlock.BlockID == Block.grass) {
|
||||
p.ChangeBlock(x, y, z, block); return;
|
||||
}
|
||||
|
||||
|
@ -39,12 +39,13 @@ namespace MCGalaxy {
|
||||
|
||||
/// <summary> Returns whether the type of this extended block is a fully custom block. </summary>
|
||||
/// <remarks> Note that core/original/vanilla blocks can be replaced with custom blocks. </remarks>
|
||||
public bool IsCustomType {
|
||||
get { return BlockID == Block.custom_block; }
|
||||
}
|
||||
public bool IsCustomType { get { return BlockID == Block.custom_block; } }
|
||||
|
||||
/// <summary> Returns whether the type of this extended block is an invalid block. </summary>
|
||||
public bool IsInvalidType { get { return BlockID == Block.Invalid; } }
|
||||
/// <summary> Returns whether the type of this extended block is the invald block. </summary>
|
||||
public bool IsInvalid { get { return BlockID == Block.Invalid; } }
|
||||
|
||||
/// <summary> Returns whether the type of this extended block is the air block. </summary>
|
||||
public bool IsAir { get { return BlockID == Block.air; } }
|
||||
|
||||
|
||||
/// <summary> Returns the raw (for client side) block ID of this block. </summary>
|
||||
|
@ -62,16 +62,10 @@ namespace MCGalaxy.Commands.Fun {
|
||||
EndType GetEnd(Player p, string mode) {
|
||||
if (mode == "") return EndType.Normal;
|
||||
if (mode.CaselessEq("destroy")) return EndType.Destroy;
|
||||
if (mode.CaselessEq("tp") || mode.CaselessEq("teleport")) return EndType.Teleport;
|
||||
if (mode.CaselessEq("tp") || mode.CaselessEq("teleport")) return EndType.Teleport;
|
||||
if (mode.CaselessEq("explode")) return EndType.Explode;
|
||||
if (mode.CaselessEq("laser")) return EndType.Laser;
|
||||
|
||||
if (mode.CaselessEq("explode")) {
|
||||
if (!p.allowTnt) Player.Message(p, "Tnt usage is currently disallowed, switching to normal gun.");
|
||||
return p.allowTnt ? EndType.Explode : EndType.Destroy;
|
||||
}
|
||||
if (mode.CaselessEq("laser")) {
|
||||
if (!p.allowTnt) Player.Message(p, "Tnt usage is currently disallowed, switching to normal gun.");
|
||||
return p.allowTnt ? EndType.Laser : EndType.Destroy;
|
||||
}
|
||||
Help(p);
|
||||
return EndType.Invalid;
|
||||
}
|
||||
@ -166,9 +160,8 @@ namespace MCGalaxy.Commands.Fun {
|
||||
return true;
|
||||
}
|
||||
} else if (p.level.physics >= 3) {
|
||||
if (type != Block.glass && p.allowTnt) {
|
||||
if (doExplode)
|
||||
p.level.MakeExplosion(pos.X, pos.Y, pos.Z, 1);
|
||||
if (type != Block.glass && doExplode) {
|
||||
p.level.MakeExplosion(pos.X, pos.Y, pos.Z, 1);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
@ -43,7 +43,7 @@ namespace MCGalaxy.Commands.Info {
|
||||
void PlacedBlock(Player p, ushort x, ushort y, ushort z, ExtBlock block) {
|
||||
if (!p.staticCommands) p.ClearBlockchange();
|
||||
block = p.level.GetExtBlock(x, y, z);
|
||||
if (block.IsInvalidType) return;
|
||||
if (block.IsInvalid) return;
|
||||
p.RevertBlock(x, y, z);
|
||||
|
||||
Dictionary<int, string> names = new Dictionary<int, string>();
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
p.cmdTimer = false;
|
||||
p.staticCommands = false;
|
||||
p.deleteMode = false;
|
||||
p.modeType = 0;
|
||||
p.ModeBlock = ExtBlock.Air;
|
||||
p.aiming = false;
|
||||
p.onTrain = false;
|
||||
p.isFlying = false;
|
||||
|
@ -42,7 +42,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
string[] args = message.SplitSpaces(2);
|
||||
string block = args[0].ToLower();
|
||||
data.Block = GetBlock(p, block, ref allMessage);
|
||||
if (data.Block.IsInvalidType) return;
|
||||
if (data.Block.IsInvalid) return;
|
||||
if (!CommandParser.IsBlockAllowed(p, "place a message block of ", data.Block)) return;
|
||||
|
||||
if (allMessage) {
|
||||
|
@ -42,35 +42,26 @@ namespace MCGalaxy.Commands.Building {
|
||||
}
|
||||
|
||||
if (message == "") {
|
||||
if (p.modeType != 0) {
|
||||
Player.Message(p, "&b{0} %Smode: &cOFF", Block.Name(p.modeType).Capitalize());
|
||||
p.modeType = 0;
|
||||
if (p.ModeBlock != ExtBlock.Air) {
|
||||
Player.Message(p, "&b{0} %Smode: &cOFF", p.level.BlockName(p.ModeBlock));
|
||||
p.ModeBlock = ExtBlock.Air;
|
||||
} else {
|
||||
Help(p);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
byte block = Block.Byte(message);
|
||||
if (block == Block.Invalid) { Player.Message(p, "Could not find block given."); return; }
|
||||
if (block == Block.air) { Player.Message(p, "Cannot use Air Mode."); return; }
|
||||
|
||||
if (!p.allowTnt && (block == Block.tnt || block == Block.bigtnt || block == Block.smalltnt
|
||||
|| block == Block.nuketnt || block == Block.tntexplosion)) {
|
||||
Player.Message(p, "Tnt usage is not allowed at the moment"); return;
|
||||
}
|
||||
if (!p.allowTnt && block == Block.fire) {
|
||||
Player.Message(p, "Tnt usage is not allowed at the moment, fire is a lighter for tnt and is also disabled"); return;
|
||||
}
|
||||
ExtBlock block;
|
||||
if (!CommandParser.GetBlock(p, message, out block)) return;
|
||||
if (block == ExtBlock.Air) { Player.Message(p, "Cannot use Air Mode."); return; }
|
||||
if (!CommandParser.IsBlockAllowed(p, "place ", (ExtBlock)block)) return;
|
||||
|
||||
string name = Block.Name(block).Capitalize();
|
||||
if (p.modeType == block) {
|
||||
Player.Message(p, "&b{0} %Smode: &cOFF", name);
|
||||
p.modeType = 0;
|
||||
if (p.ModeBlock == block) {
|
||||
Player.Message(p, "&b{0} %Smode: &cOFF", p.level.BlockName(p.ModeBlock));
|
||||
p.ModeBlock = ExtBlock.Air;
|
||||
} else {
|
||||
p.modeType = block;
|
||||
Player.Message(p, "&b{0} %Smode: &aON", name);
|
||||
p.ModeBlock = block;
|
||||
Player.Message(p, "&b{0} %Smode: &aON", p.level.BlockName(p.ModeBlock));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
|
||||
string type = p.painting ? "&aON" : "&cOFF";
|
||||
Player.Message(p, "Painting mode: " + type + "%S.");
|
||||
p.modeType = 0;
|
||||
p.ModeBlock = ExtBlock.Air;
|
||||
}
|
||||
|
||||
public override void Help(Player p) {
|
||||
|
@ -30,7 +30,7 @@ namespace MCGalaxy.Commands.Building {
|
||||
public override void Use(Player p, string message) {
|
||||
p.staticCommands = !p.staticCommands;
|
||||
p.ClearBlockchange();
|
||||
p.modeType = 0;
|
||||
p.ModeBlock = ExtBlock.Air;
|
||||
|
||||
Player.Message(p, "Static mode: &a" + p.staticCommands);
|
||||
if (message == "" || !p.staticCommands) return;
|
||||
|
@ -33,7 +33,7 @@ namespace MCGalaxy.Drawing.Brushes {
|
||||
GetRaw(parts, filter, args, out blocks, out count);
|
||||
|
||||
// check if we're allowed to place the held block
|
||||
if (blocks[0].IsInvalidType && !CommandParser.IsBlockAllowed(p, "draw with ", blocks[0])) return null;
|
||||
if (blocks[0].IsInvalid && !CommandParser.IsBlockAllowed(p, "draw with ", blocks[0])) return null;
|
||||
|
||||
for (int i = 0, j = 0; i < parts.Length; i++ ) {
|
||||
if (parts[i] == "") continue;
|
||||
|
@ -441,7 +441,7 @@ namespace MCGalaxy {
|
||||
BlockDefinition def = GetBlockDef(block);
|
||||
if (def != null) return def.Name.Replace(" ", "");
|
||||
|
||||
return block.BlockID != Block.custom_block ? Block.Name(block.BlockID) : block.ExtID.ToString();
|
||||
return block.BlockID != Block.custom_block ? Block.Name(block.BlockID).Capitalize() : block.ExtID.ToString();
|
||||
}
|
||||
|
||||
public bool LightPasses(ExtBlock block) {
|
||||
|
@ -215,7 +215,7 @@ namespace MCGalaxy {
|
||||
//Games
|
||||
public DateTime lastDeath = DateTime.UtcNow;
|
||||
|
||||
public byte modeType;
|
||||
public ExtBlock ModeBlock;
|
||||
public ExtBlock RawHeldBlock = (ExtBlock)Block.rock;
|
||||
public ExtBlock[] BlockBindings = new ExtBlock[Block.Count];
|
||||
public string[] CmdBindings = new string[10];
|
||||
|
@ -122,7 +122,7 @@ namespace MCGalaxy {
|
||||
}
|
||||
}
|
||||
|
||||
if (modeType != 0) block = (ExtBlock)modeType;
|
||||
if (!ModeBlock.IsAir) block = ModeBlock;
|
||||
if (doDelete) {
|
||||
bool deleted = DeleteBlock(oldB, x, y, z, block);
|
||||
} else {
|
||||
|
@ -95,7 +95,7 @@ namespace MCGalaxy {
|
||||
|
||||
|
||||
public ExtBlock GetHeldBlock() {
|
||||
if (modeType != 0) return (ExtBlock)modeType;
|
||||
if (!ModeBlock.IsAir) return ModeBlock;
|
||||
return BlockBindings[RawHeldBlock.RawID];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user