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.entity.projectile.h"
4#include "net.minecraft.world.item.h"
5#include "net.minecraft.world.level.h"
6#include "FireworksItem.h"
7
8const wstring FireworksItem::TAG_FIREWORKS = L"Fireworks";
9const wstring FireworksItem::TAG_EXPLOSION = L"Explosion";
10const wstring FireworksItem::TAG_EXPLOSIONS = L"Explosions";
11const wstring FireworksItem::TAG_FLIGHT = L"Flight";
12const wstring FireworksItem::TAG_E_TYPE = L"Type";
13const wstring FireworksItem::TAG_E_TRAIL = L"Trail";
14const wstring FireworksItem::TAG_E_FLICKER = L"Flicker";
15const wstring FireworksItem::TAG_E_COLORS = L"Colors";
16const wstring FireworksItem::TAG_E_FADECOLORS = L"FadeColors";
17
18FireworksItem::FireworksItem(int id) : Item(id)
19{
20}
21
22bool FireworksItem::useOn(shared_ptr<ItemInstance> instance, shared_ptr<Player> player, Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly)
23{
24 // 4J-JEV: Fix for xb1 #173493 - CU7: Content: UI: Missing tooltip for Firework Rocket.
25 if (bTestUseOnOnly) return true;
26
27 if (!level->isClientSide)
28 {
29 shared_ptr<FireworksRocketEntity> f = shared_ptr<FireworksRocketEntity>( new FireworksRocketEntity(level, x + clickX, y + clickY, z + clickZ, instance) );
30 level->addEntity(f);
31
32 if (!player->abilities.instabuild)
33 {
34 instance->count--;
35 }
36 return true;
37 }
38
39 return false;
40}
41
42void FireworksItem::appendHoverText(shared_ptr<ItemInstance> itemInstance, shared_ptr<Player> player, vector<HtmlString> *lines, bool advanced)
43{
44 if (!itemInstance->hasTag())
45 {
46 return;
47 }
48 CompoundTag *fireTag = itemInstance->getTag()->getCompound(TAG_FIREWORKS);
49 if (fireTag == NULL)
50 {
51 return;
52 }
53 if (fireTag->contains(TAG_FLIGHT))
54 {
55 lines->push_back(wstring(app.GetString(IDS_ITEM_FIREWORKS_FLIGHT)) + L" " + _toString<int>((fireTag->getByte(TAG_FLIGHT))));
56 }
57
58 ListTag<CompoundTag> *explosions = (ListTag<CompoundTag> *) fireTag->getList(TAG_EXPLOSIONS);
59 if (explosions != NULL && explosions->size() > 0)
60 {
61
62 for (int i = 0; i < explosions->size(); i++)
63 {
64 CompoundTag *expTag = explosions->get(i);
65
66 vector<HtmlString> eLines;
67 FireworksChargeItem::appendHoverText(expTag, &eLines);
68
69 if (eLines.size() > 0)
70 {
71 // Indent lines after first line
72 for (int i = 1; i < eLines.size(); i++)
73 {
74 eLines[i].indent = true;
75 }
76
77 lines->insert(lines->end(), eLines.begin(), eLines.end());
78 }
79 }
80 }
81}