From 68f9263a24a345435d2310ab559ce8a811ef0427 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 13 May 2020 19:41:30 +0200 Subject: Hacked Client --- CMakeLists.txt | 2 +- builtin/client/death_formspec.lua | 25 +- builtin/client/init.lua | 3 +- builtin/client/spoof.lua | 4 + builtin/mainmenu/init.lua | 1 + builtin/settingtypes.txt | 14 +- doc/client_lua_api.md | 1451 +++ doc/client_lua_api.txt | 1451 --- doc/fst_api.md | 171 + doc/fst_api.txt | 171 - doc/lua_api.md | 7828 +++++++++++++++ doc/lua_api.txt | 7828 --------------- doc/protocol.md | 110 + doc/protocol.txt | 110 - spoof.js | 63 + spoof.txt | 18748 ++++++++++++++++++++++++++++++++++++ src/client/client.cpp | 36 +- src/client/client.h | 7 +- src/client/clientlauncher.cpp | 5 +- src/client/game.cpp | 10 +- src/client/mapblock_mesh.cpp | 2 + src/nodedef.cpp | 5 +- src/script/cpp_api/s_base.cpp | 4 +- src/script/cpp_api/s_security.cpp | 8 +- 24 files changed, 28462 insertions(+), 9595 deletions(-) create mode 100644 builtin/client/spoof.lua create mode 100644 doc/client_lua_api.md delete mode 100644 doc/client_lua_api.txt create mode 100644 doc/fst_api.md delete mode 100644 doc/fst_api.txt create mode 100644 doc/lua_api.md delete mode 100644 doc/lua_api.txt create mode 100644 doc/protocol.md delete mode 100644 doc/protocol.txt create mode 100644 spoof.js create mode 100644 spoof.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index b1734f0c7..3f36037ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ set(CLANG_MINIMUM_VERSION "3.4") set(VERSION_MAJOR 5) set(VERSION_MINOR 2) set(VERSION_PATCH 0) -set(VERSION_EXTRA "GalwayGirl Client" CACHE STRING "Stuff to append to version string") +set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string") # Change to false for releases set(DEVELOPMENT_BUILD TRUE) diff --git a/builtin/client/death_formspec.lua b/builtin/client/death_formspec.lua index e755ac5c1..516a15efc 100644 --- a/builtin/client/death_formspec.lua +++ b/builtin/client/death_formspec.lua @@ -1,16 +1,29 @@ -- CSM death formspec. Only used when clientside modding is enabled, otherwise -- handled by the engine. +local dead = false + core.register_on_death(function() - core.display_chat_message("You died.") - local formspec = "size[11,5.5]bgcolor[#320000b4;true]" .. - "label[4.85,1.35;" .. fgettext("You died") .. - "]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]" - core.show_formspec("bultin:death", formspec) + if not dead then + core.display_chat_message("You died.") + local formspec = "size[11,5.5]bgcolor[#320000b4;true]" .. + "label[4.85,1.35;" .. fgettext("You died") .. + "]button_exit[4,3;3,0.5;btn_respawn;".. fgettext("Respawn") .."]" + core.show_formspec("bultin:death", formspec) + dead = true + end end) core.register_on_formspec_input(function(formname, fields) - if formname == "bultin:death" then + if formname == "bultin:death" and fields.btn_respawn then core.send_respawn() + dead = false end end) + +core.register_chatcommand("respawn", { + func = function() + core.send_respawn() + dead = false + end +}) diff --git a/builtin/client/init.lua b/builtin/client/init.lua index 9633a7c71..bcaa5244e 100644 --- a/builtin/client/init.lua +++ b/builtin/client/init.lua @@ -6,6 +6,7 @@ local commonpath = scriptpath.."common"..DIR_DELIM dofile(clientpath .. "register.lua") dofile(commonpath .. "after.lua") dofile(commonpath .. "chatcommands.lua") -dofile(clientpath .. "chatcommands.lua") dofile(commonpath .. "vector.lua") dofile(clientpath .. "death_formspec.lua") +dofile(clientpath .. "spoof.lua") + diff --git a/builtin/client/spoof.lua b/builtin/client/spoof.lua new file mode 100644 index 000000000..f053a8a08 --- /dev/null +++ b/builtin/client/spoof.lua @@ -0,0 +1,4 @@ +local file = io.open("spoof.txt", "a") +minetest.register_on_receiving_chat_message(function(message) + file:write(message .. "\n") +end) diff --git a/builtin/mainmenu/init.lua b/builtin/mainmenu/init.lua index 130c3e73c..21b74f34a 100644 --- a/builtin/mainmenu/init.lua +++ b/builtin/mainmenu/init.lua @@ -158,3 +158,4 @@ local function init_globals() end init_globals() + diff --git a/builtin/settingtypes.txt b/builtin/settingtypes.txt index e86acdf8d..ba0cf9610 100644 --- a/builtin/settingtypes.txt +++ b/builtin/settingtypes.txt @@ -2138,12 +2138,16 @@ contentdb_flag_blacklist (ContentDB Flag Blacklist) string nonfree, desktop_defa [Cheats] -fullbright (Enable Fullbright) bool false +fullbright (Enable fullbright) bool false -xray (Enable Xray, requires Fullbright) bool false +xray (Enable xray, requires fullbright) bool false -bypass_fly (Fly Hack) bool false +xray_texture (Texture to make transparent when xray is enabled) string default_stone.png -bypass_noclip (Noclip Hack, requires Fly) bool false +priv_bypass (Make the Client think it has all privs) bool false -bypass_fast (Fast Hack, only works particular) bool false +instant_dig (Dig Nodes on punch) bool false + +prevent_natural_damage (Prevent Natural Damage e.g Fall Damage) bool false + +freecam (Move around freely) bool false diff --git a/doc/client_lua_api.md b/doc/client_lua_api.md new file mode 100644 index 000000000..c24de8d85 --- /dev/null +++ b/doc/client_lua_api.md @@ -0,0 +1,1451 @@ +Minetest Lua Client Modding API Reference 5.2.0 +================================================ +* More information at +* Developer Wiki: + +Introduction +------------ + +** WARNING: The client API is currently unstable, and may break/change without warning. ** + +Content and functionality can be added to Minetest 0.4.15-dev+ by using Lua +scripting in run-time loaded mods. + +A mod is a self-contained bunch of scripts, textures and other related +things that is loaded by and interfaces with Minetest. + +Transferring client-sided mods from the server to the client is planned, but not implemented yet. + +If you see a deficiency in the API, feel free to attempt to add the +functionality in the engine and API. You can send such improvements as +source code patches on GitHub (https://github.com/minetest/minetest). + +Programming in Lua +------------------ +If you have any difficulty in understanding this, please read +[Programming in Lua](http://www.lua.org/pil/). + +Startup +------- +Mods are loaded during client startup from the mod load paths by running +the `init.lua` scripts in a shared environment. + +In order to load client-side mods, the following conditions need to be satisfied: + +1) `$path_user/minetest.conf` contains the setting `enable_client_modding = true` + +2) The client-side mod located in `$path_user/clientmods/` is added to + `$path_user/clientmods/mods.conf` as `load_mod_ = true`. + +Note: Depending on the remote server's settings, client-side mods might not +be loaded or have limited functionality. See setting `csm_restriction_flags` for reference. + +Paths +----- +* `RUN_IN_PLACE=1` (Windows release, local build) + * `$path_user`: `` + * `$path_share`: `` +* `RUN_IN_PLACE=0`: (Linux release) + * `$path_share`: + * Linux: `/usr/share/minetest` + * Windows: `/minetest-0.4.x` + * `$path_user`: + * Linux: `$HOME/.minetest` + * Windows: `C:/users//AppData/minetest` (maybe) + +Mod load path +------------- +Generic: + +* `$path_share/clientmods/` +* `$path_user/clientmods/` (User-installed mods) + +In a run-in-place version (e.g. the distributed windows version): + +* `minetest-0.4.x/clientmods/` (User-installed mods) + +On an installed version on Linux: + +* `/usr/share/minetest/clientmods/` +* `$HOME/.minetest/clientmods/` (User-installed mods) + +Modpack support +---------------- + +Mods can be put in a subdirectory, if the parent directory, which otherwise +should be a mod, contains a file named `modpack.conf`. +The file is a key-value store of modpack details. + +* `name`: The modpack name. +* `description`: Description of mod to be shown in the Mods tab of the main + menu. + +Mod directory structure +------------------------ + + clientmods + ├── modname + │   ├── mod.conf + │   ├── init.lua + └── another + +### modname + +The location of this directory. + +### mod.conf + +An (optional) settings file that provides meta information about the mod. + +* `name`: The mod name. Allows Minetest to determine the mod name even if the + folder is wrongly named. +* `description`: Description of mod to be shown in the Mods tab of the main + menu. +* `depends`: A comma separated list of dependencies. These are mods that must be + loaded before this mod. +* `optional_depends`: A comma separated list of optional dependencies. + Like a dependency, but no error if the mod doesn't exist. + +### `init.lua` + +The main Lua script. Running this script should register everything it +wants to register. Subsequent execution depends on minetest calling the +registered callbacks. + +**NOTE**: Client mods currently can't provide and textures, sounds or models by +themselves. Any media referenced in function calls must already be loaded +(provided by mods that exist on the server). + +Naming convention for registered textual names +---------------------------------------------- +Registered names should generally be in this format: + + "modname:" ( can have characters a-zA-Z0-9_) + +This is to prevent conflicting names from corrupting maps and is +enforced by the mod loader. + +### Example +In the mod `experimental`, there is the ideal item/node/entity name `tnt`. +So the name should be `experimental:tnt`. + +Enforcement can be overridden by prefixing the name with `:`. This can +be used for overriding the registrations of some other mod. + +Example: Any mod can redefine `experimental:tnt` by using the name + + :experimental:tnt + +when registering it. +(also that mod is required to have `experimental` as a dependency) + +The `:` prefix can also be used for maintaining backwards compatibility. + +Sounds +------ +**NOTE: Connecting sounds to objects is not implemented.** + +Only Ogg Vorbis files are supported. + +For positional playing of sounds, only single-channel (mono) files are +supported. Otherwise OpenAL will play them non-positionally. + +Mods should generally prefix their sounds with `modname_`, e.g. given +the mod name "`foomod`", a sound could be called: + + foomod_foosound.ogg + +Sounds are referred to by their name with a dot, a single digit and the +file extension stripped out. When a sound is played, the actual sound file +is chosen randomly from the matching sounds. + +When playing the sound `foomod_foosound`, the sound is chosen randomly +from the available ones of the following files: + +* `foomod_foosound.ogg` +* `foomod_foosound.0.ogg` +* `foomod_foosound.1.ogg` +* (...) +* `foomod_foosound.9.ogg` + +Examples of sound parameter tables: + + -- Play locationless + { + gain = 1.0, -- default + } + -- Play locationless, looped + { + gain = 1.0, -- default + loop = true, + } + -- Play in a location + { + pos = {x = 1, y = 2, z = 3}, + gain = 1.0, -- default + } + -- Play connected to an object, looped + { + object = , + gain = 1.0, -- default + loop = true, + } + +Looped sounds must either be connected to an object or played locationless. + +### SimpleSoundSpec +* e.g. `""` +* e.g. `"default_place_node"` +* e.g. `{}` +* e.g. `{name = "default_place_node"}` +* e.g. `{name = "default_place_node", gain = 1.0}` + +Representations of simple things +-------------------------------- + +### Position/vector + + {x=num, y=num, z=num} + +For helper functions see "Vector helpers". + +### pointed_thing +* `{type="nothing"}` +* `{type="node", under=pos, above=pos}` +* `{type="object", id=ObjectID}` + +Flag Specifier Format +--------------------- +Flags using the standardized flag specifier format can be specified in either of +two ways, by string or table. + +The string format is a comma-delimited set of flag names; whitespace and +unrecognized flag fields are ignored. Specifying a flag in the string sets the +flag, and specifying a flag prefixed by the string `"no"` explicitly +clears the flag from whatever the default may be. + +In addition to the standard string flag format, the schematic flags field can +also be a table of flag names to boolean values representing whether or not the +flag is set. Additionally, if a field with the flag name prefixed with `"no"` +is present, mapped to a boolean of any value, the specified flag is unset. + +E.g. A flag field of value + + {place_center_x = true, place_center_y=false, place_center_z=true} + +is equivalent to + + {place_center_x = true, noplace_center_y=true, place_center_z=true} + +which is equivalent to + + "place_center_x, noplace_center_y, place_center_z" + +or even + + "place_center_x, place_center_z" + +since, by default, no schematic attributes are set. + +Formspec +-------- +Formspec defines a menu. It is a string, with a somewhat strange format. + +Spaces and newlines can be inserted between the blocks, as is used in the +examples. + +### Examples + +#### Chest + + size[8,9] + list[context;main;0,0;8,4;] + list[current_player;main;0,5;8,4;] + +#### Furnace + + size[8,9] + list[context;fuel;2,3;1,1;] + list[context;src;2,1;1,1;] + list[context;dst;5,1;2,2;] + list[current_player;main;0,5;8,4;] + +#### Minecraft-like player inventory + + size[8,7.5] + image[1,0.6;1,2;player.png] + list[current_player;main;0,3.5;8,4;] + list[current_player;craft;3,0;3,3;] + list[current_player;craftpreview;7,1;1,1;] + +### Elements + +#### `size[,,]` +* Define the size of the menu in inventory slots +* `fixed_size`: `true`/`false` (optional) +* deprecated: `invsize[,;]` + +#### `container[,]` +* Start of a container block, moves all physical elements in the container by (X, Y) +* Must have matching container_end +* Containers can be nested, in which case the offsets are added + (child containers are relative to parent containers) + +#### `container_end[]` +* End of a container, following elements are no longer relative to this container + +#### `list[;;,;,;]` +* Show an inventory list + +#### `list[;;,;,;]` +* Show an inventory list + +#### `listring[;]` +* Allows to create a ring of inventory lists +* Shift-clicking on items in one element of the ring + will send them to the next inventory list inside the ring +* The first occurrence of an element inside the ring will + determine the inventory where items will be sent to + +#### `listring[]` +* Shorthand for doing `listring[;]` + for the last two inventory lists added by list[...] + +#### `listcolors[;]` +* Sets background color of slots as `ColorString` +* Sets background color of slots on mouse hovering + +#### `listcolors[;;]` +* Sets background color of slots as `ColorString` +* Sets background color of slots on mouse hovering +* Sets color of slots border + +#### `listcolors[;;;;]` +* Sets background color of slots as `ColorString` +* Sets background color of slots on mouse hovering +* Sets color of slots border +* Sets default background color of tooltips +* Sets default font color of tooltips + +#### `tooltip[;;,]` +* Adds tooltip for an element +* `` tooltip background color as `ColorString` (optional) +* `` tooltip font color as `ColorString` (optional) + +#### `image[,;,;]` +* Show an image +* Position and size units are inventory slots + +#### `item_image[,;,;]` +* Show an inventory image of registered item/node +* Position and size units are inventory slots + +#### `bgcolor[;]` +* Sets background color of formspec as `ColorString` +* If `true`, the background color is drawn fullscreen (does not effect the size of the formspec) + +#### `background[,;,;]` +* Use a background. Inventory rectangles are not drawn then. +* Position and size units are inventory slots +* Example for formspec 8x4 in 16x resolution: image shall be sized + 8 times 16px times 4 times 16px. + +#### `background[,;,;;]` +* Use a background. Inventory rectangles are not drawn then. +* Position and size units are inventory slots +* Example for formspec 8x4 in 16x resolution: + image shall be sized 8 times 16px times 4 times 16px +* If `true` the background is clipped to formspec size + (`x` and `y` are used as offset values, `w` and `h` are ignored) + +#### `pwdfield[,;,;;