4jcraft/Minecraft.Client/UI/BeaconPowerButton.cpp
2026-03-29 15:52:35 -05:00

39 lines
1.3 KiB
C++

#include "../../Platform/stdafx.h"
#include "BeaconPowerButton.h"
#include "Screens/BeaconScreen.h"
#include "../../../Minecraft.World/Entities/MobEffect.h"
#include "../../../Minecraft.World/Headers/net.minecraft.locale.h"
#include "../Textures/Textures.h"
#include "Textures/ResourceLocation.h"
// 4jcraft: referenced from MCP 8.11 (JE 1.6.4)
#ifdef ENABLE_JAVA_GUIS
ResourceLocation GUI_INVENTORY_LOCATION = ResourceLocation(TN_GUI_INVENTORY);
#endif
BeaconPowerButton::BeaconPowerButton(BeaconScreen* screen, int id, int x, int y,
int effectId, int tier)
: AbstractBeaconButton(id, x, y) {
this->screen = screen;
this->effectId = effectId;
this->tier = tier;
#ifdef ENABLE_JAVA_GUIS
this->iconRes = &GUI_INVENTORY_LOCATION;
#endif
int statusIconIndex = MobEffect::javaId(effectId);
this->iconU = (statusIconIndex % 8) * 18;
this->iconV = 198 + (statusIconIndex / 8) * 18;
}
void BeaconPowerButton::renderTooltip(int xm, int ym) {
MobEffect* effect = MobEffect::effects[effectId];
if (!effect) return;
std::wstring name = app.GetString(effect->getDescriptionId());
if (tier >= 3 && effect->id != MobEffect::regeneration->id) {
name += L" II";
}
screen->renderTooltip(name, xm, ym);
}