the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 150 lines 3.5 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.level.h" 3#include "net.minecraft.world.phys.h" 4#include "net.minecraft.world.entity.player.h" 5#include "net.minecraft.world.food.h" 6#include "net.minecraft.world.item.h" 7#include "net.minecraft.world.h" 8#include "net.minecraft.h" 9#include "CakeTile.h" 10 11 12CakeTile::CakeTile(int id) : Tile(id, Material::cake,isSolidRender()) 13{ 14 setTicking(true); 15 16 iconTop = NULL; 17 iconBottom = NULL; 18 iconInner = NULL; 19} 20 21void CakeTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param 22{ 23 int d = level->getData(x, y, z); 24 float r = 1 / 16.0f; 25 float r2 = (1 + d * 2) / 16.0f; 26 float h = 8 / 16.0f; 27 this->setShape(r2, 0, r, 1 - r, h, 1 - r); 28} 29 30void CakeTile::updateDefaultShape() 31{ 32 float r = 1 / 16.0f; 33 float h = 8 / 16.0f; 34 this->setShape(r, 0, r, 1 - r, h, 1 - r); 35} 36 37AABB *CakeTile::getAABB(Level *level, int x, int y, int z) 38{ 39 int d = level->getData(x, y, z); 40 float r = 1 / 16.0f; 41 float r2 = (1 + d * 2) / 16.0f; 42 float h = 8 / 16.0f; 43 return AABB::newTemp(x + r2, y, z + r, x + 1 - r, y + h - r, z + 1 - r); 44} 45 46AABB *CakeTile::getTileAABB(Level *level, int x, int y, int z) 47{ 48 int d = level->getData(x, y, z); 49 float r = 1 / 16.0f; 50 float r2 = (1 + d * 2) / 16.0f; 51 float h = 8 / 16.0f; 52 return AABB::newTemp(x + r2, y, z + r, x + 1 - r, y + h, z + 1 - r); 53} 54 55Icon *CakeTile::getTexture(int face, int data) 56{ 57 if (face == Facing::UP) return iconTop; 58 if (face == Facing::DOWN) return iconBottom; 59 if (data > 0 && face == Facing::WEST) return iconInner; 60 return icon; 61} 62 63void CakeTile::registerIcons(IconRegister *iconRegister) 64{ 65 icon = iconRegister->registerIcon(L"cake_side"); 66 iconInner = iconRegister->registerIcon(L"cake_inner"); 67 iconTop = iconRegister->registerIcon(L"cake_top"); 68 iconBottom = iconRegister->registerIcon(L"cake_bottom"); 69} 70 71bool CakeTile::isCubeShaped() 72{ 73 return false; 74} 75 76bool CakeTile::isSolidRender(bool isServerLevel) 77{ 78 return false; 79} 80 81// 4J-PB - Adding a TestUse for tooltip display 82bool CakeTile::TestUse() 83{ 84 return true; 85} 86 87bool CakeTile::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 88{ 89 if( soundOnly ) return false; 90 eat(level, x, y, z, player); 91 return true; 92} 93 94void CakeTile::attack(Level *level, int x, int y, int z, shared_ptr<Player> player) 95{ 96 eat(level, x, y, z, player); 97} 98 99void CakeTile::eat(Level *level, int x, int y, int z, shared_ptr<Player> player) 100{ 101 if (player->canEat(false)) 102 { 103 player->getFoodData()->eat(2, FoodConstants::FOOD_SATURATION_POOR); 104 105 int d = level->getData(x, y, z) + 1; 106 if (d >= 6) 107 { 108 level->removeTile(x, y, z); 109 } 110 else 111 { 112 level->setData(x, y, z, d, Tile::UPDATE_CLIENTS); 113 } 114 } 115} 116 117bool CakeTile::mayPlace(Level *level, int x, int y, int z) 118{ 119 if (!Tile::mayPlace(level, x, y, z)) return false; 120 121 return canSurvive(level, x, y, z); 122} 123 124void CakeTile::neighborChanged(Level *level, int x, int y, int z, int type) 125{ 126 if (!canSurvive(level, x, y, z)) 127 { 128 level->removeTile(x, y, z); 129 } 130} 131 132bool CakeTile::canSurvive(Level *level, int x, int y, int z) 133{ 134 return level->getMaterial(x, y - 1, z)->isSolid(); 135} 136 137int CakeTile::getResourceCount(Random *random) 138{ 139 return 0; 140} 141 142int CakeTile::getResource(int data, Random *random, int playerBonusLevel) 143{ 144 return 0; 145} 146 147int CakeTile::cloneTileId(Level *level, int x, int y, int z) 148{ 149 return Item::cake_Id; 150}