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.h"
3#include "net.minecraft.world.entity.player.h"
4#include "net.minecraft.world.level.h"
5#include "net.minecraft.world.level.tile.entity.h"
6#include "net.minecraft.world.h"
7#include "net.minecraft.h"
8#include "EnderChestTile.h"
9
10EnderChestTile::EnderChestTile(int id) : BaseEntityTile(id, Material::stone, isSolidRender())
11{
12 updateDefaultShape();
13}
14
15// 4J Added override
16void EnderChestTile::updateDefaultShape()
17{
18 setShape(1 / 16.0f, 0, 1 / 16.0f, 15 / 16.0f, 14 / 16.0f, 15 / 16.0f);
19}
20
21bool EnderChestTile::isSolidRender(bool isServerLevel)
22{
23 return false;
24}
25
26bool EnderChestTile::isCubeShaped()
27{
28 return false;
29}
30
31int EnderChestTile::getRenderShape()
32{
33 return Tile::SHAPE_ENTITYTILE_ANIMATED;
34}
35
36int EnderChestTile::getResource(int data, Random *random, int playerBonusLevel)
37{
38 return Tile::obsidian_Id;
39}
40
41int EnderChestTile::getResourceCount(Random *random)
42{
43 return 8;
44}
45
46bool EnderChestTile::isSilkTouchable()
47{
48 return true;
49}
50
51void EnderChestTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
52{
53 int facing = 0;
54 int dir = (Mth::floor(by->yRot * 4 / (360) + 0.5f)) & 3;
55
56 if (dir == 0) facing = Facing::NORTH;
57 if (dir == 1) facing = Facing::EAST;
58 if (dir == 2) facing = Facing::SOUTH;
59 if (dir == 3) facing = Facing::WEST;
60
61 level->setData(x, y, z, facing, Tile::UPDATE_CLIENTS);
62}
63
64bool EnderChestTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly)
65{
66 shared_ptr<PlayerEnderChestContainer> container = player->getEnderChestInventory();
67 shared_ptr<EnderChestTileEntity> enderChest = dynamic_pointer_cast<EnderChestTileEntity>(level->getTileEntity(x, y, z));
68 if (container == NULL || enderChest == NULL) return true;
69
70 if (level->isSolidBlockingTile(x, y + 1, z)) return true;
71
72 if (level->isClientSide)
73 {
74 return true;
75 }
76
77 container->setActiveChest(enderChest);
78 player->openContainer(container);
79
80 return true;
81}
82
83shared_ptr<TileEntity> EnderChestTile::newTileEntity(Level *level)
84{
85 return shared_ptr<EnderChestTileEntity>(new EnderChestTileEntity());
86}
87
88void EnderChestTile::animateTick(Level *level, int xt, int yt, int zt, Random *random)
89{
90 for (int i = 0; i < 3; i++)
91 {
92 double x = xt + random->nextFloat();
93 double y = yt + random->nextFloat();
94 double z = zt + random->nextFloat();
95 double xa = 0;
96 double ya = 0;
97 double za = 0;
98 int flipX = random->nextInt(2) * 2 - 1;
99 int flipZ = random->nextInt(2) * 2 - 1;
100 xa = (random->nextFloat() - 0.5) * 0.125;
101 ya = (random->nextFloat() - 0.5) * 0.125;
102 za = (random->nextFloat() - 0.5) * 0.125;
103 z = zt + 0.5 + (0.25) * flipZ;
104 za = (random->nextFloat() * 1) * flipZ;
105 x = xt + 0.5 + (0.25) * flipX;
106 xa = (random->nextFloat() * 1) * flipX;
107
108 level->addParticle(eParticleType_ender, x, y, z, xa, ya, za);
109 }
110}
111
112void EnderChestTile::registerIcons(IconRegister *iconRegister)
113{
114 // Register obsidian as the chest's icon, because it's used by the
115 // particles when destroying the chest
116 icon = iconRegister->registerIcon(L"obsidian");
117}