H:/PortableApps/GitPortable/App/Git/c4 now works as a mode instead of a separate command

This commit is contained in:
UnknownShadow200 2017-02-06 22:59:50 +11:00
parent 9cec31fe67
commit 9162ca4be8
5 changed files with 22 additions and 73 deletions

View File

@ -49,7 +49,7 @@ namespace MCGalaxy.Blocks {
internal static void Stairs(Player p, byte block, ushort x, ushort y, ushort z) {
if (!(p.level.physics == 0 || p.level.physics == 5)
|| p.level.GetTile(x, (ushort)(y - 1), z) != Block.staircasestep) {
p.ChangeBlock(x, y, z, Block.staircasestep, 0); return;
p.ChangeBlock(x, y, z, Block.staircasestep, 0); return;
}
p.SendBlockchange(x, y, z, Block.air); // send the air block back only to the user
@ -66,11 +66,27 @@ namespace MCGalaxy.Blocks {
p.ChangeBlock(x, (ushort)(y - 1), z, Block.stone, 0);
}
internal static void C4(Player p, byte block, ushort x, ushort y, ushort z) {
if (p.level.physics == 0 || p.level.physics == 5) {
p.RevertBlock(x, y, z); return;
}
// Use red wool to detonate c4
byte held = p.RawHeldBlock;
if (held < Block.CpeCount) held = p.bindings[held];
if (held == Block.red) {
Player.Message(p, "Placed detonator block, delete it to detonate.");
C4Det(p, Block.c4det, x, y, z); return;
}
if (p.c4circuitNumber == -1) {
sbyte num = C4Physics.NextCircuit(p.level);
p.level.C4list.Add(new C4Data(num));
p.c4circuitNumber = num;
Player.Message(p, "Place more blocks for more c4, then place a &c{0} %Sblock for the detonator.", Block.Name(Block.red));
}
C4Data c4 = C4Physics.Find(p.level, p.c4circuitNumber);
if (c4 != null) c4.list.Add(p.level.PosToInt(x, y, z));
p.ChangeBlock(x, y, z, Block.c4, 0);

View File

@ -1,61 +0,0 @@
/*
Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy)
Dual-licensed under the Educational Community License, Version 2.0 and
the GNU General Public License, Version 3 (the "Licenses"); you may
not use this file except in compliance with the Licenses. You may
obtain a copy of the Licenses at
http://www.opensource.org/licenses/ecl2.php
http://www.gnu.org/licenses/gpl-3.0.html
Unless required by applicable law or agreed to in writing,
software distributed under the Licenses are distributed on an "AS IS"
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses.
*/
using MCGalaxy.Blocks.Physics;
namespace MCGalaxy.Commands {
public sealed class CmdC4 : Command {
public override string name { get { return "c4"; } }
public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } }
public override bool museumUsable { get { return true; } }
public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } }
public CmdC4() { }
public override void Use(Player p, string message) {
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
if (p.level.physics >= 1 && p.level.physics < 5) {
sbyte numb = C4Physics.NextCircuit(p.level);
C4Data c4 = new C4Data(numb);
p.level.C4list.Add(c4);
p.c4circuitNumber = numb;
Player.Message(p, "Place any block for c4 and place a &cred %Sblock for the detonator!");
p.Blockchange += PlacedNext;
} else {
Player.Message(p, "To use c4, the physics level must be 1, 2, 3 or 4");
}
}
void PlacedNext(Player p, ushort x, ushort y, ushort z, byte type, byte extType) {
p.ClearBlockchange();
if (type == Block.red) {
p.ManualChange(x, y, z, 1, Block.c4det);
Player.Message(p, "Placed detonator block!");
return;
} else if (type != Block.air) {
p.ManualChange(x, y, z, 1, Block.c4);
}
p.Blockchange += PlacedNext;
}
public override void Help(Player p) {
Player.Message(p, "%T/c4");
Player.Message(p, "%HPlace c4!");
}
}
}

View File

@ -335,7 +335,6 @@
<Compile Include="Commands\Moderation\ModActionCmd.cs" />
<Compile Include="Commands\other\CmdAscend.cs" />
<Compile Include="Commands\other\CmdBack.cs" />
<Compile Include="Commands\other\CmdC4.cs" />
<Compile Include="Commands\other\CmdChain.cs" />
<Compile Include="Commands\other\cmdCTFADSFD.cs" />
<Compile Include="Commands\other\CmdDescend.cs" />

View File

@ -118,6 +118,7 @@ namespace MCGalaxy {
}
}
if (modeType != 0) block = modeType;
if (doDelete) {
DeleteBlock(oldB, x, y, z, block, extBlock);
} else {
@ -150,12 +151,6 @@ namespace MCGalaxy {
}
void PlaceBlock(byte old, ushort x, ushort y, ushort z, byte block, byte extBlock) {
if (modeType != 0) {
if (old == modeType) SendBlockchange(x, y, z, old);
else ChangeBlock(x, y, z, modeType, 0);
return;
}
HandlePlace handler = BlockBehaviour.placeHandlers[block];
if (handler != null) {
handler(this, old, x, y, z);