the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 111 lines 2.6 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.phys.h" 3#include "net.minecraft.world.level.h" 4#include "SharedConstants.h" 5#include "WoolCarpetTile.h" 6 7WoolCarpetTile::WoolCarpetTile(int id) : Tile(id, Material::clothDecoration, isSolidRender() ) 8{ 9 setShape(0, 0, 0, 1, 1 / 16.0f, 1); 10 setTicking(true); 11 updateShape(0); 12} 13 14Icon *WoolCarpetTile::getTexture(int face, int data) 15{ 16 return Tile::wool->getTexture(face, data); 17} 18 19AABB *WoolCarpetTile::getAABB(Level *level, int x, int y, int z) 20{ 21 int height = 0; 22 float offset = 1.0f / SharedConstants::WORLD_RESOLUTION; 23 ThreadStorage *tls = (ThreadStorage *)TlsGetValue(Tile::tlsIdxShape); 24 // 4J Stu - Added this so that the TLS shape is correct for this tile 25 if(tls->tileId != this->id) updateDefaultShape(); 26 return AABB::newTemp(x + tls->xx0, y + tls->yy0, z + tls->zz0, x + tls->xx1, y + (height * offset), z + tls->zz1); 27} 28 29bool WoolCarpetTile::blocksLight() 30{ 31 return false; 32} 33 34bool WoolCarpetTile::isSolidRender(bool isServerLevel) 35{ 36 return false; 37} 38 39bool WoolCarpetTile::isCubeShaped() 40{ 41 return false; 42} 43 44void WoolCarpetTile::updateDefaultShape() 45{ 46 updateShape(0); 47} 48 49void WoolCarpetTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) 50{ 51 updateShape(level->getData(x, y, z)); 52} 53 54void WoolCarpetTile::updateShape(int data) 55{ 56 int height = 0; 57 float o = 1 * (1 + height) / 16.0f; 58 setShape(0, 0, 0, 1, o, 1); 59} 60 61bool WoolCarpetTile::mayPlace(Level *level, int x, int y, int z) 62{ 63 return Tile::mayPlace(level, x, y, z) && canSurvive(level, x, y, z); 64} 65 66void WoolCarpetTile::neighborChanged(Level *level, int x, int y, int z, int type) 67{ 68 checkCanSurvive(level, x, y, z); 69} 70 71bool WoolCarpetTile::checkCanSurvive(Level *level, int x, int y, int z) 72{ 73 if (!canSurvive(level, x, y, z)) 74 { 75 spawnResources(level, x, y, z, level->getData(x, y, z), 0); 76 level->removeTile(x, y, z); 77 return false; 78 } 79 return true; 80} 81 82bool WoolCarpetTile::canSurvive(Level *level, int x, int y, int z) 83{ 84 return !level->isEmptyTile(x, y - 1, z); 85} 86 87bool WoolCarpetTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) 88{ 89 if (face == 1) return true; 90 return Tile::shouldRenderFace(level, x, y, z, face); 91} 92 93int WoolCarpetTile::getSpawnResourcesAuxValue(int data) 94{ 95 return data; 96} 97 98int WoolCarpetTile::getTileDataForItemAuxValue(int auxValue) 99{ 100 return (~auxValue & 0xf); 101} 102 103int WoolCarpetTile::getItemAuxValueForTileData(int data) 104{ 105 return (~data & 0xf); 106} 107 108void WoolCarpetTile::registerIcons(IconRegister *iconRegister) 109{ 110 // None, delegates to cloth tile 111}