the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 122 lines 3.2 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.h" 3#include "net.minecraft.world.h" 4#include "QuartzBlockTile.h" 5 6// 4J Added 7#include "Level.h" 8#include "PistonBaseTile.h" 9#include "Player.h" 10 11int QuartzBlockTile::BLOCK_NAMES[QUARTZ_BLOCK_NAMES] = { 12 IDS_TILE_QUARTZ_BLOCK, IDS_TILE_QUARTZ_BLOCK_CHISELED, IDS_TILE_QUARTZ_BLOCK_LINES, IDS_TILE_QUARTZ_BLOCK_LINES, IDS_TILE_QUARTZ_BLOCK_LINES 13}; 14 15const wstring QuartzBlockTile::TEXTURE_TOP = L"top"; 16const wstring QuartzBlockTile::TEXTURE_CHISELED_TOP = L"chiseled_top"; 17const wstring QuartzBlockTile::TEXTURE_LINES_TOP = L"lines_top"; 18const wstring QuartzBlockTile::TEXTURE_BOTTOM = L"bottom"; 19const wstring QuartzBlockTile::TEXTURE_NAMES[QUARTZ_BLOCK_TEXTURES] = { L"side", L"chiseled", L"lines", L"", L""}; 20 21QuartzBlockTile::QuartzBlockTile(int id) : Tile(id, Material::stone) 22{ 23} 24 25Icon *QuartzBlockTile::getTexture(int face, int data) 26{ 27 if (data == TYPE_LINES_Y || data == TYPE_LINES_X || data == TYPE_LINES_Z) 28 { 29 if (data == TYPE_LINES_Y && (face == Facing::UP || face == Facing::DOWN)) 30 { 31 return iconLinesTop; 32 } 33 else if (data == TYPE_LINES_X && (face == Facing::EAST || face == Facing::WEST)) 34 { 35 return iconLinesTop; 36 } 37 else if (data == TYPE_LINES_Z && (face == Facing::NORTH || face == Facing::SOUTH)) 38 { 39 return iconLinesTop; 40 } 41 42 return icons[data]; 43 } 44 45 if (face == Facing::UP || (face == Facing::DOWN && data == TYPE_CHISELED)) 46 { 47 if (data == TYPE_CHISELED) 48 { 49 return iconChiseledTop; 50 } 51 return iconTop; 52 } 53 if (face == Facing::DOWN) 54 { 55 return iconBottom; 56 } 57 if (data < 0 || data >= QUARTZ_BLOCK_TEXTURES) data = 0; 58 return icons[data]; 59} 60 61int QuartzBlockTile::getPlacedOnFaceDataValue(Level *level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue) 62{ 63 if (itemValue == TYPE_LINES_Y) 64 { 65 switch (face) 66 { 67 case Facing::NORTH: 68 case Facing::SOUTH: 69 itemValue = TYPE_LINES_Z; 70 break; 71 case Facing::EAST: 72 case Facing::WEST: 73 itemValue = TYPE_LINES_X; 74 break; 75 case Facing::UP: 76 case Facing::DOWN: 77 itemValue = TYPE_LINES_Y; 78 break; 79 } 80 } 81 82 return itemValue; 83} 84 85int QuartzBlockTile::getSpawnResourcesAuxValue(int data) 86{ 87 if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return TYPE_LINES_Y; 88 89 return data; 90} 91 92shared_ptr<ItemInstance> QuartzBlockTile::getSilkTouchItemInstance(int data) 93{ 94 if (data == TYPE_LINES_X || data == TYPE_LINES_Z) return shared_ptr<ItemInstance>(new ItemInstance(id, 1, TYPE_LINES_Y)); 95 return Tile::getSilkTouchItemInstance(data); 96} 97 98int QuartzBlockTile::getRenderShape() 99{ 100 return Tile::SHAPE_QUARTZ; 101} 102 103 104void QuartzBlockTile::registerIcons(IconRegister *iconRegister) 105{ 106 for (int i = 0; i < QUARTZ_BLOCK_TEXTURES; i++) 107 { 108 if (TEXTURE_NAMES[i].empty()) 109 { 110 icons[i] = icons[i - 1]; 111 } 112 else 113 { 114 icons[i] = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_NAMES[i]); 115 } 116 } 117 118 iconTop = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_TOP); 119 iconChiseledTop = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_CHISELED_TOP); 120 iconLinesTop = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_LINES_TOP); 121 iconBottom = iconRegister->registerIcon(getIconName() + L"_" + TEXTURE_BOTTOM); 122}