the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "net.minecraft.world.entity.player.h"
3#include "net.minecraft.world.level.h"
4#include "net.minecraft.world.level.tile.h"
5#include "net.minecraft.world.item.h"
6#include "net.minecraft.world.h"
7#include "ItemInstance.h"
8#include "RecordingItem.h"
9#include "GenericStats.h"
10
11unordered_map<wstring, RecordingItem *> RecordingItem::BY_NAME;
12
13RecordingItem::RecordingItem(int id, const wstring& recording) : Item(id), recording( recording )
14{
15 this->maxStackSize = 1;
16 BY_NAME[recording] = this;
17}
18
19Icon *RecordingItem::getIcon(int auxValue)
20{
21 return icon;
22}
23
24bool RecordingItem::useOn(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
25{
26 // 4J-PB - Adding a test only version to allow tooltips to be displayed
27 if (level->getTile(x, y, z) == Tile::jukebox_Id && level->getData(x, y, z) == 0)
28 {
29 if(!bTestUseOnOnly)
30 {
31 if (level->isClientSide) return true;
32
33 ((JukeboxTile *) Tile::jukebox)->setRecord(level, x, y, z, itemInstance);
34 level->levelEvent(nullptr, LevelEvent::SOUND_PLAY_RECORDING, x, y, z, id);
35 itemInstance->count--;
36
37 player->awardStat(
38 GenericStats::musicToMyEars(),
39 GenericStats::param_musicToMyEars(id)
40 );
41 }
42 return true;
43 }
44 return false;
45}
46
47void RecordingItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, vector<HtmlString> *lines, bool advanced)
48{
49 eMinecraftColour color = getRarity(shared_ptr<ItemInstance>())->color;
50
51 wchar_t text[256];
52 swprintf(text, 256, L"%ls %ls", L"C418 -", recording.c_str());
53
54 lines->push_back(HtmlString(text, color));
55}
56
57const Rarity *RecordingItem::getRarity(shared_ptr<ItemInstance> itemInstance)
58{
59 return (Rarity *)Rarity::rare;
60}
61
62void RecordingItem::registerIcons(IconRegister *iconRegister)
63{
64 icon = iconRegister->registerIcon(L"record_" + recording);
65}
66
67RecordingItem *RecordingItem::getByName(const wstring &name)
68{
69 AUTO_VAR(it,BY_NAME.find(name));
70 if(it != BY_NAME.end())
71 {
72 return it->second;
73 }
74 else
75 {
76 return NULL;
77 }
78}