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 "EnchantmentTableTile.h"
3#include "EnchantmentTableEntity.h"
4#include "net.minecraft.world.level.h"
5#include "net.minecraft.h"
6#include "net.minecraft.world.h"
7
8const wstring EnchantmentTableTile::TEXTURE_SIDE = L"enchantment_side";
9const wstring EnchantmentTableTile::TEXTURE_TOP = L"enchantment_top";
10const wstring EnchantmentTableTile::TEXTURE_BOTTOM = L"enchantment_bottom";
11
12EnchantmentTableTile::EnchantmentTableTile(int id) : BaseEntityTile(id, Material::stone, isSolidRender())
13{
14 updateDefaultShape();
15 setLightBlock(0);
16
17 iconTop = NULL;
18 iconBottom = NULL;
19}
20
21// 4J Added override
22void EnchantmentTableTile::updateDefaultShape()
23{
24 setShape(0, 0, 0, 1, 12 / 16.0f, 1);
25}
26
27bool EnchantmentTableTile::isCubeShaped()
28{
29 return false;
30}
31
32void EnchantmentTableTile::animateTick(Level *level, int x, int y, int z, Random *random)
33{
34 BaseEntityTile::animateTick(level, x, y, z, random);
35
36 for (int xx = x - 2; xx <= x + 2; xx++)
37 {
38 for (int zz = z - 2; zz <= z + 2; zz++)
39 {
40 if (xx > x - 2 && xx < x + 2 && zz == z - 1)
41 {
42 zz = z + 2;
43 }
44 if (random->nextInt(16) != 0) continue;
45 for (int yy = y; yy <= y + 1; yy++)
46 {
47 if (level->getTile(xx, yy, zz) == Tile::bookshelf_Id)
48 {
49 if (!level->isEmptyTile((xx - x) / 2 + x, yy, (zz - z) / 2 + z)) break;
50
51 level->addParticle(eParticleType_enchantmenttable, x + 0.5, y + 2.0, z + 0.5, xx - x + random->nextFloat() - 0.5, yy - y - random->nextFloat() - 1, zz - z + random->nextFloat() - 0.5);
52 }
53 }
54 }
55 }
56}
57
58bool EnchantmentTableTile::isSolidRender(bool isServerLevel)
59{
60 return false;
61}
62
63Icon *EnchantmentTableTile::getTexture(int face, int data)
64{
65 if (face == Facing::DOWN) return iconBottom;
66 if (face == Facing::UP) return iconTop;
67 return icon;
68}
69
70shared_ptr<TileEntity> EnchantmentTableTile::newTileEntity(Level *level)
71{
72 return shared_ptr<TileEntity>(new EnchantmentTableEntity());
73}
74
75bool EnchantmentTableTile::use(Level *level, int x, int y, int z, shared_ptr<Player> player, int clickedFace, float clickX, float clickY, float clickZ, bool soundOnly/*=false*/) // 4J added soundOnly param
76{
77 if(soundOnly) return false;
78
79 if (level->isClientSide)
80 {
81 return true;
82 }
83 shared_ptr<EnchantmentTableEntity> table = dynamic_pointer_cast<EnchantmentTableEntity>( level->getTileEntity(x, y, z) );
84 player->startEnchanting(x, y, z, table->hasCustomName() ? table->getName() : L"");
85 return true;
86}
87
88void EnchantmentTableTile::setPlacedBy(Level *level, int x, int y, int z, shared_ptr<LivingEntity> by, shared_ptr<ItemInstance> itemInstance)
89{
90 BaseEntityTile::setPlacedBy(level, x, y, z, by, itemInstance);
91 if (itemInstance->hasCustomHoverName())
92 {
93 dynamic_pointer_cast<EnchantmentTableEntity>( level->getTileEntity(x, y, z))->setCustomName(itemInstance->getHoverName());
94 }
95}
96
97void EnchantmentTableTile::registerIcons(IconRegister *iconRegister)
98{
99 icon = iconRegister->registerIcon(TEXTURE_SIDE);
100 iconTop = iconRegister->registerIcon(TEXTURE_TOP);
101 iconBottom = iconRegister->registerIcon(TEXTURE_BOTTOM);
102}