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 "JavaMath.h"
3#include "com.mojang.nbt.h"
4#include "net.minecraft.world.level.h"
5#include "PrimedTnt.h"
6
7
8
9void PrimedTnt::_init()
10{
11 life = 0;
12
13 // Original Java Ctor
14 blocksBuilding = true;
15 setSize(0.98f, 0.98f);
16 heightOffset = bbHeight / 2.0f;
17
18 owner = weak_ptr<LivingEntity>();
19}
20
21PrimedTnt::PrimedTnt(Level *level) : Entity( level )
22{
23 // 4J Stu - This function call had to be moved here from the Entity ctor to ensure that
24 // the derived version of the function is called
25 this->defineSynchedData();
26
27 _init();
28}
29
30PrimedTnt::PrimedTnt(Level *level, double x, double y, double z, shared_ptr<LivingEntity> owner) : Entity( level )
31{
32 _init();
33
34 setPos(x, y, z);
35
36 float rot = (float) (Math::random() * PI * 2);
37 xd = -sin(rot) * 0.02f;
38 yd = +0.2f;
39 zd = -cos(rot) * 0.02f;
40
41 life = 80;
42
43 xo = x;
44 yo = y;
45 zo = z;
46
47 this->owner = weak_ptr<LivingEntity>(owner);
48}
49
50void PrimedTnt::defineSynchedData()
51{
52}
53
54bool PrimedTnt::makeStepSound()
55{
56 return false;
57}
58
59bool PrimedTnt::isPickable()
60{
61 return !removed;
62}
63
64void PrimedTnt::tick()
65{
66 xo = x;
67 yo = y;
68 zo = z;
69
70 yd -= 0.04f;
71 move(xd, yd, zd);
72 xd *= 0.98f;
73 yd *= 0.98f;
74 zd *= 0.98f;
75
76 if (onGround)
77 {
78 xd *= 0.7f;
79 zd *= 0.7f;
80 yd *= -0.5f;
81 }
82
83 if (life-- <= 0)
84 {
85 remove();
86 if (!level->isClientSide)
87 {
88 explode();
89 }
90 }
91 else
92 {
93 level->addParticle(eParticleType_smoke, x, y + 0.5f, z, 0, 0, 0);
94 }
95
96}
97
98
99void PrimedTnt::explode()
100{
101 float r = 4.0f;
102 level->explode(shared_from_this(), x, y, z, r, true);
103}
104
105
106void PrimedTnt::addAdditonalSaveData(CompoundTag *entityTag)
107{
108 entityTag->putByte(L"Fuse", (byte) life);
109}
110
111void PrimedTnt::readAdditionalSaveData(CompoundTag *tag)
112{
113 life = tag->getByte(L"Fuse");
114}
115
116float PrimedTnt::getShadowHeightOffs()
117{
118 return 0;
119}
120
121shared_ptr<LivingEntity> PrimedTnt::getOwner()
122{
123 return owner.lock();
124}