the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 94 lines 2.4 kB view raw
1#include "stdafx.h" 2#include "net.minecraft.world.level.h" 3#include "net.minecraft.world.level.tile.piston.h" 4#include "net.minecraft.h" 5#include "net.minecraft.world.h" 6#include "LeafTile.h" 7 8#include "TreeTile.h" 9 10const unsigned int TreeTile::TREE_NAMES[ TreeTile::TREE_NAMES_LENGTH] = { IDS_TILE_LOG_OAK, 11 IDS_TILE_LOG_SPRUCE, 12 IDS_TILE_LOG_BIRCH, 13 IDS_TILE_LOG_JUNGLE 14 }; 15 16const wstring TreeTile::TREE_STRING_NAMES[ TreeTile::TREE_NAMES_LENGTH] = {L"oak", L"spruce", L"birch", L"jungle"}; 17 18const wstring TreeTile::TREE_TEXTURES[] = {L"tree_side", L"tree_spruce", L"tree_birch", L"tree_jungle"}; 19 20TreeTile::TreeTile(int id) : RotatedPillarTile(id, Material::wood) 21{ 22} 23 24int TreeTile::getResourceCount(Random *random) 25{ 26 return 1; 27} 28 29int TreeTile::getResource(int data, Random *random, int playerBonusLevel) 30{ 31 return Tile::treeTrunk_Id; 32} 33 34void TreeTile::onRemove(Level *level, int x, int y, int z, int id, int data) 35{ 36 int r = LeafTile::REQUIRED_WOOD_RANGE; 37 int r2 = r + 1; 38 39 if (level->hasChunksAt(x - r2, y - r2, z - r2, x + r2, y + r2, z + r2)) 40 { 41 for (int xo = -r; xo <= r; xo++) 42 for (int yo = -r; yo <= r; yo++) 43 for (int zo = -r; zo <= r; zo++) 44 { 45 int t = level->getTile(x + xo, y + yo, z + zo); 46 if (t == Tile::leaves_Id) 47 { 48 int currentData = level->getData(x + xo, y + yo, z + zo); 49 if ((currentData & LeafTile::UPDATE_LEAF_BIT) == 0) 50 { 51 level->setData(x + xo, y + yo, z + zo, currentData | LeafTile::UPDATE_LEAF_BIT, Tile::UPDATE_NONE); 52 } 53 } 54 } 55 } 56} 57 58 59unsigned int TreeTile::getDescriptionId(int iData /*= -1*/) 60{ 61 int type = iData & MASK_TYPE; 62 if(type < 0 ) type = 0; 63 return TreeTile::TREE_NAMES[type]; 64} 65 66Icon *TreeTile::getTypeTexture(int type) 67{ 68 return icons_side[type]; 69} 70 71Icon *TreeTile::getTopTexture(int type) 72{ 73 return icons_top[type]; 74} 75 76int TreeTile::getWoodType(int data) 77{ 78 return data & MASK_TYPE; 79} 80 81shared_ptr<ItemInstance> TreeTile::getSilkTouchItemInstance(int data) 82{ 83 // fix to avoid getting silktouched sideways logs 84 return shared_ptr<ItemInstance>(new ItemInstance(id, 1, getWoodType(data))); 85} 86 87void TreeTile::registerIcons(IconRegister *iconRegister) 88{ 89 for (int i = 0; i < TREE_NAMES_LENGTH; i++) 90 { 91 icons_side[i] = iconRegister->registerIcon(getIconName() + L"_" + TREE_STRING_NAMES[i]); 92 icons_top[i] = iconRegister->registerIcon(getIconName() + L"_" + TREE_STRING_NAMES[i] + L"_top"); 93 } 94}