the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 112 lines 2.7 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.level.h" 3#include "LadderTile.h" 4 5 6LadderTile::LadderTile(int id) : Tile(id, Material::decoration,isSolidRender()) 7{ 8} 9 10AABB *LadderTile::getAABB(Level *level, int x, int y, int z) 11{ 12 updateShape(level, x, y, z); 13 return Tile::getAABB(level, x, y, z); 14} 15 16AABB *LadderTile::getTileAABB(Level *level, int x, int y, int z) 17{ 18 updateShape(level, x, y, z); 19 return Tile::getTileAABB(level, x, y, z); 20} 21 22void LadderTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param 23{ 24 setShape(level->getData(x, y, z)); 25} 26 27void LadderTile::setShape(int data) 28{ 29 int dir = data; 30 float r = 2 / 16.0f; 31 32 if (dir == 2) setShape(0, 0, 1 - r, 1, 1, 1); 33 if (dir == 3) setShape(0, 0, 0, 1, 1, r); 34 if (dir == 4) setShape(1 - r, 0, 0, 1, 1, 1); 35 if (dir == 5) setShape(0, 0, 0, r, 1, 1); 36} 37 38bool LadderTile::blocksLight() 39{ 40 return false; 41} 42 43bool LadderTile::isSolidRender(bool isServerLevel) 44{ 45 return false; 46} 47 48bool LadderTile::isCubeShaped() 49{ 50 return false; 51} 52 53int LadderTile::getRenderShape() 54{ 55 return Tile::SHAPE_LADDER; 56} 57 58bool LadderTile::mayPlace(Level *level, int x, int y, int z) 59{ 60 if (level->isSolidBlockingTile(x - 1, y, z)) 61 { 62 return true; 63 } 64 else if (level->isSolidBlockingTile(x + 1, y, z)) 65 { 66 return true; 67 } 68 else if (level->isSolidBlockingTile(x, y, z - 1)) 69 { 70 return true; 71 } 72 else if (level->isSolidBlockingTile(x, y, z + 1)) 73 { 74 return true; 75 } 76 return false; 77} 78 79int LadderTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue) 80{ 81 int dir = level->getData(x, y, z); 82 83 if ((dir == 0 || face == 2) && level->isSolidBlockingTile(x, y, z + 1)) dir = 2; 84 if ((dir == 0 || face == 3) && level->isSolidBlockingTile(x, y, z - 1)) dir = 3; 85 if ((dir == 0 || face == 4) && level->isSolidBlockingTile(x + 1, y, z)) dir = 4; 86 if ((dir == 0 || face == 5) && level->isSolidBlockingTile(x - 1, y, z)) dir = 5; 87 88 return dir; 89} 90 91void LadderTile::neighborChanged(Level *level, int x, int y, int z, int type) 92{ 93 int face = level->getData(x, y, z); 94 bool ok = false; 95 96 if (face == 2 && level->isSolidBlockingTile(x, y, z + 1)) ok = true; 97 if (face == 3 && level->isSolidBlockingTile(x, y, z - 1)) ok = true; 98 if (face == 4 && level->isSolidBlockingTile(x + 1, y, z)) ok = true; 99 if (face == 5 && level->isSolidBlockingTile(x - 1, y, z)) ok = true; 100 if (!ok) 101 { 102 spawnResources(level, x, y, z, face, 0); 103 level->removeTile(x, y, z); 104 } 105 106 Tile::neighborChanged(level, x, y, z, type); 107} 108 109int LadderTile::getResourceCount(Random* random) 110{ 111 return 1; 112}