Merge pull request #1361 from ddinan/toggle-block-list

Add ToggleBlockList CPE
This commit is contained in:
D 2025-05-11 16:50:59 +10:00 committed by GitHub
commit 9284db5b65
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 21 additions and 1 deletions

View File

@ -33,6 +33,7 @@
#include "InputHandler.h"
#include "HeldBlockRenderer.h"
#include "Options.h"
#include "Screens.h"
struct _ProtocolData Protocol;
@ -1605,6 +1606,17 @@ static void CPE_CinematicGui(cc_uint8* data) {
Gui.BarSize = (float)barSize / UInt16_MaxValue;
}
static void CPE_ToggleBlockList(cc_uint8* data) {
cc_bool closeBlockList = data[0];
if (closeBlockList) {
InventoryScreen_Hide();
}
else {
InventoryScreen_Show();
}
}
static void CPE_Reset(void) {
cpe_serverExtensionsCount = 0; cpe_pingTicks = 0;
CPEExtensions_Reset();
@ -1649,6 +1661,7 @@ static void CPE_Reset(void) {
Net_Set(OPCODE_ENTITY_TELEPORT_EXT, CPE_ExtEntityTeleport, 11);
Net_Set(OPCODE_LIGHTING_MODE, CPE_LightingMode, 3);
Net_Set(OPCODE_CINEMATIC_GUI, CPE_CinematicGui, 10);
Net_Set(OPCODE_TOGGLE_BLOCK_LIST, CPE_ToggleBlockList, 2);
}
static cc_uint8* CPE_Tick(cc_uint8* data) {

View File

@ -40,7 +40,7 @@ enum OPCODE_ {
OPCODE_DEFINE_MODEL, OPCODE_DEFINE_MODEL_PART, OPCODE_UNDEFINE_MODEL,
OPCODE_PLUGIN_MESSAGE, OPCODE_ENTITY_TELEPORT_EXT,
OPCODE_LIGHTING_MODE, OPCODE_CINEMATIC_GUI, OPCODE_NOTIFY_ACTION,
OPCODE_NOTIFY_POSITION_ACTION,
OPCODE_NOTIFY_POSITION_ACTION, OPCODE_TOGGLE_BLOCK_LIST,
OPCODE_COUNT
};

View File

@ -1819,6 +1819,12 @@ void InventoryScreen_Show(void) {
CPE_SendNotifyAction(NOTIFY_ACTION_BLOCK_LIST_TOGGLED, 1);
}
void InventoryScreen_Hide(void) {
struct InventoryScreen* s = &InventoryScreen;
Gui_Remove((struct Screen*)s);
CPE_SendNotifyAction(NOTIFY_ACTION_BLOCK_LIST_TOGGLED, 0);
}
/*########################################################################################################################*
*------------------------------------------------------LoadingScreen------------------------------------------------------*

View File

@ -27,6 +27,7 @@ void Screen_NullFunc(void* screen);
void Screen_NullUpdate(void* screen, float delta);
void InventoryScreen_Show(void);
void InventoryScreen_Hide(void);
void HUDScreen_Show(void);
void LoadingScreen_Show(const cc_string* title, const cc_string* message);
void GeneratingScreen_Show(void);