diff --git a/dependencies/glfw/src b/dependencies/glfw/src index 8e6c8d7..b4c3ef9 160000 --- a/dependencies/glfw/src +++ b/dependencies/glfw/src @@ -1 +1 @@ -Subproject commit 8e6c8d7effc54f8aecd30eda17069588298f4ada +Subproject commit b4c3ef9d0fdf46845f3e81e5d989dab06e71e6c1 diff --git a/dependencies/symbol-processor/src b/dependencies/symbol-processor/src index ea31be1..39e1d17 160000 --- a/dependencies/symbol-processor/src +++ b/dependencies/symbol-processor/src @@ -1 +1 @@ -Subproject commit ea31be1cb2b43decb9c906215f80ff20efd2b479 +Subproject commit 39e1d17f93fb2253be3692858241aab62104d05f diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index c648802..2dbc3a9 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -14,7 +14,7 @@ 2. If a setting is cached, then the dialog's default value will be the cached value instead of the normal default. 3. When configuration has been completed, the settings specified will be cached. 2. The launcher replaces itself with MCPI. - 1. MCPI-Reborn components are loaded using ``LD_PRELOAD`` and ``LD_LIBRARY_PATH``. + 1. MCPI-Reborn components are loaded using `LD_PRELOAD` and `LD_LIBRARY_PATH`. 2. If the Media Layer Proxy is enabled, then the Media Layer Proxy Client is started as a sub-process. ### Server @@ -27,11 +27,11 @@ This component configures the various environmental variables required for MCPI-Reborn to work. When running in client-mode, this component will also launch several Zenity dialogs for interactive configuration. The environmental variables configured by this component includes: -* ``LD_PRELOAD`` -* ``LD_LIBRARY_PATH`` -* ``MCPI_FEATURE_FLAGS`` -* ``MCPI_RENDER_DISTANCE`` -* ``MCPI_USERNAME`` +* `LD_PRELOAD` +* `LD_LIBRARY_PATH` +* `MCPI_FEATURE_FLAGS` +* `MCPI_RENDER_DISTANCE` +* `MCPI_USERNAME` This is always compiled for the host system's architecture. @@ -78,11 +78,11 @@ This is always compiled for ARM. This sub-component includes headers for SDL, GLES, and EGL allowing easy (cross-)compilation. ### Mods -This component patches MCPI to modify its behavior. It's loaded using ``LD_PRELOAD``. +This component patches MCPI to modify its behavior. It's loaded using `LD_PRELOAD`. This is always compiled for ARM. -### ``libreborn`` +### `libreborn` This component contains various utility functions including: * Code Patching (ARM Only) @@ -91,7 +91,7 @@ This component contains various utility functions including: The code patching is ARM only because it relies on hard-coded ARM instructions. However, this is irrelevant since code patching is only needed in ARM code (to patch MCPI). -### ``symbols`` +### `symbols` This component contains all MCPI symbols. ## Dependencies diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 0dba96e..b1cf79b 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -19,4 +19,4 @@ ``` ### Environment Variables -* ``MCPI_TOOLCHAIN_USE_DEFAULT_SEARCH_PATHS``: Use Default CMake Search Paths Rather Than Guessing +* `MCPI_TOOLCHAIN_USE_DEFAULT_SEARCH_PATHS`: Use Default CMake Search Paths Rather Than Guessing diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 35af98a..f4b0f8a 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,44 +1,44 @@ # Changelog **2.5.3** -* Add ``Replace Block Highlight With Outline`` Feature Flag (Enabled By Default) - * By Default, The Outline Width Is Set Using The GUI Scale - * This Can Be Overridden Using The ``MCPI_BLOCK_OUTLINE_WIDTH`` Environmental Variable +* Add `Replace Block Highlight With Outline` Feature Flag (Enabled By Default) +* By Default, The Outline Width Is Set Using The GUI Scale +* This Can Be Overridden Using The ``MCPI_BLOCK_OUTLINE_WIDTH`` Environmental Variable * Added ``overwrite_calls_within`` Function * Add ``Add Cake`` Feature Flag (Enabled By Default) * Add Milk Buckets * Implement Crafting Remainders **2.5.2** -* Add ``3D Chest Model`` Feature Flag (Enabled By Default) +* Add `3D Chest Model` Feature Flag (Enabled By Default) * Stop Using Jenkins -* Replace ``iconv`` +* Replace `iconv` * Replace LibPNG **2.5.1** -* Allow Overriding Custom Skin Server Using ``MCPI_SKIN_SERVER`` Environmental Variable +* Allow Overriding Custom Skin Server Using `MCPI_SKIN_SERVER` Environmental Variable * Fix Bug With SDK Generation **2.5.0** * [Custom skin support](CUSTOM_SKINS.md)! -* Add ``Load Custom Skins`` Feature Flag (Enabled By Default) +* Add `Load Custom Skins` Feature Flag (Enabled By Default) **2.4.9** -* Allow Overriding GUI Scale With ``MCPI_GUI_SCALE`` Environmental Variable -* Add ``Disable Block Tinting`` Feature Flag (Disabled By Default) -* Add ``Disable Hostile AI In Creative Mode`` Feature Flag (Enabled By Default) +* Allow Overriding GUI Scale With `MCPI_GUI_SCALE` Environmental Variable +* Add `Disable Block Tinting` Feature Flag (Disabled By Default) +* Add `Disable Hostile AI In Creative Mode` Feature Flag (Enabled By Default) * Allow Accessing Configuration At Runtime (Useful For Mods That Need To Support Multiple Versions) **2.4.8** -* Fix Bug In ``extract_from_bl_instruction`` +* Fix Bug In `extract_from_bl_instruction` * Update LIEF And GLFW * Allow Mods To Access The Original GLFW Keycode For Key Events (But Better) * More Accurate Sound **2.4.7** * Improve Server Performance -* Add ``Add Biome Colors To Grass`` Feature Flag (Disabled By Default) -* Add ``Generate Caves`` Feature Flag (Enabled By Default) +* Add `Add Biome Colors To Grass` Feature Flag (Disabled By Default) +* Add `Generate Caves` Feature Flag (Enabled By Default) * Allow Mods To Access The Original GLFW Keycode For Key Events **2.4.6** @@ -52,16 +52,16 @@ **2.4.4** * Cache Previous Launcher Configuration -* Add ``MCPI_API_PORT`` Environmental Variable +* Add `MCPI_API_PORT` Environmental Variable * Fix Particles In Front-Facing View * Fixed Launch Crash On Ubuntu ARM64 * PatchELF Replaced With LIEF -* Moved ``3D Anaglyph`` Feature Flag To Options Screen -* Add ``Improved Classic Title Screen`` Feature Flag (Enabled By Default) +* Moved `3D Anaglyph` Feature Flag To Options Screen +* Add `Improved Classic Title Screen` Feature Flag (Enabled By Default) * Add Quit button - * Add Options Button (Moved From ``Fix Options Screen`` Feature Flag) -* Add ``Disable Speed Bridging`` Feature Flag (Disabled By Default) -* Add ``Disable Creative Mode Mining Delay`` Feature Flag (Disabled By Default) + * Add Options Button (Moved From `Fix Options Screen` Feature Flag) +* Add `Disable Speed Bridging` Feature Flag (Disabled By Default) +* Add `Disable Creative Mode Mining Delay` Feature Flag (Disabled By Default) * Improved Feature Flag Names * Miscellaneous Bug Fixes * Improved Build System @@ -83,11 +83,11 @@ * More Reliable AppImages * CMake Refactors * Disable Broken Touchscreen-Specific Block Outline Behavior -* Add ``Remove Forced GUI Lag (Can Break Joining Servers)`` Feature Flag (Disabled By Default) -* Add ``Add Buckets`` Feature Flag (Enabled By Default) -* Add ``Classic HUD`` Feature Flag (Enabled By Default) -* Add ``Translucent Toolbar`` Feature Flag (Enabled By Default) -* Add ``Force EGL`` Feature Flag (Disabled By Default) +* Add `Remove Forced GUI Lag (Can Break Joining Servers)` Feature Flag (Disabled By Default) +* Add `Add Buckets` Feature Flag (Enabled By Default) +* Add `Classic HUD` Feature Flag (Enabled By Default) +* Add `Translucent Toolbar` Feature Flag (Enabled By Default) +* Add `Force EGL` Feature Flag (Disabled By Default) * Fix Sound Pitch/Volume/Attenuation * Fix Holding Left-Click When Attacking * Don't Force EGL (Should Fix Some NVIDIA Systems) @@ -101,7 +101,7 @@ * Bug Fixes **2.3.11** -* ``--version`` Command Line Option +* `--version` Command Line Option * TPS Measured In Benchmark & Server * Front-Facing Third-Person * GLESv1 Comparability Layer @@ -127,39 +127,39 @@ * Don't Append Hyphens To New World Name, Only Folder Names **2.3.6** -* Fix ``Invert Y-axis`` Option Name +* Fix `Invert Y-axis` Option Name * Improve Touch GUI Inventory In Non-Touch GUI * New Create World Dialog - * Controlled By ``Implement Create World Dialog`` Feature Flag (Enabled By Default) + * Controlled By `Implement Create World Dialog` Feature Flag (Enabled By Default) * Custom World Names * Game-Mode Selection * Custom Seeds **2.3.5** * Renamed Some Feature Flags -* Add ``Improved Title Background`` Feature Flag (Enabled By Default) +* Add `Improved Title Background` Feature Flag (Enabled By Default) * Non-Touch GUI Rework - * Make ``Full Touch GUI`` Feature Flag Disabled By Default - * Add ``Force Touch GUI Button Behavior`` Feature Flag (Enabled By Default) - * Add ``Improved Button Hover Behavior`` Feature Flag (Enabled By Default) + * Make `Full Touch GUI` Feature Flag Disabled By Default + * Add `Force Touch GUI Button Behavior` Feature Flag (Enabled By Default) + * Add `Improved Button Hover Behavior` Feature Flag (Enabled By Default) **2.3.4** * AppImage Fixes * Make Death Messages Customizable Server-Side * Fix Q-Key Behavior Behavior When Editing Signs -* Add ``Force Touch Inventory`` Feature Flag (Disabled By Default) -* Add ``Fix Pause Menu`` Feature Flag (Enabled By Default) +* Add `Force Touch Inventory` Feature Flag (Disabled By Default) +* Add `Fix Pause Menu` Feature Flag (Enabled By Default) * Enables Server Visibility Toggle Button * Options Changes (Not Supported On Legacy) - * Add ``Fix Options Screen`` Feature Flag (Enabled By Default) + * Add `Fix Options Screen` Feature Flag (Enabled By Default) * Adds Options Button To Classic UI Start Screen * Removes Useless Options Toggles * Fixes Options Toggles' Default Position * Store Multiple Settings In `options.txt` - * ``Peaceful Mode`` Feature Flag Moved To ``game_difficulty`` - * ``Smooth Lighting`` Feature Flag Moved To ``gfx_ao`` - * ``Fancy Graphics`` Feature Flag Moved To ``gfx_fancygraphics`` - * ``Disable Hosting LAN Worlds`` Feature Flag Moved To ``mp_server_visible_default`` + * `Peaceful Mode` Feature Flag Moved To `game_difficulty` + * `Smooth Lighting` Feature Flag Moved To `gfx_ao` + * `Fancy Graphics` Feature Flag Moved To `gfx_fancygraphics` + * `Disable Hosting LAN Worlds` Feature Flag Moved To `mp_server_visible_default` **2.3.3** * Add More Blocks To Expanded Creative Inventory @@ -170,30 +170,30 @@ * Add More Blocks To Expanded Creative Inventory * Fix Nether Reactor With Creative Restrictions Disabled * Alphabetize Feature Flags -* Add ``Disable V-Sync`` Feature Flag (Disabled By Default) +* Add `Disable V-Sync` Feature Flag (Disabled By Default) **2.3.1** -* Internal Refactor Of ``libreborn`` -* Remove Use Of ``/bin/sh`` +* Internal Refactor Of `libreborn` +* Remove Use Of `/bin/sh` * Load Custom Mods First * Use Zenity Dark Mode -* Add ``Improved Cursor Rendering`` Feature Flag (Enabled By Default) +* Add `Improved Cursor Rendering` Feature Flag (Enabled By Default) **2.3.0** * Switch To AppImage For Packaging * Prevent OpenAL From Crashing When Out Of Memory * Vendor GLFW & Zenity * Seamless Wayland Support -* Add ``MCPI_DEBUG`` Environmental Variable -* Add ``Disable Hosting LAN Worlds`` Feature Flag (Disabled By Default) -* Add ``Fix Furnace Not Checking Item Auxiliary`` Feature Flag (Enabled By Default) -* Add ``Disable Raw Mouse Motion (Not Recommended)`` Feature Flag (Disabled By Default) For Broken X11 Setups +* Add `MCPI_DEBUG` Environmental Variable +* Add `Disable Hosting LAN Worlds` Feature Flag (Disabled By Default) +* Add `Fix Furnace Not Checking Item Auxiliary` Feature Flag (Enabled By Default) +* Add `Disable Raw Mouse Motion (Not Recommended)` Feature Flag (Disabled By Default) For Broken X11 Setups * Added Back `~/.minecraft-pi/mods` * Improve Build System * Improve Documentation **2.2.11** -* Add ``Close Current Screen On Death`` Feature Flag (Enabled By Default) To Prevent Bugs +* Add `Close Current Screen On Death` Feature Flag (Enabled By Default) To Prevent Bugs * Fix More Furnace UI Bugs When Using "Disable 'gui_blocks' Atlas" **2.2.10** @@ -204,8 +204,8 @@ * Store Files In `/usr/lib` **2.2.8** -* Add ``Hide Chat Messages`` Optional Feature Flag -* Add ``Remove Creative Mode Restrictions`` Optional Feature Flag +* Add `Hide Chat Messages` Optional Feature Flag +* Add `Remove Creative Mode Restrictions` Optional Feature Flag * Improve GLFW->SDL Mouse Motion Event Conversion * Performance Optimizations * Make Majority Of Server-Specific Logging Code Also Apply To The Client @@ -237,15 +237,15 @@ * Make Missing Sound Event Cause Warning Rather Than Crash **2.2.1** -* Prevent ``random.burp`` Sound From Crashing Game +* Prevent `random.burp` Sound From Crashing Game * Always Cleanup Media Layer, Even On Crash * Resolve All Sounds On Startup **2.2.0** * Sound Support -* Split Off ``Allow Joining Survival Servers`` From Game-Mode Mod +* Split Off `Allow Joining Survival Servers` From Game-Mode Mod * Separate Headless Code From Server Code -* Fix Bug Where ``RakNetInstance`` Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened +* Fix Bug Where `RakNetInstance` Starts Pinging Potential Servers Before The "Join Game" Screen Is Opened * Clean-Up Code * Remove Support For Debian Buster @@ -262,7 +262,7 @@ * Print Error Message If RakNet Fails To Start **2.1.4** -* Fix ``RakNet::RakString`` Security Bug +* Fix `RakNet::RakString` Security Bug **2.1.3** * Workaround Broken Library Search Path On Some ARM 32-Bit Systems @@ -274,16 +274,16 @@ * Fix Symlink Code **2.1.0** -* Allow Binding ``Q`` Key To Item Dropping +* Allow Binding `Q` Key To Item Dropping * Expose More Feature Flags -* Replace ``Mob Spawning`` Feature Flag With ``Force Mob Spawning`` -* Fix ``ESC`` Key In Options Menu When ``Miscellaneous Input Fixes`` Is Enabled +* Replace `Mob Spawning` Feature Flag With `Force Mob Spawning` +* Fix `ESC` Key In Options Menu When `Miscellaneous Input Fixes` Is Enabled **2.0.9** -* Fix Translucent Preview Items In Furnace UI Being Fully Opaque When The ``gui_blocks`` Atlas Is Disabled +* Fix Translucent Preview Items In Furnace UI Being Fully Opaque When The `gui_blocks` Atlas Is Disabled **2.0.8** -* Use Default Port In ``servers.txt`` If Not Specified +* Use Default Port In `servers.txt` If Not Specified **2.0.7** * Fix Sign Text Not Updating In Multiplayer When Exiting Editing UI Using Escape Button @@ -300,7 +300,7 @@ * Optimize Media Layer Proxy **2.0.3** -* Make ``kill`` Admin Command Print Death Message +* Make `kill` Admin Command Print Death Message **2.0.2** * Fix Mouse Cursor Bugs diff --git a/docs/COMMAND_LINE.md b/docs/COMMAND_LINE.md index 4e1a28a..1683ea7 100644 --- a/docs/COMMAND_LINE.md +++ b/docs/COMMAND_LINE.md @@ -2,19 +2,19 @@ ## Command Line Arguments -### ``--version`` (Or ``-v``) -If you run MCPI-Reborn with ``--version`` it will print its version to ``stdout``. +### `--version` (Or `-v`) +If you run MCPI-Reborn with `--version` it will print its version to `stdout`. -### ``--debug`` -This sets ``MCPI_DEBUG``. +### `--debug` +This sets `MCPI_DEBUG`. -### ``--copy-sdk`` +### `--copy-sdk` This extracts the modding SDK and immediately exits. (This allows the SDK to be extracted without starting the game.) ### Client Mode Only -#### ``--print-available-feature-flags`` -This print the available feature flags (and their default values) to ``stdout`` and then immediately exit. +#### `--print-available-feature-flags` +This print the available feature flags (and their default values) to `stdout` and then immediately exit. The feature flags are printed in the following format: ``` @@ -22,43 +22,43 @@ TRUE This Flag Is On By Default FALSE This Flag Is Off By Default ``` -#### ``--default`` -This will skip the startup configuration dialogs and just use the default values. This will use the cached configuration unless ``--no-cache`` is used. +#### `--default` +This will skip the startup configuration dialogs and just use the default values. This will use the cached configuration unless `--no-cache` is used. -#### ``--benchmark`` +#### `--benchmark` This will make MCPI-Reborn enter a simple benchmark mode. This means automatically loading a newly generated world, then rotating the camera for a period of time. When it has finished, it will then exit and print the average FPS while the world was loaded. In this mode, all user input is blocked. However you can still modify rendering settings by changing feature flags. The world used will always be re-created on start and uses a hard-coded seed. -#### ``--no-cache`` +#### `--no-cache` This will skip loading and saving the cached launcher configuration. -#### ``--wipe-cache`` +#### `--wipe-cache` This will wipe the cached launcher configuration. ### Server Mode Only -#### ``--only-generate`` +#### `--only-generate` This will make MCPI-Reborn immediately exit once world generation has completed. This is mainly used for automatically testing MCPI-Reborn. ## Environmental Variables -### ``MCPI_DEBUG`` +### `MCPI_DEBUG` This enables debug logging if it is set. -### ``MCPI_API_PORT`` +### `MCPI_API_PORT` This configures the API to use a different port (the default is 4711). ### Client Mode Only If any of the following variables aren't set, one configuration dialog will open on startup for each unset variable. -#### ``MCPI_FEATURE_FLAGS`` -This corresponds to ``--print-available-feature-flags``. This is just a list of all enabled feature flags separated by ``|``. +#### `MCPI_FEATURE_FLAGS` +This corresponds to `--print-available-feature-flags`. This is just a list of all enabled feature flags separated by `|`. -For instance, the string ``Feature A|Feature B`` would enable both ``Feature A`` and ``Feature B`` and *disable every other available feature flag*. +For instance, the string `Feature A|Feature B` would enable both `Feature A` and `Feature B` and *disable every other available feature flag*. -#### ``MCPI_RENDER_DISTANCE`` -This is the render distance. The possible values are: ``Far``, ``Normal``, ``Short``, and ``Tiny``. +#### `MCPI_RENDER_DISTANCE` +This is the render distance. The possible values are: `Far`, `Normal`, `Short`, and `Tiny`. -#### ``MCPI_USERNAME`` +#### `MCPI_USERNAME` This is the username. diff --git a/docs/CUSTOM_SKINS.md b/docs/CUSTOM_SKINS.md index f6da281..45a872d 100644 --- a/docs/CUSTOM_SKINS.md +++ b/docs/CUSTOM_SKINS.md @@ -3,4 +3,4 @@ MCPI-Reborn supports downloading custom skins from [a central skin server](https This *does not* cache skins and *will not* work without internet access. -Custom skins can be disabled using the ``Load Custom Skins`` feature flag. +Custom skins can be disabled using the `Load Custom Skins` feature flag. diff --git a/docs/DEDICATED_SERVER.md b/docs/DEDICATED_SERVER.md index 77e5037..5b70345 100644 --- a/docs/DEDICATED_SERVER.md +++ b/docs/DEDICATED_SERVER.md @@ -1,10 +1,10 @@ # Dedicated Server -The dedicated server is a version of Minecraft: Pi Edition modified to run in a headless environment. It loads settings from a ``server.properties`` file. +The dedicated server is a version of Minecraft: Pi Edition modified to run in a headless environment. It loads settings from a `server.properties` file. This server is also compatible with MCPE Alpha v0.6.1[^1]. ## Setup -To use, install and run the ``minecraft-pi-reborn-server`` AppImage. It will generate the world and ``server.properties`` in the current directory. +To use, install and run the `minecraft-pi-reborn-server` AppImage. It will generate the world and `server.properties` in the current directory. ## Server Limitations * Player data is not saved because of limitations with MCPE LAN worlds diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 8d3ea58..e0942e7 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -6,16 +6,16 @@ Download packages [here](https://gitea.thebrokenrail.com/minecraft-pi-reborn/min ### System Requirements * Debian Bullseye/Ubuntu 20.04 Or Higher * FUSE 2 - * Debian/Ubuntu: ``sudo apt install libfuse2`` - * Arch: ``sudo pacman -S fuse2`` + * Debian/Ubuntu: `sudo apt install libfuse2` + * Arch: `sudo pacman -S fuse2` * Client-Only Dependencies * Graphics Drivers * GTK+ 3 - * Debian/Ubuntu: ``sudo apt install libgtk-3-0`` - * Arch: ``sudo pacman -S gtk3`` + * Debian/Ubuntu: `sudo apt install libgtk-3-0` + * Arch: `sudo pacman -S gtk3` * OpenAL - * Debian/Ubuntu: ``sudo apt install libopenal1`` - * Arch: ``sudo pacman -S openal`` + * Debian/Ubuntu: `sudo apt install libopenal1` + * Arch: `sudo pacman -S openal` ### Running Follow [these](https://docs.appimage.org/introduction/quickstart.html#how-to-run-an-appimage) instructions. @@ -24,7 +24,7 @@ Follow [these](https://docs.appimage.org/introduction/quickstart.html#how-to-run Download On Flathub ### Note -Game data is stored in ``~/.var/app/com.thebrokenrail.MCPIReborn/.minecraft-pi`` instead of ``~/.minecraft-pi``. +Game data is stored in `~/.var/app/com.thebrokenrail.MCPIReborn/.minecraft-pi` instead of `~/.minecraft-pi`. ## Arch User Repository (Arch Linux Only) -The [``minecraft-pi-reborn-git``](https://aur.archlinux.org/packages/minecraft-pi-reborn-git) is available in the AUR. +The [`minecraft-pi-reborn-git`](https://aur.archlinux.org/packages/minecraft-pi-reborn-git) is available in the AUR. diff --git a/docs/MULTIPLAYER.md b/docs/MULTIPLAYER.md index 0fd62ef..6dc3c8d 100644 --- a/docs/MULTIPLAYER.md +++ b/docs/MULTIPLAYER.md @@ -5,9 +5,9 @@ MCPI-Reborn supports two ways to play multiplayer. This is also supported by vanilla MCPI. Just load a world in MCPI and other devices on the network can join. ## External Servers -Unlike vanilla MCPI, MCPI-Reborn allows you to natively join a server outside of the local network. Just modify ``~/.minecraft-pi/servers.txt`` and it should show up in MCPI's server list. +Unlike vanilla MCPI, MCPI-Reborn allows you to natively join a server outside of the local network. Just modify `~/.minecraft-pi/servers.txt` and it should show up in MCPI's server list. -### Example ``~/.minecraft-pi/servers.txt`` +### Example `~/.minecraft-pi/servers.txt` ``` # Default Port Is 19132 example.com diff --git a/docs/OVERRIDING_ASSETS.md b/docs/OVERRIDING_ASSETS.md index fe158b9..c29f584 100644 --- a/docs/OVERRIDING_ASSETS.md +++ b/docs/OVERRIDING_ASSETS.md @@ -1,6 +1,6 @@ # Overriding Assets -To make overriding assets easier, MCPI-Reborn provides an overrides folder. Any file located in Minecraft: Pi Edition's ``data`` folder can be overridden by placing a file with the same name and path in the overrides folder. The overrides folder is located at ``~/.minecraft-pi/overrides``. +To make overriding assets easier, MCPI-Reborn provides an overrides folder. Any file located in Minecraft: Pi Edition's `data` folder can be overridden by placing a file with the same name and path in the overrides folder. The overrides folder is located at `~/.minecraft-pi/overrides`. ## Examples -- ``data/images/terrain.png`` -> ``~/.minecraft-pi/overrides/images/terrain.png`` -- ``data/lang/en_US.lang`` -> ``~/.minecraft-pi/overrides/lang/en_US.lang`` \ No newline at end of file +- `data/images/terrain.png` -> `~/.minecraft-pi/overrides/images/terrain.png` +- `data/lang/en_US.lang` -> `~/.minecraft-pi/overrides/lang/en_US.lang` \ No newline at end of file diff --git a/launcher/src/client/available-feature-flags b/launcher/src/client/available-feature-flags index b6f75d1..c0acdcb 100644 --- a/launcher/src/client/available-feature-flags +++ b/launcher/src/client/available-feature-flags @@ -8,7 +8,7 @@ TRUE Fix Sign Placement TRUE Show Block Outlines FALSE Expand Creative Mode Inventory FALSE Remove Creative Mode Restrictions -TRUE Animated Water +TRUE Animated Water & Lava TRUE Remove Invalid Item Background TRUE Disable "gui_blocks" Atlas TRUE Fix Camera Rendering @@ -52,3 +52,5 @@ TRUE Load Custom Skins TRUE 3D Chest Model TRUE Replace Block Highlight With Outline TRUE Add Cake +TRUE Use Java Beta 1.3 Light Ramp +TRUE Send Full Level When Hosting Game \ No newline at end of file diff --git a/libreborn/include/libreborn/patch.h b/libreborn/include/libreborn/patch.h index a4587a1..13ef6a0 100644 --- a/libreborn/include/libreborn/patch.h +++ b/libreborn/include/libreborn/patch.h @@ -15,7 +15,7 @@ void _overwrite_calls(const char *file, int line, void *start, void *target); #define overwrite_calls(start, target) _overwrite_calls(__FILE__, __LINE__, start, target); void _overwrite_calls_within(const char *file, int line, void *from, void *to, void *start, void *target); -#define overwrite_calls_within(from, to, start, target) _overwrite_calls(__FILE__, __LINE__, from, to, start, target); +#define overwrite_calls_within(from, to, start, target) _overwrite_calls_within(__FILE__, __LINE__, from, to, start, target); void *extract_from_bl_instruction(unsigned char *from); diff --git a/libreborn/include/libreborn/util.h b/libreborn/include/libreborn/util.h index 46e9d8f..b63e86b 100644 --- a/libreborn/include/libreborn/util.h +++ b/libreborn/include/libreborn/util.h @@ -50,6 +50,25 @@ const char *reborn_get_version(); int reborn_is_headless(); int reborn_is_server(); +// Customize VTable +#define CUSTOM_VTABLE(name, parent) \ + static void _setup_##name##_vtable(parent##_vtable *vtable); \ + static parent##_vtable *get_##name##_vtable() { \ + static parent##_vtable *vtable = NULL; \ + /* Allocate VTable */ \ + if (vtable == NULL) { \ + /* Init */ \ + vtable = dup_##parent##_vtable(parent##_vtable_base); \ + ALLOC_CHECK(vtable); \ + /* Setup */ \ + _setup_##name##_vtable(vtable); \ + } \ + /* Return */ \ + return vtable; \ + } \ + /* User-Defined Setup Code */ \ + static void _setup_##name##_vtable(parent##_vtable *vtable) + #ifdef __cplusplus } #endif diff --git a/libreborn/src/util/cp437.cpp b/libreborn/src/util/cp437.cpp index 8dd0e81..bb9062f 100644 --- a/libreborn/src/util/cp437.cpp +++ b/libreborn/src/util/cp437.cpp @@ -16,7 +16,7 @@ static std::string to_utf8(const std::u32string &s) { // Minecraft-Flavored CP437 #define CP437_CHARACTERS 256 static const std::string cp437_characters_map[CP437_CHARACTERS] = { - "\0", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "\n", "♂", "♀", "\r", "♫", "☼", + "\0", "☺", "☻", "♥", "♦", "♣", "♠", "•", "◘", "○", "\n", "♂", "♀", "♪", "♫", "☼", "►", "◄", "↕", "‼", "¶", "§", "▬", "↨", "↑", "↓", "→", "←", "∟", "↔", "▲", "▼", " ", "!", "\"", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "-", ".", "/", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ":", ";", "<", "=", ">", "?", diff --git a/libreborn/src/util/string.c b/libreborn/src/util/string.c index bf08000..e9e713e 100644 --- a/libreborn/src/util/string.c +++ b/libreborn/src/util/string.c @@ -14,7 +14,7 @@ void sanitize_string(char **str, int max_length, unsigned int allow_newlines) { // Loop Through Message if (!allow_newlines) { for (int i = 0; i < length; i++) { - if ((*str)[i] == '\n' || (*str)[i] == '\r') { + if ((*str)[i] == '\n') { // Replace Newline (*str)[i] = ' '; } diff --git a/media-layer/core/src/media.c b/media-layer/core/src/media.c index bfe12cf..759c01e 100644 --- a/media-layer/core/src/media.c +++ b/media-layer/core/src/media.c @@ -123,6 +123,8 @@ static SDLKey glfw_key_to_sdl_key(int key) { return SDLK_RETURN; case GLFW_KEY_BACKSPACE: return SDLK_BACKSPACE; + case GLFW_KEY_DELETE: + return SDLK_DELETE; // Fullscreen case GLFW_KEY_F11: return SDLK_F11; diff --git a/media-layer/include/SDL/SDL_keysym.h b/media-layer/include/SDL/SDL_keysym.h index a6397c5..e4ef34e 100644 --- a/media-layer/include/SDL/SDL_keysym.h +++ b/media-layer/include/SDL/SDL_keysym.h @@ -28,6 +28,7 @@ typedef enum { SDLK_s = 115, SDLK_t = 116, SDLK_w = 119, + SDLK_DELETE = 127, SDLK_UP = 273, SDLK_DOWN = 274, SDLK_RIGHT = 275, diff --git a/mods/CMakeLists.txt b/mods/CMakeLists.txt index 24bee06..78149df 100644 --- a/mods/CMakeLists.txt +++ b/mods/CMakeLists.txt @@ -15,7 +15,7 @@ set(SRC src/version/version.cpp # chat src/chat/chat.cpp - src/chat/ui.c + src/chat/ui.cpp # creative src/creative/creative.cpp # game-mode @@ -97,6 +97,10 @@ else() src/screenshot/screenshot.c # textures src/textures/textures.cpp + src/textures/lava.cpp + # text-input-box + src/text-input-box/TextInputBox.cpp + src/text-input-box/TextInputScreen.cpp ) endif() diff --git a/mods/include/mods/chat/chat.h b/mods/include/mods/chat/chat.h index e9d4ad8..3ff276c 100644 --- a/mods/include/mods/chat/chat.h +++ b/mods/include/mods/chat/chat.h @@ -15,7 +15,6 @@ extern "C" { #ifndef MCPI_SERVER_MODE void chat_open(); -unsigned int chat_get_counter(); #endif // Override using the HOOK() macro to provide customized chat behavior. diff --git a/mods/include/mods/misc/misc.h b/mods/include/mods/misc/misc.h index 6fe20c1..dedaca8 100644 --- a/mods/include/mods/misc/misc.h +++ b/mods/include/mods/misc/misc.h @@ -29,6 +29,8 @@ void Level_saveLevelData_injection(Level *level); // Use this instead of directly calling Gui::addMessage(), it has proper logging! void misc_add_message(Gui *gui, const char *text); +extern bool is_in_chat; + #ifdef __cplusplus } #endif diff --git a/mods/include/mods/text-input-box/TextInputBox.h b/mods/include/mods/text-input-box/TextInputBox.h new file mode 100644 index 0000000..2f3410b --- /dev/null +++ b/mods/include/mods/text-input-box/TextInputBox.h @@ -0,0 +1,35 @@ +#pragma once + +#include + +struct TextInputBox { + GuiComponent super; + + int m_ID; + int m_xPos; + int m_yPos; + int m_width; + int m_height; + std::string m_placeholder; + std::string m_text; + bool m_bFocused; + bool m_bEnabled; + bool m_bCursorOn; + int m_insertHead; + int m_lastFlashed; + Font *m_pFont; + int m_maxLength; + + void setSize(int x, int y, int width = 200, int height = 12); + void init(Font *pFont); + void setEnabled(bool bEnabled); + void keyPressed(int key); + void charPressed(int chr); + void render(); + void tick(); + void setFocused(bool b); + void onClick(int x, int y); + bool clicked(int x, int y); + + static TextInputBox *create(int id, const std::string &placeholder = "", const std::string &text = ""); +}; diff --git a/mods/include/mods/text-input-box/TextInputScreen.h b/mods/include/mods/text-input-box/TextInputScreen.h new file mode 100644 index 0000000..c3c5ada --- /dev/null +++ b/mods/include/mods/text-input-box/TextInputScreen.h @@ -0,0 +1,12 @@ +#pragma once + +#include + +#include + +struct TextInputScreen { + Screen super; + std::vector *m_textInputs; + + static void setup(Screen_vtable *vtable); +}; diff --git a/mods/src/atlas/README.md b/mods/src/atlas/README.md index eb0bb9e..0de8aec 100644 --- a/mods/src/atlas/README.md +++ b/mods/src/atlas/README.md @@ -1,2 +1,2 @@ -# ``atlas`` Mod -This mod allows disabling the ``gui_blocks`` atlas. +# `atlas` Mod +This mod allows disabling the `gui_blocks` atlas. diff --git a/mods/src/benchmark/README.md b/mods/src/benchmark/README.md index f4a6712..de7b659 100644 --- a/mods/src/benchmark/README.md +++ b/mods/src/benchmark/README.md @@ -1,2 +1,2 @@ -# ``benchmark`` Mod +# `benchmark` Mod This mod contain a simple game benchmark. diff --git a/mods/src/bucket/README.md b/mods/src/bucket/README.md index 5a8ddd8..fa0ff42 100644 --- a/mods/src/bucket/README.md +++ b/mods/src/bucket/README.md @@ -1,2 +1,2 @@ -# ``bucket`` Mod +# `bucket` Mod This mod adds buckets. diff --git a/mods/src/bucket/bucket.cpp b/mods/src/bucket/bucket.cpp index 504a525..0f7c90e 100644 --- a/mods/src/bucket/bucket.cpp +++ b/mods/src/bucket/bucket.cpp @@ -170,25 +170,16 @@ static ItemInstance *BucketItem_getCraftingRemainingItem(FoodItem *item, ItemIns } // Bucket VTable -static FoodItem_vtable *get_bucket_vtable() { - static FoodItem_vtable *vtable = NULL; - if (vtable == NULL) { - // Init - vtable = dup_FoodItem_vtable(FoodItem_vtable_base); - ALLOC_CHECK(vtable); - - // Modify - vtable->getDescriptionId = BucketItem_getDescriptionId; - vtable->getIcon = BucketItem_getIcon; - vtable->useOn = BucketItem_useOn; - vtable->getUseDuration = BucketItem_getUseDuration; - vtable->useTimeDepleted = BucketItem_useTimeDepleted; - vtable->getUseAnimation = BucketItem_getUseAnimation; - vtable->isFood = BucketItem_isFood; - vtable->use = BucketItem_use; - vtable->getCraftingRemainingItem = BucketItem_getCraftingRemainingItem; - } - return vtable; +CUSTOM_VTABLE(bucket, FoodItem) { + vtable->getDescriptionId = BucketItem_getDescriptionId; + vtable->getIcon = BucketItem_getIcon; + vtable->useOn = BucketItem_useOn; + vtable->getUseDuration = BucketItem_getUseDuration; + vtable->useTimeDepleted = BucketItem_useTimeDepleted; + vtable->getUseAnimation = BucketItem_getUseAnimation; + vtable->isFood = BucketItem_isFood; + vtable->use = BucketItem_use; + vtable->getCraftingRemainingItem = BucketItem_getCraftingRemainingItem; } // Create Items diff --git a/mods/src/cake/cake.cpp b/mods/src/cake/cake.cpp index 8461c8a..e922975 100644 --- a/mods/src/cake/cake.cpp +++ b/mods/src/cake/cake.cpp @@ -28,7 +28,7 @@ static int Cake_getTexture2(__attribute__((unused)) Tile *tile, int face) { return 122; } -static int Cake_getTexture3(__attribute__((unused)) Tile *tile, Level *level, int x, int y, int z, int face) { +static int Cake_getTexture3(__attribute__((unused)) Tile *tile, LevelSource *level, int x, int y, int z, int face) { // Eaten face if (face == 3) { int data = level->vtable->getData(level, x, y, z); @@ -86,7 +86,7 @@ static AABB *Cake_getAABB(Tile *tile, Level *level, int x, int y, int z) { return aabb; } -static void Cake_updateShape(Tile *tile, Level *level, int x, int y, int z) { +static void Cake_updateShape(Tile *tile, LevelSource *level, int x, int y, int z) { // Set cake int data = level->vtable->getData(level, x, y, z); if (data >= 6) data = 0; diff --git a/mods/src/camera/README.md b/mods/src/camera/README.md index af39ab3..e4f66f6 100644 --- a/mods/src/camera/README.md +++ b/mods/src/camera/README.md @@ -1,2 +1,2 @@ -# ``camera`` Mod +# `camera` Mod This mod fixes the Camera's renderer so that it is no longer invisible. diff --git a/mods/src/chat/README.md b/mods/src/chat/README.md index ca486cd..8398132 100644 --- a/mods/src/chat/README.md +++ b/mods/src/chat/README.md @@ -1,2 +1,2 @@ -# ``chat`` Mod +# `chat` Mod This mod implements a chat system. diff --git a/mods/src/chat/chat-internal.h b/mods/src/chat/chat-internal.h index 436d6b4..293c6a0 100644 --- a/mods/src/chat/chat-internal.h +++ b/mods/src/chat/chat-internal.h @@ -6,9 +6,12 @@ extern "C" { #endif -__attribute__((visibility("internal"))) extern int _chat_enabled; #ifndef MCPI_SERVER_MODE -__attribute__((visibility("internal"))) void _chat_queue_message(char *message); +__attribute__((visibility("internal"))) void _chat_queue_message(const char *message); +#endif + +#ifndef MCPI_HEADLESS_MODE +__attribute__((visibility("internal"))) void _init_chat_ui(); #endif #ifdef __cplusplus diff --git a/mods/src/chat/chat.cpp b/mods/src/chat/chat.cpp index 37bc6a4..1fef0d4 100644 --- a/mods/src/chat/chat.cpp +++ b/mods/src/chat/chat.cpp @@ -5,9 +5,6 @@ #include #include #include -#ifndef MCPI_HEADLESS_MODE -#include -#endif #include #ifndef MCPI_HEADLESS_MODE @@ -22,9 +19,6 @@ #include "chat-internal.h" #include -// Store If Chat is Enabled -int _chat_enabled = 0; - // Message Limitations #define MAX_CHAT_MESSAGE_LENGTH 512 @@ -95,45 +89,27 @@ static void ServerSideNetworkHandler_handle_ChatPacket_injection(ServerSideNetwo #ifndef MCPI_HEADLESS_MODE // Message Queue -static pthread_mutex_t queue_mutex = PTHREAD_MUTEX_INITIALIZER; static std::vector queue; // Add To Queue -void _chat_queue_message(char *message) { - // Lock - pthread_mutex_lock(&queue_mutex); +void _chat_queue_message(const char *message) { // Add - std::string str; - str.append(message); + std::string str = message; queue.push_back(str); - // Unlock - pthread_mutex_unlock(&queue_mutex); } // Empty Queue unsigned int old_chat_counter = 0; static void send_queued_messages(Minecraft *minecraft) { - // Lock - pthread_mutex_lock(&queue_mutex); - // If Message Was Submitted, No Other Chat Windows Are Open, And The Game Is Not Paused, Then Re-Lock Cursor - unsigned int new_chat_counter = chat_get_counter(); - if (old_chat_counter > new_chat_counter && new_chat_counter == 0) { - // Unlock UI - media_set_interactable(1); - } - old_chat_counter = new_chat_counter; // Loop for (unsigned int i = 0; i < queue.size(); i++) { send_api_chat_command(minecraft, (char *) queue[i].c_str()); } queue.clear(); - // Unlock - pthread_mutex_unlock(&queue_mutex); } #endif // Init void init_chat() { - _chat_enabled = feature_has("Implement Chat", server_enabled); - if (_chat_enabled) { + if (feature_has("Implement Chat", server_enabled)) { // Disable Original ChatPacket Loopback unsigned char disable_chat_packet_loopback_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" patch((void *) 0x6b490, disable_chat_packet_loopback_patch); @@ -141,9 +117,11 @@ void init_chat() { overwrite_call((void *) 0x6b518, (void *) CommandServer_parse_CommandServer_dispatchPacket_injection); // Re-Broadcast ChatPacket patch_address(ServerSideNetworkHandler_handle_ChatPacket_vtable_addr, (void *) ServerSideNetworkHandler_handle_ChatPacket_injection); - // Send Messages On Input Tick #ifndef MCPI_HEADLESS_MODE + // Send Messages On Input Tick input_run_on_tick(send_queued_messages); + // Init UI + _init_chat_ui(); #endif } } diff --git a/mods/src/chat/ui.c b/mods/src/chat/ui.c deleted file mode 100644 index 04c14da..0000000 --- a/mods/src/chat/ui.c +++ /dev/null @@ -1,83 +0,0 @@ -// Config Needs To Load First -#include - -// Chat UI Code Is Useless In Headless Mode -#ifndef MCPI_HEADLESS_MODE - -#include -#include -#include -#include - -#include - -#include "chat-internal.h" -#include - -// Count Chat Windows -static pthread_mutex_t chat_counter_lock = PTHREAD_MUTEX_INITIALIZER; -static volatile unsigned int chat_counter = 0; -unsigned int chat_get_counter() { - return chat_counter; -} - -// Chat Thread -#define DIALOG_TITLE "Chat" -static void *chat_thread(__attribute__((unused)) void *nop) { - // Open - int return_code; - const char *command[] = { - "zenity", - "--title", DIALOG_TITLE, - "--name", MCPI_APP_ID, - "--entry", - "--text", "Enter Chat Message:", - NULL - }; - char *output = run_command(command, &return_code, NULL); - // Handle Message - if (output != NULL) { - // Check Return Code - if (is_exit_status_success(return_code)) { - // Remove Ending Newline - int length = strlen(output); - if (output[length - 1] == '\n') { - output[length - 1] = '\0'; - } - length = strlen(output); - // Don't Allow Empty Strings - if (length > 0) { - // Submit - char *safe_output = to_cp437(output); - _chat_queue_message(safe_output); - free(safe_output); - } - } - // Free Output - free(output); - } - // Update Counter - pthread_mutex_lock(&chat_counter_lock); - chat_counter--; - pthread_mutex_unlock(&chat_counter_lock); - // Return - return NULL; -} - -// Create Chat Thead -void chat_open() { - if (_chat_enabled) { - // Lock UI - media_set_interactable(0); - - // Update Counter - pthread_mutex_lock(&chat_counter_lock); - chat_counter++; - pthread_mutex_unlock(&chat_counter_lock); - // Start Thread - pthread_t thread; - pthread_create(&thread, NULL, chat_thread, NULL); - } -} - -#endif diff --git a/mods/src/chat/ui.cpp b/mods/src/chat/ui.cpp new file mode 100644 index 0000000..c7d6000 --- /dev/null +++ b/mods/src/chat/ui.cpp @@ -0,0 +1,137 @@ +// Config Needs To Load First +#include + +// Chat UI Code Is Useless In Headless Mode +#ifndef MCPI_HEADLESS_MODE + +#include "chat-internal.h" +#include +#include +#include + +// Structure +struct ChatScreen { + TextInputScreen super; + TextInputBox *chat; + Button *send; +}; +CUSTOM_VTABLE(chat_screen, Screen) { + TextInputScreen::setup(vtable); + // Init + static Screen_init_t original_init = vtable->init; + vtable->init = [](Screen *super) { + original_init(super); + ChatScreen *self = (ChatScreen *) super; + // Text Input + self->chat = TextInputBox::create(1); + self->super.m_textInputs->push_back(self->chat); + self->chat->init(super->font); + self->chat->setFocused(true); + // Send Button + if (Minecraft_isTouchscreen(super->minecraft)) { + self->send = (Button *) new Touch_TButton; + } else { + self->send = new Button; + } + ALLOC_CHECK(self->send); + int send_id = 2; + std::string send_text = "Send"; + if (Minecraft_isTouchscreen(super->minecraft)) { + Touch_TButton_constructor((Touch_TButton *) self->send, send_id, &send_text); + } else { + Button_constructor(self->send, send_id, &send_text); + } + super->rendered_buttons.push_back(self->send); + super->selectable_buttons.push_back(self->send); + // Hide Chat Messages + is_in_chat = true; + }; + // Removal + static Screen_removed_t original_removed = vtable->removed; + vtable->removed = [](Screen *super) { + original_removed(super); + is_in_chat = false; + ChatScreen *self = (ChatScreen *) super; + delete self->chat; + self->send->vtable->destructor_deleting(self->send); + }; + // Rendering + static Screen_render_t original_render = vtable->render; + vtable->render = [](Screen *super, int x, int y, float param_1) { + // Background + super->vtable->renderBackground(super); + // Render Chat + Gui_renderChatMessages(&super->minecraft->gui, super->height, 20, true, super->font); + // Call Original Method + original_render(super, x, y, param_1); + }; + // Positioning + vtable->setupPositions = [](Screen *super) { + Screen_setupPositions_non_virtual(super); + ChatScreen *self = (ChatScreen *) super; + self->send->height = 20; + self->send->width = 40; + int x = 0; + int y = super->height - self->send->height; + int width = super->width - self->send->width; + self->chat->setSize(x, y, width, self->send->height); + self->send->y = super->height - self->send->height; + self->send->x = x + width; + }; + // Key Presses + static Screen_keyPressed_t original_keyPressed = vtable->keyPressed; + vtable->keyPressed = [](Screen *super, int key) { + // Handle Enter + ChatScreen *self = (ChatScreen *) super; + if (key == 0x0d && self->chat->m_bFocused) { + if (self->chat->m_text.length() > 0) { + _chat_queue_message(self->chat->m_text.c_str()); + } + Minecraft_setScreen(super->minecraft, NULL); + } + // Call Original Method + original_keyPressed(super, key); + }; + // Button Click + vtable->buttonClicked = [](Screen *super, Button *button) { + ChatScreen *self = (ChatScreen *) super; + if (button == self->send) { + // Send + self->chat->setFocused(true); + super->vtable->keyPressed(super, 0x0d); + } else { + // Call Original Method + Screen_buttonClicked_non_virtual(super, button); + } + }; +} +static Screen *create_chat_screen() { + // Construct + ChatScreen *screen = new ChatScreen; + ALLOC_CHECK(screen); + Screen_constructor(&screen->super.super); + + // Set VTable + screen->super.super.vtable = get_chat_screen_vtable(); + + // Return + return (Screen *) screen; +} + +// Open Screen +static bool open_chat_screen = false; +void chat_open() { + open_chat_screen = true; +} + +// Init +void _init_chat_ui() { + misc_run_on_tick([](Minecraft *minecraft) { + if (open_chat_screen && Minecraft_isLevelGenerated(minecraft) && minecraft->screen == NULL) { + Minecraft_setScreen(minecraft, create_chat_screen()); + } + open_chat_screen = false; + }); +} + +#endif diff --git a/mods/src/compat/README.md b/mods/src/compat/README.md index 3eaf3c5..3fe8e4b 100644 --- a/mods/src/compat/README.md +++ b/mods/src/compat/README.md @@ -1,2 +1,2 @@ -# ``compat`` Mod +# `compat` Mod This utility mod sends keyboard input to other mods. It also patches out all EGL and X11 calls. diff --git a/mods/src/compat/compat.c b/mods/src/compat/compat.c index 9e4e831..aa8f351 100644 --- a/mods/src/compat/compat.c +++ b/mods/src/compat/compat.c @@ -70,12 +70,7 @@ HOOK(SDL_PollEvent, int, (SDL_Event *event)) { input_third_person(); handled = 1; } else if (event->key.keysym.sym == SDLK_t) { - // Only When In-Game With No Other Chat Windows Open - if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON && chat_get_counter() == 0) { - // Open Chat - chat_open(); - } - // Mark Handled + chat_open(); handled = 1; } else if (event->key.keysym.sym == SDLK_ESCAPE) { // Treat Escape As Back Button Press (This Fixes Issues With Signs) diff --git a/mods/src/creative/README.md b/mods/src/creative/README.md index b65fe72..2132086 100644 --- a/mods/src/creative/README.md +++ b/mods/src/creative/README.md @@ -1,2 +1,2 @@ -# ``creative`` Mod +# `creative` Mod This mod adds an optional feature flag to add more items to the Creative Mode inventory. diff --git a/mods/src/death/README.md b/mods/src/death/README.md index 30302fc..e51226b 100644 --- a/mods/src/death/README.md +++ b/mods/src/death/README.md @@ -1,2 +1,2 @@ -# ``death`` Mod +# `death` Mod This mod implements death messages. diff --git a/mods/src/feature/README.md b/mods/src/feature/README.md index f653377..2761995 100644 --- a/mods/src/feature/README.md +++ b/mods/src/feature/README.md @@ -1,2 +1,2 @@ -# ``feature`` Mod +# `feature` Mod This utility mod handles feature flags. diff --git a/mods/src/game-mode/README.md b/mods/src/game-mode/README.md index eaaf2ac..43ab6aa 100644 --- a/mods/src/game-mode/README.md +++ b/mods/src/game-mode/README.md @@ -1,2 +1,2 @@ -# ``game-mode`` Mod +# `game-mode` Mod This mod implements Survival Mode and dynamic game-mode switching. diff --git a/mods/src/home/README.md b/mods/src/home/README.md index cd96f65..54102ed 100644 --- a/mods/src/home/README.md +++ b/mods/src/home/README.md @@ -1,4 +1,4 @@ -# ``home`` Mod +# `home` Mod This utility mod handles changing the location where world data is stored. This is so it doesn't conflict with Minecraft: Java Edition. -Normally, it changes it to ``~/.minecraft-pi``, but in server mode it changes it to the launch directory. +Normally, it changes it to `~/.minecraft-pi`, but in server mode it changes it to the launch directory. diff --git a/mods/src/init/README.md b/mods/src/init/README.md index 15eb4d6..688c869 100644 --- a/mods/src/init/README.md +++ b/mods/src/init/README.md @@ -1,2 +1,2 @@ -# ``init`` Mod +# `init` Mod This utility mod handles initializing the other mods in the correct order. diff --git a/mods/src/input/README.md b/mods/src/input/README.md index b2ab763..c0d75e1 100644 --- a/mods/src/input/README.md +++ b/mods/src/input/README.md @@ -1,10 +1,10 @@ -# ``input`` Mod +# `input` Mod This mod fixes various input-related bugs, including: * Bows being broken. * The cursor interacting with the toolbar while the it is locked. * Being unable to attack mobs. -* The ``ESC`` key not behaving as expected. +* The `ESC` key not behaving as expected. It also adds various features, including: * Hide GUI and third person toggle keys. -* Dropping items with ``Q``. +* Dropping items with `Q`. diff --git a/mods/src/input/misc.c b/mods/src/input/misc.c index d63f310..1dc74f6 100644 --- a/mods/src/input/misc.c +++ b/mods/src/input/misc.c @@ -80,7 +80,8 @@ static void _handle_mouse_grab(Minecraft *minecraft) { // Block UI Interaction When Mouse Is Locked static bool Gui_tickItemDrop_Minecraft_isCreativeMode_call_injection(Minecraft *minecraft) { - if (!enable_misc || SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF) { + bool is_in_game = minecraft->screen == NULL || minecraft->screen->vtable == (Screen_vtable *) Touch_IngameBlockSelectionScreen_vtable_base; + if (!enable_misc || (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF && is_in_game)) { // Call Original Method return creative_is_restricted() && Minecraft_isCreativeMode(minecraft); } else { diff --git a/mods/src/misc/README.md b/mods/src/misc/README.md index 882a7b6..620d2b2 100644 --- a/mods/src/misc/README.md +++ b/mods/src/misc/README.md @@ -1,4 +1,4 @@ -# ``misc`` Mod +# `misc` Mod This mod has several miscellaneous mods that are too small to be their own mod, including: * Rendering text above the hotbar when an item is selected. * Sanitizing player usernames for invalid characters. diff --git a/mods/src/misc/misc.c b/mods/src/misc/misc.c index 9bf5ff9..1ffcedc 100644 --- a/mods/src/misc/misc.c +++ b/mods/src/misc/misc.c @@ -65,6 +65,7 @@ static void Gui_renderBubbles_GuiComponent_blit_injection(Gui *component, int32_ // Additional GUI Rendering static int hide_chat_messages = 0; +bool is_in_chat = 0; static int render_selected_item_text = 0; static void Gui_renderChatMessages_injection(Gui *gui, int32_t y_offset, uint32_t max_messages, bool disable_fading, Font *font) { // Handle Classic HUD @@ -76,7 +77,7 @@ static void Gui_renderChatMessages_injection(Gui *gui, int32_t y_offset, uint32_ } // Call Original Method - if (!hide_chat_messages) { + if (!hide_chat_messages && !is_in_chat) { Gui_renderChatMessages(gui, y_offset, max_messages, disable_fading, font); } @@ -489,7 +490,7 @@ static ContainerMenu *ContainerMenu_injection(ContainerMenu *container_menu, Con // Return return container_menu; } -static unsigned char *ContainerMenu_destructor_injection(ContainerMenu *container_menu) { +static ContainerMenu *ContainerMenu_destructor_injection(ContainerMenu *container_menu) { // Play Animation Container *container = container_menu->container; ChestTileEntity *tile_entity = (ChestTileEntity *) (((unsigned char *) container) - offsetof(ChestTileEntity, container)); @@ -499,7 +500,7 @@ static unsigned char *ContainerMenu_destructor_injection(ContainerMenu *containe } // Call Original Method - return ContainerMenu_destructor_non_virtual(container_menu); + return ContainerMenu_destructor_complete_non_virtual(container_menu); } #ifndef MCPI_HEADLESS_MODE @@ -558,6 +559,18 @@ static void Player_stopUsingItem_injection(Player *self) { Player_stopUsingItem(self); } +// Java Light Ramp +static void Dimension_updateLightRamp_injection(Dimension *self) { + // https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/world/level/Dimension.cpp#L92-L105 + for (int i = 0; i <= 15; i++) { + float f1 = 1.0f - (((float) i) / 15.0f); + self->light_ramp[i] = ((1.0f - f1) / (f1 * 3.0f + 1.0f)) * (1.0f - 0.1f) + 0.1f; + // Default Light Ramp: + // float fVar4 = 1.0 - ((float) i * 0.0625); + // self->light_ramp[i] = ((1.0 - fVar4) / (fVar4 * 3.0 + 1.0)) * 0.95 + 0.15; + } +} + // Init static void nop() { } @@ -720,8 +733,8 @@ void init_misc() { // Animation overwrite_calls((void *) ContainerMenu_constructor, (void *) ContainerMenu_injection); - overwrite_calls((void *) ContainerMenu_destructor_non_virtual, (void *) ContainerMenu_destructor_injection); - patch_address(ContainerMenu_destructor_vtable_addr, (void *) ContainerMenu_destructor_injection); + overwrite_calls((void *) ContainerMenu_destructor_complete_non_virtual, (void *) ContainerMenu_destructor_injection); + patch_address(ContainerMenu_destructor_complete_vtable_addr, (void *) ContainerMenu_destructor_injection); } patch_address((void *) 0x115b48, (void *) ChestTileEntity_shouldSave_injection); @@ -739,10 +752,17 @@ void init_misc() { overwrite_calls((void *) FurnaceTileEntity_getLitProgress, (void *) FurnaceTileEntity_getLitProgress_injection); // Send the full level, not only changed chunks - unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" - patch((void *) 0x717c4, nop_patch); - unsigned char mov_r3_ff[4] = {0xff, 0x30, 0xa0, 0xe3}; // "mov r3, #0xff" - patch((void *) 0x7178c, mov_r3_ff); + if (feature_has("Send Full Level When Hosting Game", server_enabled)) { + unsigned char nop_patch[4] = {0x00, 0xf0, 0x20, 0xe3}; // "nop" + patch((void *) 0x717c4, nop_patch); + unsigned char mov_r3_ff[4] = {0xff, 0x30, 0xa0, 0xe3}; // "mov r3, #0xff" + patch((void *) 0x7178c, mov_r3_ff); + } + + // Java Light Ramp + if (feature_has("Use Java Beta 1.3 Light Ramp", server_disabled)) { + overwrite((void *) Dimension_updateLightRamp_non_virtual, (void *) Dimension_updateLightRamp_injection); + } // Fix used items transferring durability overwrite_calls((void *) Player_startUsingItem, (void *) Player_startUsingItem_injection); diff --git a/mods/src/multiplayer/README.md b/mods/src/multiplayer/README.md index d07d003..1bf8907 100644 --- a/mods/src/multiplayer/README.md +++ b/mods/src/multiplayer/README.md @@ -1,4 +1,4 @@ -# ``multiplayer`` Mod +# `multiplayer` Mod This mod implements connecting to external (non-LAN) servers. This mod is client mode only. -It is controlled by the ``~/.minecraft-pi/servers.txt`` file. +It is controlled by the `~/.minecraft-pi/servers.txt` file. diff --git a/mods/src/options/README.md b/mods/src/options/README.md index d414035..3e0db82 100644 --- a/mods/src/options/README.md +++ b/mods/src/options/README.md @@ -1,4 +1,4 @@ -# ``options`` Mod +# `options` Mod This mod allows various options to be configured, including: * Mob Spawning * The Render Distance diff --git a/mods/src/override/README.md b/mods/src/override/README.md index f4e23c3..1081d1a 100644 --- a/mods/src/override/README.md +++ b/mods/src/override/README.md @@ -1,4 +1,4 @@ -# ``override`` Mod +# `override` Mod This mod allows built-in assets to be overriden by placing replacements in an override folder. -``/data/images/terrain.png`` would be overriden by ``/overrides/images/terrain.png``. +`/data/images/terrain.png` would be overriden by `/overrides/images/terrain.png`. diff --git a/mods/src/readdir/README.md b/mods/src/readdir/README.md index 5207a4e..ee92b12 100644 --- a/mods/src/readdir/README.md +++ b/mods/src/readdir/README.md @@ -1,2 +1,2 @@ -# ``readdir`` Mod +# `readdir` Mod This mod fixes a small bug where the contents of directories cannot be read on a 64-bit filesystem. This notably broke the world selection screen. diff --git a/mods/src/screenshot/README.md b/mods/src/screenshot/README.md index 41d40d6..a08b77e 100644 --- a/mods/src/screenshot/README.md +++ b/mods/src/screenshot/README.md @@ -1,2 +1,2 @@ -# ``screenshot`` Mod +# `screenshot` Mod This mod implements the core screenshot logic. diff --git a/mods/src/server/README.md b/mods/src/server/README.md index 14c4a9e..ce80428 100644 --- a/mods/src/server/README.md +++ b/mods/src/server/README.md @@ -1,2 +1,2 @@ -# ``server`` Mod +# `server` Mod This mod contains most of the code involved in converting MCPI into a server. diff --git a/mods/src/sign/README.md b/mods/src/sign/README.md index 1f70660..fbdf13b 100644 --- a/mods/src/sign/README.md +++ b/mods/src/sign/README.md @@ -1,2 +1,2 @@ -# ``sign`` Mod +# `sign` Mod This mod fixes sign placement. diff --git a/mods/src/sign/sign.cpp b/mods/src/sign/sign.cpp index ea1e013..11cbac8 100644 --- a/mods/src/sign/sign.cpp +++ b/mods/src/sign/sign.cpp @@ -12,7 +12,13 @@ // Handle Backspace static int32_t sdl_key_to_minecraft_key_injection(int32_t sdl_key) { if (sdl_key == SDLK_BACKSPACE) { - return 8; + return 0x8; + } else if (sdl_key == SDLK_DELETE) { + return 0x2e; + } else if (sdl_key == SDLK_LEFT) { + return 0x25; + } else if (sdl_key == SDLK_RIGHT) { + return 0x27; } else { // Call Original Method return Common_sdl_key_to_minecraft_key(sdl_key); @@ -31,37 +37,17 @@ static void LocalPlayer_openTextEdit_injection(LocalPlayer *local_player, TileEn } // Store Text Input -std::vector input; void sign_key_press(char key) { - input.push_back(key); -} -static void clear_input(__attribute__((unused)) Minecraft *minecraft) { - input.clear(); -} - -// Handle Text Input -static void TextEditScreen_updateEvents_injection(TextEditScreen *screen) { - // Call Original Method - TextEditScreen_updateEvents_non_virtual(screen); - - if (!screen->passthrough_input) { - for (char key : input) { - // Handle Normal Key - screen->vtable->keyboardNewChar(screen, key); - } - } - clear_input(NULL); + Keyboard__inputText.push_back(key); } // Init void init_sign() { if (feature_has("Fix Sign Placement", server_disabled)) { - // Handle Backspace - overwrite_calls((void *) Common_sdl_key_to_minecraft_key, (void *) sdl_key_to_minecraft_key_injection); // Fix Signs patch_address(LocalPlayer_openTextEdit_vtable_addr, (void *) LocalPlayer_openTextEdit_injection); - patch_address(TextEditScreen_updateEvents_vtable_addr, (void *) TextEditScreen_updateEvents_injection); - // Clear Input On Input Tick - input_run_on_tick(clear_input); } + + // Handle Backspace + overwrite_calls((void *) Common_sdl_key_to_minecraft_key, (void *) sdl_key_to_minecraft_key_injection); } diff --git a/mods/src/skin/README.md b/mods/src/skin/README.md index 61ef293..5564421 100644 --- a/mods/src/skin/README.md +++ b/mods/src/skin/README.md @@ -1,2 +1,2 @@ -# ``skin`` Mod +# `skin` Mod This mod adds custom skin loading. diff --git a/mods/src/sound/README.md b/mods/src/sound/README.md index 7c8d082..ae75619 100644 --- a/mods/src/sound/README.md +++ b/mods/src/sound/README.md @@ -1,2 +1,2 @@ -# ``sound`` Mod +# `sound` Mod This mod implements a sound engine. diff --git a/mods/src/test/README.md b/mods/src/test/README.md index 20c0c77..ad4b1dc 100644 --- a/mods/src/test/README.md +++ b/mods/src/test/README.md @@ -1,2 +1,2 @@ -# ``test`` Mod +# `test` Mod This utility mod tests that the system is configured correctly before starting. diff --git a/mods/src/text-input-box/README.md b/mods/src/text-input-box/README.md new file mode 100644 index 0000000..bba603a --- /dev/null +++ b/mods/src/text-input-box/README.md @@ -0,0 +1,2 @@ +# `text-input-box` Mod +This mod implements a GUI component for text input. This is ported from [ReMinecraftPE](https://github.com/ReMinecraftPE/mcpe/blob/d7a8b6baecf8b3b050538abdbc976f690312aa2d/source/client/gui/components/TextInputBox.cpp). diff --git a/mods/src/text-input-box/TextInputBox.cpp b/mods/src/text-input-box/TextInputBox.cpp new file mode 100644 index 0000000..e91ede1 --- /dev/null +++ b/mods/src/text-input-box/TextInputBox.cpp @@ -0,0 +1,200 @@ +#include + +#include + +TextInputBox *TextInputBox::create(int id, const std::string &placeholder, const std::string &text) { + // Construct + TextInputBox *self = new TextInputBox; + GuiComponent_constructor(&self->super); + + // Setup + self->m_ID = id; + self->m_xPos = 0; + self->m_yPos = 0; + self->m_width = 0; + self->m_height = 0; + self->m_placeholder = placeholder; + self->m_text = text; + self->m_bFocused = false; + self->m_bEnabled = true; + self->m_bCursorOn = true; + self->m_insertHead = 0; + self->m_lastFlashed = 0; + self->m_pFont = nullptr; + self->m_maxLength = -1; + + // Return + return self; +} + +void TextInputBox::setSize(int x, int y, int width, int height) { + m_xPos = x; + m_yPos = y; + m_width = width; + m_height = height; +} + +void TextInputBox::init(Font *pFont) { + m_pFont = pFont; +} + +void TextInputBox::setEnabled(bool bEnabled) { + m_bEnabled = bEnabled; +} + +void TextInputBox::keyPressed(int key) { + if (!m_bFocused) { + return; + } + + switch (key) { + case 0x8: { + // Backspace + if (m_text.empty()) { + return; + } + if (m_insertHead <= 0) { + return; + } + if (m_insertHead > int(m_text.size())) { + m_insertHead = int(m_text.size()); + } + m_text.erase(m_text.begin() + m_insertHead - 1, m_text.begin() + m_insertHead); + m_insertHead--; + break; + } + case 0x2e: { + // Delete + if (m_text.empty()) { + return; + } + if (m_insertHead < 0) { + return; + } + if (m_insertHead >= int(m_text.size())) { + return; + } + m_text.erase(m_text.begin() + m_insertHead, m_text.begin() + m_insertHead + 1); + break; + } + case 0x25: { + // Left + m_insertHead--; + if (m_insertHead < 0) { + m_insertHead = 0; + } + break; + } + case 0x27: { + // Right + m_insertHead++; + if (!m_text.empty()) { + if (m_insertHead > int(m_text.size())) { + m_insertHead = int(m_text.size()); + } + } else { + m_insertHead = 0; + } + break; + } + case 0x0d: { + // Enter + m_bFocused = false; + break; + } + } +} + +void TextInputBox::tick() { + if (!m_lastFlashed) { + m_lastFlashed = Common_getTimeMs(); + } + + if (m_bFocused) { + if (Common_getTimeMs() > m_lastFlashed + 500) { + m_lastFlashed += 500; + m_bCursorOn ^= 1; + } + } else { + m_bCursorOn = false; + } +} + +void TextInputBox::setFocused(bool b) { + if (m_bFocused == b) { + return; + } + + m_bFocused = b; + if (b) { + m_lastFlashed = Common_getTimeMs(); + m_bCursorOn = true; + m_insertHead = int(m_text.size()); + } +} + +void TextInputBox::onClick(int x, int y) { + setFocused(clicked(x, y)); +} + +static int PADDING = 5; +void TextInputBox::charPressed(int k) { + if (!m_bFocused) { + return; + } + + // note: the width will increase by the same amount no matter where K is appended + std::string test_str = m_text + char(k); + if (m_maxLength != -1 && int(test_str.length()) > m_maxLength) { + return; + } + int width = Font_width(m_pFont, &test_str); + if (width < (m_width - PADDING)) { + m_text.insert(m_text.begin() + m_insertHead, k); + m_insertHead++; + } +} + +void TextInputBox::render() { + GuiComponent_fill(&super, m_xPos, m_yPos, m_xPos + m_width, m_yPos + m_height, 0xFFAAAAAA); + GuiComponent_fill(&super, m_xPos + 1, m_yPos + 1, m_xPos + m_width - 1, m_yPos + m_height - 1, 0xFF000000); + + int textYPos = (m_height - 8) / 2; + + if (m_text.empty()) { + GuiComponent_drawString(&super, m_pFont, &m_placeholder, m_xPos + PADDING, m_yPos + textYPos, 0x404040); + } else { + GuiComponent_drawString(&super, m_pFont, &m_text, m_xPos + PADDING, m_yPos + textYPos, 0xFFFFFF); + } + + if (m_bCursorOn) { + int xPos = 5; + + std::string substr = m_text.substr(0, m_insertHead); + xPos += Font_width(m_pFont, &substr); + + std::string str = "_"; + GuiComponent_drawString(&super, m_pFont, &str, m_xPos + xPos, m_yPos + textYPos + 2, 0xFFFFFF); + } +} + +bool TextInputBox::clicked(int xPos, int yPos) { + if (!m_bEnabled) { + return false; + } + + if (xPos < m_xPos) { + return false; + } + if (yPos < m_yPos) { + return false; + } + if (xPos >= m_xPos + m_width) { + return false; + } + if (yPos >= m_yPos + m_height) { + return false; + } + + return true; +} diff --git a/mods/src/text-input-box/TextInputScreen.cpp b/mods/src/text-input-box/TextInputScreen.cpp new file mode 100644 index 0000000..9fc9e19 --- /dev/null +++ b/mods/src/text-input-box/TextInputScreen.cpp @@ -0,0 +1,50 @@ +#include + +#include + +// VTable +void TextInputScreen::setup(Screen_vtable *vtable) { + vtable->keyPressed = [](Screen *super2, int key) { + Screen_keyPressed_non_virtual(super2, key); + TextInputScreen *self = (TextInputScreen *) super2; + for (int i = 0; i < int(self->m_textInputs->size()); i++) { + TextInputBox *textInput = (*self->m_textInputs)[i]; + textInput->keyPressed(key); + } + }; + vtable->keyboardNewChar = [](Screen *super2, char key) { + Screen_keyboardNewChar_non_virtual(super2, key); + TextInputScreen *self = (TextInputScreen *) super2; + for (int i = 0; i < int(self->m_textInputs->size()); i++) { + TextInputBox *textInput = (*self->m_textInputs)[i]; + textInput->charPressed(key); + } + }; + vtable->mouseClicked = [](Screen *super2, int x, int y, int param_1) { + Screen_mouseClicked_non_virtual(super2, x, y, param_1); + TextInputScreen *self = (TextInputScreen *) super2; + for (int i = 0; i < int(self->m_textInputs->size()); i++) { + TextInputBox *textInput = (*self->m_textInputs)[i]; + textInput->onClick(x, y); + } + }; + vtable->render = [](Screen *super2, int x, int y, float param_1) { + Screen_render_non_virtual(super2, x, y, param_1); + TextInputScreen *self = (TextInputScreen *) super2; + for (int i = 0; i < int(self->m_textInputs->size()); i++) { + TextInputBox *textInput = (*self->m_textInputs)[i]; + textInput->tick(); + textInput->render(); + } + }; + vtable->init = [](Screen *super2) { + Screen_init_non_virtual(super2); + TextInputScreen *self = (TextInputScreen *) super2; + self->m_textInputs = new std::vector; + }; + vtable->removed = [](Screen *super2) { + Screen_removed_non_virtual(super2); + TextInputScreen *self = (TextInputScreen *) super2; + delete self->m_textInputs; + }; +} diff --git a/mods/src/textures/README.md b/mods/src/textures/README.md index 49ffa51..27d31ba 100644 --- a/mods/src/textures/README.md +++ b/mods/src/textures/README.md @@ -1,2 +1,2 @@ -# ``textures`` Mod +# `textures` Mod This mod enables the animated water texture. diff --git a/mods/src/textures/lava.cpp b/mods/src/textures/lava.cpp new file mode 100644 index 0000000..edc416d --- /dev/null +++ b/mods/src/textures/lava.cpp @@ -0,0 +1,245 @@ +#include + +#include +#include + +#include "textures-internal.h" + +// Lava texture code was originally decompield by @iProgramMC as part of ReMinecraftPE. +// See: https://github.com/ReMinecraftPE/mcpe + +// Structures +struct LavaTexture { + DynamicTexture super; + int field_14; + int field_18; + float m_data1[256]; + float m_data2[256]; + float m_data3[256]; + float m_data4[256]; +}; +struct LavaSideTexture { + DynamicTexture super; + int field_14; + int field_18; + int field_1C; + float m_data1[256]; + float m_data2[256]; + float m_data3[256]; + float m_data4[256]; +}; +struct FireTexture { + DynamicTexture super; + float m_data1[320]; + float m_data2[320]; + Random m_random; +}; + +// LavaTexture +CUSTOM_VTABLE(lava_texture, DynamicTexture) { + vtable->tick = [](DynamicTexture *super) { + LavaTexture *self = (LavaTexture *) super; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + float f = 0.0F; + int ax = int(Mth_sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f); + int ay = int(Mth_sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f); + for (int bx = x - 1; bx <= x + 1; bx++) { + for (int by = y - 1; by <= y + 1; by++) { + int k2 = (bx + ay) & 0xf; + int i3 = (by + ax) & 0xf; + f += self->m_data1[k2 + i3 * 16]; + } + } + self->m_data2[x + y * 16] = f / 10.0f + ((self->m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + self->m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f; + self->m_data3[x + y * 16] += self->m_data4[x + y * 16] * 0.01f; + if (self->m_data3[x + y * 16] < 0.0f) { + self->m_data3[x + y * 16] = 0.0f; + } + self->m_data4[x + y * 16] -= 0.06f; + if (Mth_random() < 0.005f) { + self->m_data4[x + y * 16] = 1.5f; + } + } + } + std::swap(self->m_data1, self->m_data2); + for (int i = 0; i < 256; i++) { + float x1 = self->m_data1[i] * 2.0f; + if (x1 > 1.0f) { + x1 = 1.0f; + } + if (x1 < 0.0f) { + x1 = 0.0f; + } + self->super.pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); + self->super.pixels[i * 4 + 1] = int(255.0f * x1 * x1); + self->super.pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); + self->super.pixels[i * 4 + 3] = 255; + } + }; +} +static DynamicTexture *create_lava_texture() { + // Construct + LavaTexture *texture = new LavaTexture; + ALLOC_CHECK(texture); + DynamicTexture_constructor(&texture->super, Tile_lava->texture); + // Set VTable + texture->super.vtable = get_lava_texture_vtable(); + // Setup + texture->field_14 = 0; + texture->field_18 = 0; + for (int i = 0; i < 256; i++) { + texture->m_data1[i] = 0.0f; + texture->m_data2[i] = 0.0f; + texture->m_data3[i] = 0.0f; + texture->m_data4[i] = 0.0f; + } + // Return + return (DynamicTexture *) texture; +} + +// LavaSideTexture +CUSTOM_VTABLE(lava_side_texture, DynamicTexture) { + vtable->tick = [](DynamicTexture *super) { + LavaSideTexture *self = (LavaSideTexture *) super; + self->field_1C++; + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + float f = 0.0F; + int ax = int(Mth_sin((float(x) * float(M_PI) * 2) / 16.0f) * 1.2f); + int ay = int(Mth_sin((float(y) * float(M_PI) * 2) / 16.0f) * 1.2f); + for (int bx = x - 1; bx <= x + 1; bx++) { + for (int by = y - 1; by <= y + 1; by++) { + int k2 = (bx + ay) & 0xf; + int i3 = (by + ax) & 0xf; + f += self->m_data1[k2 + i3 * 16]; + } + } + self->m_data2[x + y * 16] = f / 10.0f + ((self->m_data3[(x & 0xf) + ((y + 0) & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + (y & 0xf) * 16] + self->m_data3[((x + 1) & 0xf) + ((y + 1) & 0xf) * 16] + self->m_data3[(x & 0xf) + ((y + 1) & 0xf) * 16]) * 0.25f) * 0.8f; + self->m_data3[x + y * 16] += self->m_data4[x + y * 16] * 0.01f; + if (self->m_data3[x + y * 16] < 0.0f) { + self->m_data3[x + y * 16] = 0.0f; + } + self->m_data4[x + y * 16] -= 0.06f; + if (Mth_random() < 0.005f) { + self->m_data4[x + y * 16] = 1.5f; + } + } + } + std::swap(self->m_data1, self->m_data2); + for (int i = 0; i < 256; i++) { + float x1 = self->m_data1[(i - 16 * (self->field_1C / 3)) & 0xFF] * 2.0f; + if (x1 > 1.0f) { + x1 = 1.0f; + } + if (x1 < 0.0f) { + x1 = 0.0f; + } + self->super.pixels[i * 4 + 0] = int(155.0f + 100.0f * x1); + self->super.pixels[i * 4 + 1] = int(255.0f * x1 * x1); + self->super.pixels[i * 4 + 2] = int(128.0f * x1 * x1 * x1 * x1); + self->super.pixels[i * 4 + 3] = 255; + } + }; +} +static DynamicTexture *create_lava_side_texture() { + // Construct + LavaSideTexture *texture = new LavaSideTexture; + ALLOC_CHECK(texture); + DynamicTexture_constructor(&texture->super, Tile_lava->texture + 1); + // Set VTable + texture->super.vtable = get_lava_side_texture_vtable(); + // Setup + texture->field_14 = 0; + texture->field_18 = 0; + texture->field_1C = 0; + texture->super.texture_size = 2; + for (int i = 0; i < 256; i++) { + texture->m_data1[i] = 0.0f; + texture->m_data2[i] = 0.0f; + texture->m_data3[i] = 0.0f; + texture->m_data4[i] = 0.0f; + } + // Return + return (DynamicTexture *) texture; +} + +// FireTexture +CUSTOM_VTABLE(fire_texture, DynamicTexture) { + vtable->tick = [](DynamicTexture *super) { + FireTexture *self = (FireTexture *) super; + for (int i = 0; i < 16; i++) { + for (int j = 0; j < 20; j++) { + int l = 18; + float f1 = self->m_data1[i + ((j + 1) % 20) * 16] * l; + for (int i1 = i - 1; i1 <= i + 1; i1++) { + for (int k1 = j; k1 <= j + 1; k1++) { + int i2 = i1; + int k2 = k1; + if (i2 >= 0 && k2 >= 0 && i2 < 16 && k2 < 20) + { + f1 += self->m_data1[i2 + k2 * 16]; + } + l++; + } + } + self->m_data2[i + j * 16] = f1 / 25.2f; + if (j >= 19) { + union { + uint32_t x; + uint8_t b[4]; + } a; + a.x = Random_genrand_int32(&self->m_random); + self->m_data2[i + j * 16] = 0.2f + (((a.b[3] / 256.0f) * 0.1f) + ((((a.b[0] / 256.0f) * (a.b[1] / 256.0f)) * (a.b[2] / 256.0f)) * 4.0f)); + } + } + } + std::swap(self->m_data1, self->m_data2); + for (int i = 0; i < 256; i++) { + float x = self->m_data1[i] * 1.8f; + if (x > 1.0f) { + x = 1.0f; + } + if (x < 0.0f) { + x = 0.0f; + } + self->super.pixels[4 * i + 0] = int(x * 155.0f + 100.0f); + self->super.pixels[4 * i + 1] = int(x * x * 255.0f); + self->super.pixels[4 * i + 2] = int(x * x * x * x * x * x * x * x * x * x * 255.0f); + self->super.pixels[4 * i + 3] = x >= 0.5f ? 255 : 0; + } + }; +} +static DynamicTexture *create_fire_texture(int a2) { + // Construct + FireTexture *texture = new FireTexture; + ALLOC_CHECK(texture); + DynamicTexture_constructor(&texture->super, Tile_fire->texture + (16 * a2)); + // Set VTable + texture->super.vtable = get_fire_texture_vtable(); + // Setup Random + int seed = Common_getTimeMs(); + texture->m_random.seed = seed; + texture->m_random.param_1 = 0x271; + texture->m_random.param_2 = false; + texture->m_random.param_3 = 0; + // Return + return (DynamicTexture *) texture; +} + +// Add Textures +static void Textures_addDynamicTexture_injection(Textures *textures, DynamicTexture *dynamic_texture) { + // Call Original Method + Textures_addDynamicTexture(textures, dynamic_texture); + + // Add Lava + Textures_addDynamicTexture(textures, create_lava_texture()); + Textures_addDynamicTexture(textures, create_lava_side_texture()); + Textures_addDynamicTexture(textures, create_fire_texture(0)); + Textures_addDynamicTexture(textures, create_fire_texture(1)); +} + +// Init +void _init_textures_lava() { + overwrite_call((void *) 0x170b4, (void *) Textures_addDynamicTexture_injection); +} diff --git a/mods/src/textures/textures-internal.h b/mods/src/textures/textures-internal.h new file mode 100644 index 0000000..d195604 --- /dev/null +++ b/mods/src/textures/textures-internal.h @@ -0,0 +1,3 @@ +#pragma once + +__attribute__((visibility("internal"))) void _init_textures_lava(); diff --git a/mods/src/textures/textures.cpp b/mods/src/textures/textures.cpp index 091edd3..297fcd6 100644 --- a/mods/src/textures/textures.cpp +++ b/mods/src/textures/textures.cpp @@ -11,6 +11,7 @@ #include #include #include +#include "textures-internal.h" #include "stb_image.h" @@ -213,8 +214,10 @@ static Texture AppPlatform_linux_loadTexture_injection(__attribute__((unused)) A // Init void init_textures() { // Tick Dynamic Textures (Animated Water) - if (feature_has("Animated Water", server_disabled)) { + if (feature_has("Animated Water & Lava", server_disabled)) { misc_run_on_tick(Minecraft_tick_injection); + // Animated Lava + _init_textures_lava(); } // Scale Animated Textures diff --git a/mods/src/title-screen/README.md b/mods/src/title-screen/README.md index 5ecab2d..b7dbf1d 100644 --- a/mods/src/title-screen/README.md +++ b/mods/src/title-screen/README.md @@ -1,2 +1,2 @@ -# ``title-screen`` Mod +# `title-screen` Mod This mod improves the title screen. diff --git a/mods/src/touch/README.md b/mods/src/touch/README.md index 69403e1..62ce485 100644 --- a/mods/src/touch/README.md +++ b/mods/src/touch/README.md @@ -1,2 +1,2 @@ -# ``touch`` Mod +# `touch` Mod This mod allows the hidden touch GUI to be activated. diff --git a/mods/src/version/README.md b/mods/src/version/README.md index b53ccc7..7d0726f 100644 --- a/mods/src/version/README.md +++ b/mods/src/version/README.md @@ -1,2 +1,2 @@ -# ``version`` Mod +# `version` Mod This mod adds the MCPI-Reborn version to the start screen. diff --git a/symbols/CMakeLists.txt b/symbols/CMakeLists.txt index 6b2ff44..7822775 100644 --- a/symbols/CMakeLists.txt +++ b/symbols/CMakeLists.txt @@ -75,6 +75,8 @@ set(SRC src/level/LevelData.def src/level/LevelSettings.def src/level/ServerLevel.def + src/level/Dimension.def + src/level/MultiPlayerLevel.def src/item/ItemRenderer.def src/item/ItemInHandRenderer.def src/item/AuxDataTileItem.def @@ -107,10 +109,11 @@ set(SRC src/gui/components/OptionsPane.def src/gui/components/GuiComponent.def src/gui/components/Button.def - src/gui/components/Gui.def + src/gui/Gui.def src/gui/components/IntRectangle.def src/gui/components/RectangleArea.def src/gui/components/ScrollingPane.def + src/gui/components/Touch_TButton.def src/app-platform/AppPlatform.def src/app-platform/AppPlatform_linux.def src/app-platform/AppPlatform_readAssetFile_return_value.def @@ -136,16 +139,19 @@ set(SRC src/misc/Vec3.def src/misc/HitResult.def src/misc/PerfRenderer.def - src/misc/Texture.def - src/misc/Textures.def + src/textures/Texture.def + src/textures/Textures.def + src/textures/DynamicTexture.def src/misc/SoundEngine.def src/misc/Common.def src/misc/Config.def src/misc/Random.def + src/misc/Mth.def src/input/IMoveInput.def src/input/IBuildInput.def src/input/MouseBuildInput.def src/input/Mouse.def + src/input/Keyboard.def src/recipes/FurnaceRecipes.def src/recipes/Recipes.def src/recipes/Recipes_Type.def diff --git a/symbols/src/game/Minecraft.def b/symbols/src/game/Minecraft.def index b6440d8..637a92f 100644 --- a/symbols/src/game/Minecraft.def +++ b/symbols/src/game/Minecraft.def @@ -40,6 +40,7 @@ property HitResult hit_result = 0xc38; property int progress = 0xc60; property PerfRenderer *perf_renderer = 0xcbc; property CommandServer *command_server = 0xcc0; +property Font *font = 0x16c; // Smooth Lighting static-property bool useAmbientOcclusion = 0x136b90; diff --git a/symbols/src/gui/Font.def b/symbols/src/gui/Font.def index e69de29..2914ff8 100644 --- a/symbols/src/gui/Font.def +++ b/symbols/src/gui/Font.def @@ -0,0 +1 @@ +method int width(std::string *string) = 0x24d4c; diff --git a/symbols/src/gui/components/Gui.def b/symbols/src/gui/Gui.def similarity index 100% rename from symbols/src/gui/components/Gui.def rename to symbols/src/gui/Gui.def index 4162907..fc7595a 100644 --- a/symbols/src/gui/components/Gui.def +++ b/symbols/src/gui/Gui.def @@ -1,7 +1,7 @@ -size 0xa74; - extends GuiComponent; +size 0xa74; + method void tick() = 0x27778; method void handleClick(int param_2, int param_3, int param_4) = 0x2599c; method void renderOnSelectItemNameText(int param_1, Font *font, int param_2) = 0x26aec; diff --git a/symbols/src/gui/components/Button.def b/symbols/src/gui/components/Button.def index 5ff1315..cf2bb7b 100644 --- a/symbols/src/gui/components/Button.def +++ b/symbols/src/gui/components/Button.def @@ -1,5 +1,6 @@ extends GuiComponent; +size 0x28; constructor (int param_1, std::string *text) = 0x1bc54; method int hovered(Minecraft *minecraft, int click_x, int click_y) = 0x1be2c; diff --git a/symbols/src/gui/components/GuiComponent.def b/symbols/src/gui/components/GuiComponent.def index d245806..93a801c 100644 --- a/symbols/src/gui/components/GuiComponent.def +++ b/symbols/src/gui/components/GuiComponent.def @@ -1,3 +1,9 @@ +size 0x8; +constructor () = 0x28204; + +vtable 0x1039b0; + method void blit(int x_dest, int y_dest, int x_src, int y_src, int width_dest, int height_dest, int width_src, int height_src) = 0x282a4; method void drawCenteredString(Font *font, std::string *text, int x, int y, int color) = 0x2821c; -method void fill(int x1, int y1, int x2, int y2, uint color) = 0x285f0; \ No newline at end of file +method void drawString(Font *font, std::string *text, int x, int y, int color) = 0x28284; +method void fill(int x1, int y1, int x2, int y2, uint color) = 0x285f0; diff --git a/symbols/src/gui/components/OptionButton.def b/symbols/src/gui/components/OptionButton.def index 750cfcd..abb60b2 100644 --- a/symbols/src/gui/components/OptionButton.def +++ b/symbols/src/gui/components/OptionButton.def @@ -3,3 +3,5 @@ extends ImageButton; constructor (Options_Option *option) = 0x1c968; method void updateImage(Options *options) = 0x1ca58; + +property Options_Option *option = 0x54; diff --git a/symbols/src/gui/components/Touch_TButton.def b/symbols/src/gui/components/Touch_TButton.def new file mode 100644 index 0000000..fc73c64 --- /dev/null +++ b/symbols/src/gui/components/Touch_TButton.def @@ -0,0 +1,4 @@ +extends Button; + +size 0x28; +constructor (int param_1, std::string *text) = 0x1c168; diff --git a/symbols/src/gui/screens/Screen.def b/symbols/src/gui/screens/Screen.def index c02051d..79c3818 100644 --- a/symbols/src/gui/screens/Screen.def +++ b/symbols/src/gui/screens/Screen.def @@ -1,15 +1,23 @@ extends GuiComponent; +size 0x48; +constructor () = 0x29028; + +vtable-size 0x74; vtable 0x1039d8; virtual-method void updateEvents() = 0x14; virtual-method void keyboardNewChar(char key) = 0x70; virtual-method void keyPressed(int key) = 0x6c; -virtual-method void render(int param_1, int param_2, float param_3) = 0x8; +virtual-method void render(int x, int y, float param_1) = 0x8; virtual-method bool handleBackEvent(bool param_1) = 0x24; virtual-method void tick() = 0x28; virtual-method void buttonClicked(Button *button) = 0x60; virtual-method void init() = 0xc; +virtual-method void mouseClicked(int x, int y, int param_1) = 0x64; +virtual-method void removed() = 0x2c; +virtual-method void renderBackground() = 0x30; +virtual-method void setupPositions() = 0x10; property Minecraft *minecraft = 0x14; property std::vector