minecraft-pi-reborn/mods/src/camera/camera.cpp

49 lines
2.0 KiB
C++
Raw Normal View History

2021-01-27 21:26:19 +00:00
#include <libreborn/libreborn.h>
2021-09-12 03:18:12 +00:00
#include <symbols/minecraft.h>
2020-12-02 23:18:49 +00:00
2022-06-25 21:30:08 +00:00
#include <mods/feature/feature.h>
2022-07-13 20:46:33 +00:00
#include <mods/screenshot/screenshot.h>
2022-06-25 21:30:08 +00:00
#include <mods/home/home.h>
#include <mods/init/init.h>
2021-07-04 23:02:45 +00:00
2020-12-02 23:18:49 +00:00
// Take Screenshot Using TripodCamera
2021-06-17 21:32:24 +00:00
static void AppPlatform_linux_saveScreenshot_injection(__attribute__((unused)) unsigned char *app_platform, __attribute__((unused)) std::string const& path, __attribute__((unused)) int32_t width, __attribute__((unused)) int32_t height) {
2022-07-13 20:46:33 +00:00
#ifndef MCPI_HEADLESS_MODE
screenshot_take(home_get());
#endif
2020-12-02 23:18:49 +00:00
}
// Enable TripodCameraRenderer
static unsigned char *EntityRenderDispatcher_injection(unsigned char *dispatcher) {
// Call Original Method
(*EntityRenderDispatcher)(dispatcher);
// Register TripodCameraRenderer
2020-12-18 03:22:56 +00:00
unsigned char *renderer = (unsigned char *) ::operator new(TRIPOD_CAMERA_RENDERER_SIZE);
2021-02-16 17:26:40 +00:00
ALLOC_CHECK(renderer);
2020-12-02 23:18:49 +00:00
(*TripodCameraRenderer)(renderer);
(*EntityRenderDispatcher_assign)(dispatcher, (unsigned char) 0x5, renderer);
return dispatcher;
}
// Display Smoke From TripodCamera Higher
static void TripodCamera_tick_Level_addParticle_call_injection(unsigned char *level, std::string const& particle, float x, float y, float z, float deltaX, float deltaY, float deltaZ, int count) {
// Call Original Method
(*Level_addParticle)(level, particle, x, y + 0.5, z, deltaX, deltaY, deltaZ, count);
}
2021-07-04 23:02:45 +00:00
// Init
2020-12-02 23:18:49 +00:00
void init_camera() {
// Implement AppPlatform_linux::saveScreenshot So Cameras Work
patch_address(AppPlatform_linux_saveScreenshot_vtable_addr, (void *) AppPlatform_linux_saveScreenshot_injection);
2021-07-04 23:02:45 +00:00
// Fix Camera Rendering
2022-04-10 00:01:16 +00:00
if (feature_has("Fix Camera Rendering", server_disabled)) {
2021-07-04 23:02:45 +00:00
// Enable TripodCameraRenderer
overwrite_calls((void *) EntityRenderDispatcher, (void *) EntityRenderDispatcher_injection);
// Display Smoke From TripodCamera Higher
2021-12-01 02:25:04 +00:00
overwrite_call((void *) 0xbcf18, (void *) TripodCamera_tick_Level_addParticle_call_injection);
2021-07-04 23:02:45 +00:00
}
2021-06-17 21:32:24 +00:00
}