the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
1#include "stdafx.h"
2#include "..\Minecraft.Client\Minecraft.h"
3#include "net.minecraft.world.item.h"
4#include "net.minecraft.world.level.h"
5#include "net.minecraft.world.level.biome.h"
6#include "net.minecraft.stats.h"
7#include "net.minecraft.world.h"
8#include "TallGrass.h"
9
10const unsigned int TallGrass::TALL_GRASS_TILE_NAMES[TALL_GRASS_TILE_NAMES_LENGTH] = { IDS_TILE_SHRUB,
11 IDS_TILE_TALL_GRASS,
12 IDS_TILE_FERN,
13 };
14
15const wstring TallGrass::TEXTURE_NAMES[] = {L"deadbush", L"tallgrass", L"fern"};
16
17TallGrass::TallGrass(int id) : Bush(id, Material::replaceable_plant)
18{
19 this->updateDefaultShape();
20}
21
22// 4J Added override
23void TallGrass::updateDefaultShape()
24{
25 float ss = 0.4f;
26 this->setShape(0.5f - ss, 0, 0.5f - ss, 0.5f + ss, 0.8f, 0.5f + ss);
27}
28
29
30Icon *TallGrass::getTexture(int face, int data)
31{
32 if (data >= TALL_GRASS_TILE_NAMES_LENGTH) data = 0;
33 return icons[data];
34}
35
36int TallGrass::getColor(int auxData)
37{
38 if (auxData == DEAD_SHRUB) return 0xffffff;
39
40 return FoliageColor::getDefaultColor();
41}
42
43int TallGrass::getColor() const
44{
45 // 4J Stu - Not using this any more
46 //double temp = 0.5;
47 //double rain = 1.0;
48
49 //return GrassColor::get(temp, rain);
50
51 return Minecraft::GetInstance()->getColourTable()->getColor( eMinecraftColour_Grass_Common );
52}
53
54int TallGrass::getColor(LevelSource *level, int x, int y, int z )
55{
56 return getColor( level, x, y, z, level->getData(x, y, z) );
57}
58
59// 4J - changed interface to have data passed in, and put existing interface as wrapper above
60int TallGrass::getColor(LevelSource *level, int x, int y, int z, int data)
61{
62 int d = data;
63 if (d == DEAD_SHRUB) return 0xffffff;
64
65 return level->getBiome(x, z)->getGrassColor();
66}
67
68int TallGrass::getResource(int data, Random *random, int playerBonusLevel)
69{
70 if (random->nextInt(8) == 0) {
71 return Item::seeds_wheat->id;
72 }
73
74 return -1;
75}
76
77int TallGrass::getResourceCountForLootBonus(int bonusLevel, Random *random)
78{
79 return 1 + random->nextInt(bonusLevel * 2 + 1);
80}
81
82void TallGrass::playerDestroy(Level *level, shared_ptr<Player> player, int x, int y, int z, int data)
83{
84 if (!level->isClientSide && player->getSelectedItem() != NULL && player->getSelectedItem()->id == Item::shears->id)
85 {
86 player->awardStat(
87 GenericStats::blocksMined(id),
88 GenericStats::param_blocksMined(id,data,1)
89 );
90
91 // drop leaf block instead of sapling
92 popResource(level, x, y, z, shared_ptr<ItemInstance>(new ItemInstance(Tile::tallgrass, 1, data)));
93 }
94 else
95 {
96 Bush::playerDestroy(level, player, x, y, z, data);
97 }
98}
99
100int TallGrass::cloneTileData(Level *level, int x, int y, int z)
101{
102 return level->getData(x, y, z);
103}
104
105unsigned int TallGrass::getDescriptionId(int iData /*= -1*/)
106{
107 if(iData < 0 ) iData = 0;
108 return TallGrass::TALL_GRASS_TILE_NAMES[iData];
109}
110
111void TallGrass::registerIcons(IconRegister *iconRegister)
112{
113 icons = new Icon*[TALL_GRASS_TILE_NAMES_LENGTH];
114
115 for (int i = 0; i < TALL_GRASS_TILE_NAMES_LENGTH; i++)
116 {
117 icons[i] = iconRegister->registerIcon(TEXTURE_NAMES[i]);
118 }
119}