mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-04-27 13:43:36 +00:00
66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
#include "../Platform/stdafx.h"
|
|
#include "../Headers/net.minecraft.world.entity.player.h"
|
|
#include "../Headers/net.minecraft.world.level.h"
|
|
#include "../Headers/net.minecraft.world.level.tile.h"
|
|
#include "../Headers/net.minecraft.world.h"
|
|
#include "ItemInstance.h"
|
|
#include "RecordingItem.h"
|
|
#include "../Stats/GenericStats.h"
|
|
|
|
RecordingItem::RecordingItem(int id, const std::wstring& recording)
|
|
: Item(id), recording(recording) {
|
|
this->maxStackSize = 1;
|
|
}
|
|
|
|
Icon* RecordingItem::getIcon(int auxValue) { return icon; }
|
|
|
|
bool RecordingItem::useOn(std::shared_ptr<ItemInstance> itemInstance,
|
|
std::shared_ptr<Player> player, Level* level, int x,
|
|
int y, int z, int face, float clickX, float clickY,
|
|
float clickZ, bool bTestUseOnOnly) {
|
|
// 4J-PB - Adding a test only version to allow tooltips to be displayed
|
|
if (level->getTile(x, y, z) == Tile::recordPlayer_Id &&
|
|
level->getData(x, y, z) == 0) {
|
|
if (!bTestUseOnOnly) {
|
|
if (level->isClientSide) return true;
|
|
|
|
((RecordPlayerTile*)Tile::recordPlayer)
|
|
->setRecord(level, x, y, z, id);
|
|
level->levelEvent(nullptr, LevelEvent::SOUND_PLAY_RECORDING, x, y,
|
|
z, id);
|
|
itemInstance->count--;
|
|
|
|
player->awardStat(GenericStats::musicToMyEars(),
|
|
GenericStats::param_musicToMyEars(id));
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void RecordingItem::appendHoverText(
|
|
std::shared_ptr<ItemInstance> itemInstance, std::shared_ptr<Player> player,
|
|
std::vector<std::wstring>* lines, bool advanced,
|
|
std::vector<std::wstring>& unformattedStrings) {
|
|
eMinecraftColour rarityColour =
|
|
getRarity(std::shared_ptr<ItemInstance>())->color;
|
|
int colour = app.GetHTMLColour(rarityColour);
|
|
wchar_t formatted[256];
|
|
|
|
swprintf(formatted, 256, L"<font color=\"#%08x\">%ls</font>", colour,
|
|
L"C418 - ", recording.c_str());
|
|
|
|
lines->push_back(formatted);
|
|
|
|
unformattedStrings.push_back(recording);
|
|
}
|
|
|
|
const Rarity* RecordingItem::getRarity(
|
|
std::shared_ptr<ItemInstance> itemInstance) {
|
|
return (Rarity*)Rarity::rare;
|
|
}
|
|
|
|
void RecordingItem::registerIcons(IconRegister* iconRegister) {
|
|
icon = iconRegister->registerIcon(L"record_" + recording);
|
|
}
|