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.damagesource.h"
3#include "net.minecraft.world.entity.h"
4#include "net.minecraft.world.entity.player.h"
5#include "net.minecraft.world.level.h"
6#include "net.minecraft.world.item.h"
7#include "net.minecraft.network.packet.h"
8#include "MinecartFurnace.h"
9
10MinecartFurnace::MinecartFurnace(Level *level) : Minecart(level)
11{
12 defineSynchedData();
13
14 fuel = 0;
15 xPush = zPush = 0.0f;
16}
17
18MinecartFurnace::MinecartFurnace(Level *level, double x, double y, double z) : Minecart(level, x, y, z)
19{
20 defineSynchedData();
21
22 fuel = 0;
23 xPush = zPush = 0.0f;
24}
25
26// 4J Added
27int MinecartFurnace::getContainerType()
28{
29 return ContainerOpenPacket::MINECART_HOPPER;
30}
31
32int MinecartFurnace::getType()
33{
34 return TYPE_FURNACE;
35}
36
37void MinecartFurnace::defineSynchedData()
38{
39 Minecart::defineSynchedData();
40 entityData->define(DATA_ID_FUEL, (byte) 0);
41}
42
43void MinecartFurnace::tick()
44{
45 Minecart::tick();
46
47 if (fuel > 0)
48 {
49 fuel--;
50 }
51 if (fuel <= 0)
52 {
53 xPush = zPush = 0;
54 }
55 setHasFuel(fuel > 0);
56
57 if (hasFuel() && random->nextInt(4) == 0)
58 {
59 level->addParticle(eParticleType_largesmoke, x, y + 0.8, z, 0, 0, 0);
60 }
61}
62
63void MinecartFurnace::destroy(DamageSource *source)
64{
65 Minecart::destroy(source);
66
67 if (!source->isExplosion())
68 {
69 spawnAtLocation(shared_ptr<ItemInstance>(new ItemInstance(Tile::furnace, 1)), 0);
70 }
71}
72
73void MinecartFurnace::moveAlongTrack(int xt, int yt, int zt, double maxSpeed, double slideSpeed, int tile, int data)
74{
75 Minecart::moveAlongTrack(xt, yt, zt, maxSpeed, slideSpeed, tile, data);
76
77 double sd = xPush * xPush + zPush * zPush;
78 if (sd > 0.01 * 0.01 && xd * xd + zd * zd > 0.001)
79 {
80 sd = Mth::sqrt(sd);
81 xPush /= sd;
82 zPush /= sd;
83
84 if (xPush * xd + zPush * zd < 0)
85 {
86 xPush = 0;
87 zPush = 0;
88 }
89 else
90 {
91 xPush = xd;
92 zPush = zd;
93 }
94 }
95}
96
97void MinecartFurnace::applyNaturalSlowdown()
98{
99 double sd = xPush * xPush + zPush * zPush;
100
101 if (sd > 0.01 * 0.01)
102 {
103 sd = Mth::sqrt(sd);
104 xPush /= sd;
105 zPush /= sd;
106 double speed = 0.05;
107 xd *= 0.8f;
108 yd *= 0;
109 zd *= 0.8f;
110 xd += xPush * speed;
111 zd += zPush * speed;
112 }
113 else
114 {
115 xd *= 0.98f;
116 yd *= 0;
117 zd *= 0.98f;
118 }
119
120 Minecart::applyNaturalSlowdown();
121}
122
123bool MinecartFurnace::interact(shared_ptr<Player> player)
124{
125 shared_ptr<ItemInstance> selected = player->inventory->getSelected();
126 if (selected != NULL && selected->id == Item::coal_Id)
127 {
128 if (!player->abilities.instabuild && --selected->count == 0) player->inventory->setItem(player->inventory->selected, nullptr);
129 fuel += SharedConstants::TICKS_PER_SECOND * 180;
130
131 }
132 xPush = x - player->x;
133 zPush = z - player->z;
134
135 return true;
136}
137
138void MinecartFurnace::addAdditonalSaveData(CompoundTag *base)
139{
140 Minecart::addAdditonalSaveData(base);
141 base->putDouble(L"PushX", xPush);
142 base->putDouble(L"PushZ", zPush);
143 base->putShort(L"Fuel", (short) fuel);
144}
145
146void MinecartFurnace::readAdditionalSaveData(CompoundTag *base)
147{
148 Minecart::readAdditionalSaveData(base);
149 xPush = base->getDouble(L"PushX");
150 zPush = base->getDouble(L"PushZ");
151 fuel = base->getShort(L"Fuel");
152}
153
154bool MinecartFurnace::hasFuel()
155{
156 return (entityData->getByte(DATA_ID_FUEL) & 1) != 0;
157}
158
159void MinecartFurnace::setHasFuel(bool fuel)
160{
161 if (fuel)
162 {
163 entityData->set(DATA_ID_FUEL, (byte) (entityData->getByte(DATA_ID_FUEL) | 1));
164 }
165 else
166 {
167 entityData->set(DATA_ID_FUEL, (byte) (entityData->getByte(DATA_ID_FUEL) & ~1));
168 }
169}
170
171Tile *MinecartFurnace::getDefaultDisplayTile()
172{
173 return Tile::furnace_lit;
174}
175
176int MinecartFurnace::getDefaultDisplayData()
177{
178 return 2;
179}