feat(jui): re-enable and update TrapScreen

(Dispenser and Dropper GUI)
This commit is contained in:
Sally Knight 2026-03-26 17:28:29 +03:00 committed by Tropical
parent fbbf086f71
commit 975f716f9c
5 changed files with 28 additions and 11 deletions

View file

@ -683,9 +683,13 @@ bool LocalPlayer::openBeacon(std::shared_ptr<BeaconTileEntity> beacon) {
}
bool LocalPlayer::openTrap(std::shared_ptr<DispenserTileEntity> trap) {
#ifdef ENABLE_JAVA_GUIS
minecraft->setScreen(new TrapScreen(inventory, trap));
bool success = true;
#else
bool success = app.LoadTrapMenu(GetXboxPad(), inventory, trap);
if (success) ui.PlayUISFX(eSFX_Press);
// minecraft->setScreen(new TrapScreen(inventory, trap));
#endif
return success;
}

View file

@ -179,6 +179,7 @@ const wchar_t* Textures::preLoaded[TN_COUNT] = {
L"title/mclogo",
L"gui/horse",
L"gui/anvil",
L"gui/trap",
L"title/bg/panorama",
#endif
// L"item/christmas",

View file

@ -161,6 +161,7 @@ typedef enum _TEXTURE_NAME {
TN_TITLE_MCLOGO,
TN_GUI_HORSE,
TN_GUI_ANVIL,
TN_GUI_TRAP,
TN_TITLE_BG_PANORAMA,
#endif
// TN_TILE_XMAS_CHEST,

View file

@ -6,23 +6,29 @@
#include "../../../Minecraft.World/Blocks/TileEntities/DispenserTileEntity.h"
#include "../../../Minecraft.World/Headers/net.minecraft.world.h"
#ifdef ENABLE_JAVA_GUIS
ResourceLocation GUI_TRAP_LOCATION = ResourceLocation(TN_GUI_TRAP);
#endif
TrapScreen::TrapScreen(std::shared_ptr<Inventory> inventory,
std::shared_ptr<DispenserTileEntity> trap)
: AbstractContainerScreen(new TrapMenu(inventory, trap)) {}
: AbstractContainerScreen(new TrapMenu(inventory, trap)) {
this->trap = trap;
this->inventory = inventory;
}
void TrapScreen::renderLabels() {
font->draw(L"Dispenser", 16 + 4 + 40, 2 + 2 + 2, 0x404040);
font->draw(L"Inventory", 8, imageHeight - 96 + 2, 0x404040);
font->draw(trap->getName(), 16 + 4 + 40, 2 + 2 + 2, 0x404040);
font->draw(inventory->getName(), 8, imageHeight - 96 + 2, 0x404040);
}
void TrapScreen::renderBg(float a) {
// 4J Unused
#if 0
int tex = minecraft->textures->loadTexture(L"/gui/trap.png");
glColor4f(1, 1, 1, 1);
minecraft->textures->bind(tex);
int xo = (width - imageWidth) / 2;
int yo = (height - imageHeight) / 2;
this->blit(xo, yo, 0, 0, imageWidth, imageHeight);
#ifdef ENABLE_JAVA_GUIS
glColor4f(1, 1, 1, 1);
minecraft->textures->bindTexture(&GUI_TRAP_LOCATION);
int xo = (width - imageWidth) / 2;
int yo = (height - imageHeight) / 2;
this->blit(xo, yo, 0, 0, imageWidth, imageHeight);
#endif
}

View file

@ -1,4 +1,5 @@
#pragma once
#include <memory>
#include "AbstractContainerScreen.h"
class DispenserTileEntity;
class Inventory;
@ -11,4 +12,8 @@ public:
protected:
virtual void renderLabels();
virtual void renderBg(float a);
private:
std::shared_ptr<Inventory> inventory;
std::shared_ptr<DispenserTileEntity> trap;
};