the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 152 lines 3.4 kB view raw
1#include "stdafx.h" 2#include "HalfSlabTile.h" 3#include "net.minecraft.world.level.h" 4#include "net.minecraft.world.level.biome.h" 5#include "net.minecraft.world.item.h" 6#include "net.minecraft.stats.h" 7#include "Facing.h" 8 9 10HalfSlabTile::HalfSlabTile(int id, bool fullSize, Material *material) : Tile(id, material, fullSize) 11{ 12 this->fullSize = fullSize; 13 14 if (fullSize) 15 { 16 solid[id] = true; 17 } 18 else 19 { 20 setShape(0, 0, 0, 1, 0.5f, 1); 21 } 22 setLightBlock(255); 23} 24 25void HalfSlabTile::updateShape(LevelSource *level, int x, int y, int z, int forceData, shared_ptr<TileEntity> forceEntity) // 4J added forceData, forceEntity param 26{ 27 if (fullSize) 28 { 29 setShape(0, 0, 0, 1, 1, 1); 30 } 31 else 32 { 33 bool upper = (level->getData(x, y, z) & TOP_SLOT_BIT) != 0; 34 if (upper) 35 { 36 setShape(0, 0.5f, 0, 1, 1, 1); 37 } 38 else 39 { 40 setShape(0, 0, 0, 1, 0.5f, 1); 41 } 42 } 43} 44 45void HalfSlabTile::updateDefaultShape() 46{ 47 if (fullSize) 48 { 49 setShape(0, 0, 0, 1, 1, 1); 50 } 51 else 52 { 53 setShape(0, 0, 0, 1, 0.5f, 1); 54 } 55} 56 57void HalfSlabTile::addAABBs(Level *level, int x, int y, int z, AABB *box, AABBList *boxes, shared_ptr<Entity> source) 58{ 59 updateShape(level, x, y, z); 60 Tile::addAABBs(level, x, y, z, box, boxes, source); 61} 62 63bool HalfSlabTile::isSolidRender(bool isServerLevel) 64{ 65 return fullSize; 66} 67 68int HalfSlabTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue) 69{ 70 if (fullSize) return itemValue; 71 72 if (face == Facing::DOWN || (face != Facing::UP && clickY > 0.5)) 73 { 74 return itemValue | TOP_SLOT_BIT; 75 } 76 return itemValue; 77} 78 79int HalfSlabTile::getResourceCount(Random *random) 80{ 81 if (fullSize) 82 { 83 return 2; 84 } 85 return 1; 86} 87 88int HalfSlabTile::getSpawnResourcesAuxValue(int data) 89{ 90 return data & TYPE_MASK; 91} 92 93bool HalfSlabTile::isCubeShaped() 94{ 95 return fullSize; 96} 97 98bool HalfSlabTile::shouldRenderFace(LevelSource *level, int x, int y, int z, int face) 99{ 100 if (fullSize) return Tile::shouldRenderFace(level, x, y, z, face); 101 102 if (face != Facing::UP && face != Facing::DOWN && !Tile::shouldRenderFace(level, x, y, z, face)) 103 { 104 return false; 105 } 106 107 int ox = x, oy = y, oz = z; 108 ox += Facing::STEP_X[Facing::OPPOSITE_FACING[face]]; 109 oy += Facing::STEP_Y[Facing::OPPOSITE_FACING[face]]; 110 oz += Facing::STEP_Z[Facing::OPPOSITE_FACING[face]]; 111 112 boolean isUpper = (level->getData(ox, oy, oz) & TOP_SLOT_BIT) != 0; 113 if (isUpper) 114 { 115 if (face == Facing::DOWN) return true; 116 if (face == Facing::UP && Tile::shouldRenderFace(level, x, y, z, face)) return true; 117 return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) != 0); 118 } 119 else 120 { 121 if (face == Facing::UP) return true; 122 if (face == Facing::DOWN && Tile::shouldRenderFace(level, x, y, z, face)) return true; 123 return !(isHalfSlab(level->getTile(x, y, z)) && (level->getData(x, y, z) & TOP_SLOT_BIT) == 0); 124 } 125} 126 127bool HalfSlabTile::isHalfSlab(int tileId) 128{ 129 return tileId == Tile::stoneSlabHalf_Id || tileId == Tile::woodSlabHalf_Id; 130} 131 132int HalfSlabTile::cloneTileData(Level *level, int x, int y, int z) 133{ 134 return Tile::cloneTileData(level, x, y, z) & TYPE_MASK; 135} 136 137int HalfSlabTile::cloneTileId(Level *level, int x, int y, int z) 138{ 139 if (isHalfSlab(id)) 140 { 141 return id; 142 } 143 if (id == Tile::stoneSlab_Id) 144 { 145 return Tile::stoneSlabHalf_Id; 146 } 147 if (id == Tile::woodSlab_Id) 148 { 149 return Tile::woodSlabHalf_Id; 150 } 151 return Tile::stoneSlabHalf_Id; 152}