mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-16 19:15:14 -04:00
commit
1b85f54dbf
@ -304,6 +304,64 @@ static struct ChatCommand MotdCommand = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/*#######################################################################################################################*
|
||||||
|
*-------------------------------------------------------PlaceCommand-----------------------------------------------------*
|
||||||
|
*########################################################################################################################*/
|
||||||
|
|
||||||
|
static void PlaceCommand_Execute(const cc_string* args, int argsCount) {
|
||||||
|
int block;
|
||||||
|
IVec3 pos;
|
||||||
|
cc_uint8 off;
|
||||||
|
|
||||||
|
if (argsCount == 2) {
|
||||||
|
Chat_AddRaw("&eToo few arguments.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
block = !argsCount || argsCount == 3 ? Inventory_SelectedBlock : Block_Parse(&args[0]);
|
||||||
|
|
||||||
|
if (block == -1) {
|
||||||
|
Chat_AddRaw("&eCould not parse block.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (block > Game_Version.MaxCoreBlock && !Block_IsCustomDefined(block)) {
|
||||||
|
Chat_Add1("&eThere is no block with id \"%i\".", &block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argsCount > 2) {
|
||||||
|
off = argsCount == 4;
|
||||||
|
if (!Convert_ParseInt(&args[0 + off], &pos.x) || !Convert_ParseInt(&args[1 + off], &pos.y) || !Convert_ParseInt(&args[2 + off], &pos.z)) {
|
||||||
|
Chat_AddRaw("&eCould not parse coordinates.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
IVec3_Floor(&pos, &Entities.CurPlayer->Base.Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!World_Contains(pos.x, pos.y, pos.z)) {
|
||||||
|
Chat_AddRaw("&eCoordinates are outside the world boundaries.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Game_ChangeBlock(pos.x, pos.y, pos.z, block);
|
||||||
|
cc_string name = Block_UNSAFE_GetName(block);
|
||||||
|
Chat_Add4("&eSuccessfully placed %s block at (%i, %i, %i).", &name, &pos.x, &pos.y, &pos.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct ChatCommand PlaceCommand = {
|
||||||
|
"Place", PlaceCommand_Execute,
|
||||||
|
COMMAND_FLAG_SINGLEPLAYER_ONLY,
|
||||||
|
{
|
||||||
|
"&a/client place [block] [x y z]",
|
||||||
|
"&ePlaces block at [x y z].",
|
||||||
|
"&eIf no block is provided, held block is used.",
|
||||||
|
"&eIf no coordinates are provided, current",
|
||||||
|
"&e coordinates are used."
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-------------------------------------------------------DrawOpCommand-----------------------------------------------------*
|
*-------------------------------------------------------DrawOpCommand-----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
@ -747,6 +805,7 @@ static void OnInit(void) {
|
|||||||
Commands_Register(&TeleportCommand);
|
Commands_Register(&TeleportCommand);
|
||||||
Commands_Register(&ClearDeniedCommand);
|
Commands_Register(&ClearDeniedCommand);
|
||||||
Commands_Register(&MotdCommand);
|
Commands_Register(&MotdCommand);
|
||||||
|
Commands_Register(&PlaceCommand);
|
||||||
Commands_Register(&BlockEditCommand);
|
Commands_Register(&BlockEditCommand);
|
||||||
Commands_Register(&CuboidCommand);
|
Commands_Register(&CuboidCommand);
|
||||||
Commands_Register(&ReplaceCommand);
|
Commands_Register(&ReplaceCommand);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user