minecraft-pi-reborn/mods/src/input/crafting.cpp

31 lines
810 B
C++
Raw Permalink Normal View History

2022-10-07 04:06:50 +00:00
#include <libreborn/libreborn.h>
#include <symbols/minecraft.h>
#include "input-internal.h"
#include <mods/input/input.h>
#include <mods/creative/creative.h>
// Store Should Open Crafting Menu
static int should_open_crafting = 0;
void input_open_crafting() {
should_open_crafting = 1;
}
2024-01-06 11:30:23 +00:00
static void _handle_open_crafting(Minecraft *minecraft) {
2022-10-07 04:06:50 +00:00
if (should_open_crafting) {
should_open_crafting = 0;
// Set Screen
2024-01-07 08:23:43 +00:00
if (!creative_is_restricted() || !Minecraft_isCreativeMode(minecraft)) {
2024-05-17 04:36:28 +00:00
WorkbenchScreen *screen = new WorkbenchScreen;
2022-10-07 04:06:50 +00:00
ALLOC_CHECK(screen);
2024-05-15 09:02:19 +00:00
screen = screen->constructor(0);
minecraft->setScreen((Screen *) screen);
2022-10-07 04:06:50 +00:00
}
}
}
// Init
void _init_crafting() {
input_run_on_tick(_handle_open_crafting);
}