mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-27 23:43:45 -04:00
Core: Fix mark/click, it should activate mbs/portals/doors at those coords if no selection is in progress. (Thanks xnotx123)
This commit is contained in:
parent
06707b1ee3
commit
1963feafb0
@ -115,6 +115,7 @@ namespace MCGalaxy.Commands
|
|||||||
Player.Message(p, "No Complex Blocks look like \"{0}\"", block);
|
Player.Message(p, "No Complex Blocks look like \"{0}\"", block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void OutputBlockProps(Player p, byte b) {
|
static void OutputBlockProps(Player p, byte b) {
|
||||||
BlockProps props = Block.Props[b];
|
BlockProps props = Block.Props[b];
|
||||||
|
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
or implied. See the Licenses for the specific language governing
|
or implied. See the Licenses for the specific language governing
|
||||||
permissions and limitations under the Licenses.
|
permissions and limitations under the Licenses.
|
||||||
*/
|
*/
|
||||||
|
using MCGalaxy.Blocks;
|
||||||
|
|
||||||
namespace MCGalaxy.Commands.Building {
|
namespace MCGalaxy.Commands.Building {
|
||||||
public sealed class CmdMark : Command {
|
public sealed class CmdMark : Command {
|
||||||
public override string name { get { return "mark"; } }
|
public override string name { get { return "mark"; } }
|
||||||
@ -29,22 +31,38 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
|
|
||||||
public override void Use(Player p, string message) {
|
public override void Use(Player p, string message) {
|
||||||
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
|
if (Player.IsSuper(p)) { MessageInGameOnly(p); return; }
|
||||||
|
|
||||||
|
if (message.CaselessEq("all")) {
|
||||||
if (!p.HasBlockchange) {
|
if (!p.HasBlockchange) {
|
||||||
Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return;
|
Player.Message(p, "Cannot mark, no selection or cuboid in progress."); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.CaselessEq("all")) {
|
|
||||||
Level lvl = p.level;
|
Level lvl = p.level;
|
||||||
PlaceMark(p, 0, 0, 0);
|
PlaceMark(p, 0, 0, 0);
|
||||||
PlaceMark(p, lvl.Width - 1, lvl.Height - 1, lvl.Length - 1);
|
PlaceMark(p, lvl.Width - 1, lvl.Height - 1, lvl.Length - 1);
|
||||||
} else {
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// convert player pos to block coords
|
// convert player pos to block coords
|
||||||
Vec3U16 P = Vec3U16.ClampPos(p.pos[0], (ushort)(p.pos[1] - 32), p.pos[2], p.level);
|
Vec3U16 P = Vec3U16.ClampPos(p.pos[0], (ushort)(p.pos[1] - 32), p.pos[2], p.level);
|
||||||
P.X /= 32; P.Y /= 32; P.Z /= 32;
|
P.X /= 32; P.Y /= 32; P.Z /= 32;
|
||||||
if (message != "" && !ParseCoords(message, p, ref P)) return;
|
if (message != "" && !ParseCoords(message, p, ref P)) return;
|
||||||
|
|
||||||
P = Vec3U16.Clamp(P.X, P.Y, P.Z, p.level);
|
P = Vec3U16.Clamp(P.X, P.Y, P.Z, p.level);
|
||||||
|
|
||||||
|
if (!p.HasBlockchange) {
|
||||||
PlaceMark(p, P.X, P.Y, P.Z);
|
PlaceMark(p, P.X, P.Y, P.Z);
|
||||||
|
} else {
|
||||||
|
// We only want to activate blocks in the world
|
||||||
|
byte old = p.level.GetTile(P.X, P.Y, P.Z);
|
||||||
|
if (!p.CheckManualChange(old, Block.air, false)) return;
|
||||||
|
|
||||||
|
HandleDelete handler = BlockBehaviour.deleteHandlers[old];
|
||||||
|
if (handler != null) {
|
||||||
|
handler(p, old, P.X, P.Y, P.Z);
|
||||||
|
} else {
|
||||||
|
Player.Message(p, "Cannot mark, no selection or cuboid in progress, " +
|
||||||
|
"nor could the existing block at the coordinates be activated."); return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,6 +97,7 @@ namespace MCGalaxy.Commands.Building {
|
|||||||
Player.Message(p, "%T/mark [x y z] %H- Places a marker for selections or cuboids");
|
Player.Message(p, "%T/mark [x y z] %H- Places a marker for selections or cuboids");
|
||||||
Player.Message(p, " %HIf no xyz is given, marks at where you are standing");
|
Player.Message(p, " %HIf no xyz is given, marks at where you are standing");
|
||||||
Player.Message(p, " %He.g. /mark 30 y 20 will mark at (30, last y, 20)");
|
Player.Message(p, " %He.g. /mark 30 y 20 will mark at (30, last y, 20)");
|
||||||
|
Player.Message(p, " %HNote: If no selection is in progress, activates (e.g. doors) the existing block at those coordinates.");
|
||||||
Player.Message(p, "%T/mark all %H- Places markers at min and max corners of the map");
|
Player.Message(p, "%T/mark all %H- Places markers at min and max corners of the map");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,13 +101,7 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Block.canPlace(this, old) && !Block.BuildIn(old) && !Block.AllowBreak(old)) {
|
if (!CheckManualChange(old, block, doDelete)) {
|
||||||
Formatter.MessageBlock(this, doDelete ? "delete " : "replace ", old);
|
|
||||||
RevertBlock(x, y, z); return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Block.canPlace(this, block)) {
|
|
||||||
Formatter.MessageBlock(this, "place ", block);
|
|
||||||
RevertBlock(x, y, z); return;
|
RevertBlock(x, y, z); return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +128,19 @@ namespace MCGalaxy {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal bool CheckManualChange(byte old, byte block, bool replaceMode) {
|
||||||
|
if (!Block.canPlace(this, old) && !Block.BuildIn(old) && !Block.AllowBreak(old)) {
|
||||||
|
Formatter.MessageBlock(this, replaceMode ? "replace " : "delete ", old);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Block.canPlace(this, block)) {
|
||||||
|
Formatter.MessageBlock(this, "place ", block);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool DeleteBlock(byte old, ushort x, ushort y, ushort z, byte block, byte extBlock) {
|
bool DeleteBlock(byte old, ushort x, ushort y, ushort z, byte block, byte extBlock) {
|
||||||
if (deleteMode) { return ChangeBlock(x, y, z, Block.air, 0); }
|
if (deleteMode) { return ChangeBlock(x, y, z, Block.air, 0); }
|
||||||
bool changed = true;
|
bool changed = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user