Added Foliage and Grass Color tinting, Started Basic Work on restoring ravines, New Option to Toggle Tinting.

This commit is contained in:
Shredder
2026-04-03 14:55:33 +05:00
parent eac71a93d1
commit ff5c57f6ba
27 changed files with 241 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@@ -153,6 +153,7 @@ options.group.tweaks=Tweaks
options.allowSprint=Allow sprint options.allowSprint=Allow sprint
options.barOnTop=HUD above inventory options.barOnTop=HUD above inventory
options.rpiCursor=Show Raspberry PI cursor options.rpiCursor=Show Raspberry PI cursor
options.foliageTint=Tint Grass and Leaves
options.autoJump=Auto Jump options.autoJump=Auto Jump
options.thirdperson=Third Person options.thirdperson=Third Person
options.servervisible=Server Visible options.servervisible=Server Visible

View File

@@ -90,6 +90,7 @@
#include "../network/command/CommandServer.h" #include "../network/command/CommandServer.h"
#include "gamemode/CreatorMode.h" #include "gamemode/CreatorMode.h"
#include "../world/level/GrassColor.h"
static void checkGlError(const char* tag) { static void checkGlError(const char* tag) {
#ifdef GLDEBUG #ifdef GLDEBUG
while (1) { while (1) {
@@ -1132,6 +1133,24 @@ void Minecraft::init()
gameRenderer = new GameRenderer(this); gameRenderer = new GameRenderer(this);
particleEngine = new ParticleEngine(level, textures); particleEngine = new ParticleEngine(level, textures);
// 4j's code for reference
// FoliageColor::init(textures->loadTexturePixels(L"misc/foliagecolor.png"));
// my code
TextureId foliageId = (textures->loadTexture("environment/foliagecolor.png")); // loading the uh png for foliage color
int* foliagePixels = textures->loadTexturePixels(foliageId, "environment/foliagecolor.png");
// now i can finally initialize foliage color, probably not the best way to handle this but i cant be arsed rn
FoliageColor::init(foliagePixels);
TextureId grassId = (textures->loadTexture("environment/grasscolor.png")); // loading the uh png for foliage color
int* grassPixels = textures->loadTexturePixels(grassId, "environment/grasscolor.png");
GrassColor::init(grassPixels);
bool tint = options.getBooleanValue(OPTIONS_FOLIAGE_TINT); // finally, toggleable foliage color
FoliageColor::setUseTint(tint);
GrassColor::setUseTint(tint);
// Platform specific initialization here // Platform specific initialization here
font = new Font(&options, "font/default8.png", textures); font = new Font(&options, "font/default8.png", textures);

View File

@@ -60,6 +60,8 @@ OptionBool useTouchscreen("useTouchscreen", true);
OptionBool serverVisible("servervisible", true); OptionBool serverVisible("servervisible", true);
OptionBool foliageTint("foliagetint", false);
OptionInt keyForward("key.forward", Keyboard::KEY_W); OptionInt keyForward("key.forward", Keyboard::KEY_W);
OptionInt keyLeft("key.left", Keyboard::KEY_A); OptionInt keyLeft("key.left", Keyboard::KEY_A);
OptionInt keyBack("key.back", Keyboard::KEY_S); OptionInt keyBack("key.back", Keyboard::KEY_S);
@@ -136,6 +138,8 @@ void Options::initTable() {
m_options[OPTIONS_USE_TOUCHSCREEN] = &useTouchscreen; m_options[OPTIONS_USE_TOUCHSCREEN] = &useTouchscreen;
m_options[OPTIONS_SERVER_VISIBLE] = &serverVisible; m_options[OPTIONS_SERVER_VISIBLE] = &serverVisible;
m_options[OPTIONS_KEY_FORWARD] = &keyForward; m_options[OPTIONS_KEY_FORWARD] = &keyForward;
@@ -160,6 +164,7 @@ void Options::initTable() {
m_options[OPTIONS_BAR_ON_TOP] = &barOnTop; m_options[OPTIONS_BAR_ON_TOP] = &barOnTop;
m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint; m_options[OPTIONS_ALLOW_SPRINT] = &allowSprint;
m_options[OPTIONS_RPI_CURSOR] = &rpiCursor; m_options[OPTIONS_RPI_CURSOR] = &rpiCursor;
m_options[OPTIONS_FOLIAGE_TINT] = &foliageTint;
m_options[OPTIONS_AUTOJUMP] = &autoJump; m_options[OPTIONS_AUTOJUMP] = &autoJump;
m_options[OPTIONS_LAST_IP] = &lastIp; m_options[OPTIONS_LAST_IP] = &lastIp;

View File

@@ -84,6 +84,7 @@ enum OptionId {
OPTIONS_LAST_IP, OPTIONS_LAST_IP,
OPTIONS_RPI_CURSOR, OPTIONS_RPI_CURSOR,
OPTIONS_FOLIAGE_TINT,
// Should be last! // Should be last!
OPTIONS_COUNT OPTIONS_COUNT
}; };

View File

@@ -225,7 +225,8 @@ void OptionsScreen::generateOptionScreens() {
optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft) optionPanes[4]->addOptionItem(OPTIONS_ALLOW_SPRINT, minecraft)
.addOptionItem(OPTIONS_BAR_ON_TOP, minecraft) .addOptionItem(OPTIONS_BAR_ON_TOP, minecraft)
.addOptionItem(OPTIONS_RPI_CURSOR, minecraft); .addOptionItem(OPTIONS_RPI_CURSOR, minecraft)
.addOptionItem(OPTIONS_FOLIAGE_TINT, minecraft);
} }
void OptionsScreen::mouseClicked(int x, int y, int buttonNum) { void OptionsScreen::mouseClicked(int x, int y, int buttonNum) {

View File

@@ -7,6 +7,10 @@
#include "../../world/level/Region.h" #include "../../world/level/Region.h"
#include "../../world/level/chunk/LevelChunk.h" #include "../../world/level/chunk/LevelChunk.h"
#include "../../util/Mth.h" #include "../../util/Mth.h"
#include "../../world/level/biome/BiomeSource.h"
#include "../../world/level/Level.h"
//#include "../../platform/time.h" //#include "../../platform/time.h"
/*static*/ int Chunk::updates = 0; /*static*/ int Chunk::updates = 0;
@@ -260,3 +264,6 @@ void Chunk::resetUpdates()
updates = 0; updates = 0;
//swRebuild.reset(); //swRebuild.reset();
} }
BiomeSource* Region::getBiomeSource() {
return level->getBiomeSource();
}

View File

@@ -25,6 +25,8 @@
#include "../../client/player/LocalPlayer.h" #include "../../client/player/LocalPlayer.h"
#include "../../world/level/GrassColor.h"
#ifdef GFX_SMALLER_CHUNKS #ifdef GFX_SMALLER_CHUNKS
/* static */ const int LevelRenderer::CHUNK_SIZE = 8; /* static */ const int LevelRenderer::CHUNK_SIZE = 8;
#else #else
@@ -143,6 +145,10 @@ void LevelRenderer::setLevel( Level* level )
level->addListener(this); level->addListener(this);
allChanged(); allChanged();
} }
if (mc->options.getBooleanValue(OPTIONS_AMBIENT_OCCLUSION)) {
mc->useAmbientOcclusion = !mc->useAmbientOcclusion;
allChanged();
}
} }
void LevelRenderer::allChanged() void LevelRenderer::allChanged()
@@ -155,6 +161,11 @@ void LevelRenderer::allChanged()
Tile::leaves_carried->setFancy(fancy); Tile::leaves_carried->setFancy(fancy);
lastViewDistance = mc->options.getIntValue(OPTIONS_VIEW_DISTANCE); lastViewDistance = mc->options.getIntValue(OPTIONS_VIEW_DISTANCE);
bool tint = mc->options.getBooleanValue(OPTIONS_FOLIAGE_TINT);
FoliageColor::setUseTint(tint);
GrassColor::setUseTint(tint);
int dist = (512 >> 3) << (3 - lastViewDistance); int dist = (512 >> 3) << (3 - lastViewDistance);
if (lastViewDistance <= 2 && mc->isPowerVR()) if (lastViewDistance <= 2 && mc->isPowerVR())
dist = (int)((float)dist * 0.8f); dist = (int)((float)dist * 0.8f);

View File

@@ -249,6 +249,37 @@ int Textures::crispBlend( int c0, int c1 )
return (a << 24) | (r << 16) | (g << 8) | b; return (a << 24) | (r << 16) | (g << 8) | b;
} }
// shredder here, moved the code from minecraft.cpp bcus that isnt the right place
// had to implement this because i couldn't find a similar function in the code to do this
int* Textures::loadTexturePixels(TextureId texId, const std::string& resourceName){
const TextureData* texture = getTemporaryTextureData(texId); // storing raw pixels
int size = texture->w * texture->h; // gets the size of our funny lil guy
int* pixels = new int[size]; // memory leaks be galore
unsigned char* raw = texture->data; // storing raw data into our beloved variable
for (int i = 0; i < (texture->w * texture->h); i++){
// my head hurts i hate working with this
// uh since each pixel stores r g b a, aka the color channels which are each one byte, we multiply them by 4 to move from one pixel to another
int r = raw[i * 4 + 0]; // gets us the first channel aka red
int g = raw[i * 4 + 1]; // gets us the second channel green
int b = raw[i * 4 + 2]; // gets us the third channel blue
int a = raw[i * 4 + 3]; // gets us the alpha channel
// woohoo pixels uh should have been seperated into their colors now hopefully
// r g b a
// ugh we now got to turn it into the AA RR GGBB format aak 0xAARRGGBB
// b gets 0 - 7 (8 bits), g gets 7 - 15 (8 bits), r gets 16 - 23 (8 bits), alpha gets the last ones 24 - 31 (8 bits),
pixels[i] = (a << 24) | (r << 16) | (g << 8) | (b); // shuld combine them into one 32 bit int unless i did something dumb
}
return pixels; // your meal has been prepared john colors
}
///*public*/ int loadHttpTexture(std::string url, std::string backup) { ///*public*/ int loadHttpTexture(std::string url, std::string backup) {
// HttpTexture texture = httpTextures.get(url); // HttpTexture texture = httpTextures.get(url);
// if (texture != NULL) { // if (texture != NULL) {

View File

@@ -44,6 +44,8 @@ public:
TextureId assignTexture(const std::string& resourceName, const TextureData& img); TextureId assignTexture(const std::string& resourceName, const TextureData& img);
const TextureData* getTemporaryTextureData(TextureId id); const TextureData* getTemporaryTextureData(TextureId id);
int* loadTexturePixels(TextureId texId, const std::string& resourceName);
void tick(bool uploadToGraphicsCard); void tick(bool uploadToGraphicsCard);
void clear(); void clear();

View File

@@ -0,0 +1,13 @@
#include "FoliageColor.h"
// TODO: Probably move all the stuff from the header into here so it's a bit cleaner
bool FoliageColor::useTint = true;
int FoliageColor::get(float temp, float rain) {
rain *= temp;
int x = (int) ((1 - temp) * 255);
int y = (int) ((1 - rain) * 255);
return pixels[y << 8 | x];
}
int* FoliageColor::pixels = nullptr;

View File

@@ -6,31 +6,49 @@
class FoliageColor class FoliageColor
{ {
public: public:
// static void init(int[] pixels) { static bool useTint;
// FoliageColor::pixels = pixels;
// }
//
// static int get(float temp, float rain) {
// rain *= temp;
// int x = (int) ((1 - temp) * 255);
// int y = (int) ((1 - rain) * 255);
// return pixels[y << 8 | x];
// }
static int getEvergreenColor() { static void setUseTint(bool value) {
return 0x619961; useTint = value;
} }
/*
Shredder here, Ive converted the unused commented out code into their correct syntax, though if i did something incorrectly feel free to take reference from the
commented out code
*/
static int getBirchColor() { // static void init(int[] pixels) {
return 0x80a755; // FoliageColor::pixels = pixels;
} // }
//
// static int get(float temp, float rain) {
// rain *= temp;
// int x = (int) ((1 - temp) * 255);
// int y = (int) ((1 - rain) * 255);
// return pixels[y << 8 | x];
// }
static int getDefaultColor() {
return 0x48b518; static void init(int* p) {
} pixels = p;
}
static int get(float temp, float rain);
static int getEvergreenColor() {
return 0x619961;
}
static int getBirchColor() {
return 0x80a755;
}
static int getDefaultColor() {
return 0xFFFFFF;
}
private: private:
//static int pixels[256*256]; // static int pixels[256*256];
static int* pixels;
}; };
#endif /*NET_MINECRAFT_WORLD_LEVEL__FoliageColor_H__*/ #endif /*NET_MINECRAFT_WORLD_LEVEL__FoliageColor_H__*/

View File

@@ -0,0 +1,13 @@
#include "GrassColor.h"
// TODO: Probably move all the stuff from the header into here so it's a bit cleaner
bool GrassColor::useTint = true;
int GrassColor::get(float temp, float rain) {
rain *= temp;
int x = (int) ((1 - temp) * 255);
int y = (int) ((1 - rain) * 255);
return pixels[y << 8 | x];
}
int* GrassColor::pixels = nullptr;

View File

@@ -0,0 +1,42 @@
#ifndef NET_MINECRAFT_WORLD_LEVEL__GrassColor_H__
#define NET_MINECRAFT_WORLD_LEVEL__GrassColor_H__
//package net.minecraft.world.level;
class GrassColor
{
public:
static bool useTint;
static void setUseTint(bool value) {
useTint = value;
}
/*
Shredder here, Ive converted the unused commented out code into their correct syntax, though if i did something incorrectly feel free to take reference from the
commented out code
*/
// static void init(int[] pixels) {
// GrassColor::pixels = pixels;
// }
//
// static int get(float temp, float rain) {
// rain *= temp;
// int x = (int) ((1 - temp) * 255);
// int y = (int) ((1 - rain) * 255);
// return pixels[y << 8 | x];
// }
static void init(int* p) {
pixels = p;
}
static int get(float temp, float rain);
private:
// static int pixels[256*256];
static int* pixels;
};
#endif /*NET_MINECRAFT_WORLD_LEVEL__GrassColor_H__*/

View File

@@ -3,8 +3,9 @@
//package net.minecraft.world.level; //package net.minecraft.world.level;
/*
class BiomeSource; class BiomeSource;
/*
class TileEntity; class TileEntity;
*/ */
class Material; class Material;
@@ -29,7 +30,7 @@ public:
virtual bool isSolidRenderTile(int x, int i, int z) = 0; virtual bool isSolidRenderTile(int x, int i, int z) = 0;
virtual bool isSolidBlockingTile(int x, int i, int z) = 0; virtual bool isSolidBlockingTile(int x, int i, int z) = 0;
//virtual BiomeSource* getBiomeSource() = 0; virtual BiomeSource* getBiomeSource() = 0;
virtual Biome* getBiome(int x, int z) = 0; virtual Biome* getBiome(int x, int z) = 0;
}; };

View File

@@ -5,6 +5,7 @@
#include "LevelSource.h" #include "LevelSource.h"
class Level; class Level;
class Material; class Material;
class LevelChunk; class LevelChunk;
@@ -27,6 +28,7 @@ public:
int getData(int x, int y, int z); int getData(int x, int y, int z);
const Material* getMaterial(int x, int y, int z); const Material* getMaterial(int x, int y, int z);
Biome* getBiome(int x, int z); Biome* getBiome(int x, int z);
BiomeSource* getBiomeSource() override;
private: private:
int xc1, zc1; int xc1, zc1;
LevelChunk*** chunks; LevelChunk*** chunks;

View File

@@ -149,13 +149,7 @@ Feature* Biome::getGrassFeature( Random* random ) {
return new TallgrassFeature(Tile::tallgrass->id, TallGrass::TALL_GRASS); return new TallgrassFeature(Tile::tallgrass->id, TallGrass::TALL_GRASS);
} }
Feature* Biome::getBasicTreeFeature( Random* random )
{
if (random->nextInt(10) == 0) {
return new BasicTree(false);
}
}
Biome* Biome::getBiome( float temperature, float downfall ) Biome* Biome::getBiome( float temperature, float downfall )

View File

@@ -71,7 +71,6 @@ public:
virtual Feature* getTreeFeature(Random* random); virtual Feature* getTreeFeature(Random* random);
virtual Feature* getGrassFeature(Random* random); virtual Feature* getGrassFeature(Random* random);
virtual Feature* getBasicTreeFeature(Random* random);
static Biome* getBiome(float temperature, float downfall); static Biome* getBiome(float temperature, float downfall);
static Biome* _getBiome(float temperature, float downfall); static Biome* _getBiome(float temperature, float downfall);

View File

@@ -69,11 +69,11 @@ Biome* BiomeSource::getBiome( int x, int z )
return getBiomeBlock(x, z, 1, 1)[0]; return getBiomeBlock(x, z, 1, 1)[0];
} }
//float BiomeSource::getTemperature( int x, int z ) float BiomeSource::getTemperature( int x, int z )
//{ {
// temperatures = temperatureMap->getRegion(temperatures, x, z, 1, 1, tempScale, tempScale, 0.5f); temperatures = temperatureMap->getRegion(temperatures, x, z, 1, 1, tempScale, tempScale, 0.5f);
// return temperatures[0]; return temperatures[0];
//} }
Biome** BiomeSource::getBiomeBlock( int x, int z, int w, int h ) Biome** BiomeSource::getBiomeBlock( int x, int z, int w, int h )
{ {
@@ -123,7 +123,7 @@ Biome** BiomeSource::getBiomeBlock( Biome** biomes__, int x, int z, int w, int h
return biomes; return biomes;
} }
float* BiomeSource::getTemperatureBlock( /*float* temperatures__, */int x, int z, int w, int h ) float* BiomeSource::getTemperatureBlock( float* temperatures__, int x, int z, int w, int h )
{ {
//LOGI("gTempBlock: 1\n"); //LOGI("gTempBlock: 1\n");
//const int size = w * h; //const int size = w * h;
@@ -164,8 +164,8 @@ float* BiomeSource::getTemperatureBlock( /*float* temperatures__, */int x, int z
return temperatures; return temperatures;
} }
//float* BiomeSource::getDownfallBlock( /*float* downfalls__,*/ int x, int z, int w, int h ) float* BiomeSource::getDownfallBlock( float* downfalls__, int x, int z, int w, int h )
//{ {
// //const int size = w * h; // //const int size = w * h;
// //if (lenDownfalls < size) { // //if (lenDownfalls < size) {
// // delete[] downfalls; // // delete[] downfalls;
@@ -173,6 +173,6 @@ float* BiomeSource::getTemperatureBlock( /*float* temperatures__, */int x, int z
// // lenDownfalls = size; // // lenDownfalls = size;
// //} // //}
// //
// downfalls = downfallMap->getRegion(downfalls, x, z, w, w, downfallScale, downfallScale, 0.5f); downfalls = downfallMap->getRegion(downfalls, x, z, w, w, downfallScale, downfallScale, 0.5f);
// return downfalls; return downfalls;
//} }

View File

@@ -31,13 +31,13 @@ public:
virtual Biome* getBiome(const ChunkPos& chunk); virtual Biome* getBiome(const ChunkPos& chunk);
virtual Biome* getBiome(int x, int z); virtual Biome* getBiome(int x, int z);
//virtual float getTemperature(int x, int z); virtual float getTemperature(int x, int z);
// Note: The arrays returned here are temporary in the meaning that their // Note: The arrays returned here are temporary in the meaning that their
// contents might change in the future. If you need to SAVE the // contents might change in the future. If you need to SAVE the
// values, do a shallow copy to an array of your own. // values, do a shallow copy to an array of your own.
virtual float* getTemperatureBlock(/*float* temperatures, */ int x, int z, int w, int h); virtual float* getTemperatureBlock(float* temperatures, int x, int z, int w, int h);
//virtual float* getDownfallBlock(/*float* downfalls, */int x, int z, int w, int h); virtual float* getDownfallBlock(float* downfalls, int x, int z, int w, int h);
virtual Biome** getBiomeBlock(int x, int z, int w, int h); virtual Biome** getBiomeBlock(int x, int z, int w, int h);
private: private:

View File

@@ -1,4 +1,4 @@
#if 0
#include "CanyonFeature.h" #include "CanyonFeature.h"
@@ -138,7 +138,7 @@ void CanyonFeature::addTunnel( int xOffs, int zOffs, unsigned char* blocks, floa
} }
} }
void CanyonFeature::addFeature( Level level, int x, int z, int xOffs, int zOffs, char* blocks ) void CanyonFeature::addFeature(Level* level, int x, int z, int xOffs, int zOffs,unsigned char* blocks)
{ {
if (random.nextInt(15) != 0) return; if (random.nextInt(15) != 0) return;
@@ -151,6 +151,7 @@ void CanyonFeature::addFeature( Level level, int x, int z, int xOffs, int zOffs,
float thickness = (random.nextFloat() * 2 + random.nextFloat()) + 1; float thickness = (random.nextFloat() * 2 + random.nextFloat()) + 1;
addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave, thickness, yRot, xRot, 0, 0, 5.0); addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave, thickness, yRot, xRot, 0, 0, 5.0);
} }
/* //private /* //private
@@ -165,4 +166,4 @@ void CanyonFeature::addFeature( Level level, int x, int z, int xOffs, int zOffs,
for (int z = zOffs - r; z <= zOffs + r; z++) { for (int z = zOffs - r; z <= zOffs + r; z++) {
random.setSeed((x * xScale + z * zScale) ^ level.seed);*/ random.setSeed((x * xScale + z * zScale) ^ level.seed);*/
#endif

View File

@@ -1,7 +1,7 @@
#ifndef NET_MINECRAFT_WORLD_LEVEL_LEVELGEN__CanyonFeature_H__ #ifndef NET_MINECRAFT_WORLD_LEVEL_LEVELGEN__CanyonFeature_H__
#define NET_MINECRAFT_WORLD_LEVEL_LEVELGEN__CanyonFeature_H__ #define NET_MINECRAFT_WORLD_LEVEL_LEVELGEN__CanyonFeature_H__
#if 0
//package net.minecraft.world.level.levelgen; //package net.minecraft.world.level.levelgen;
@@ -12,8 +12,8 @@ class CanyonFeature: public LargeFeature {
/*protected*/ /*protected*/
void addTunnel(int xOffs, int zOffs, unsigned char* blocks, float xCave, float yCave, float zCave, float thickness, float yRot, float xRot, int step, int dist, float yScale); void addTunnel(int xOffs, int zOffs, unsigned char* blocks, float xCave, float yCave, float zCave, float thickness, float yRot, float xRot, int step, int dist, float yScale);
/*protected*/ /*protected*/
void addFeature(Level level, int x, int z, int xOffs, int zOffs, char* blocks); void addFeature(Level* level, int x, int z, int xOffs, int zOffs,unsigned char* blocks);
}; };
#endif
#endif /*NET_MINECRAFT_WORLD_LEVEL_LEVELGEN__CanyonFeature_H__*/ #endif /*NET_MINECRAFT_WORLD_LEVEL_LEVELGEN__CanyonFeature_H__*/

View File

@@ -473,7 +473,7 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) {
MobSpawner::postProcessSpawnMobs(level, biome, xo + 8, zo + 8, 16, 16, &random); MobSpawner::postProcessSpawnMobs(level, biome, xo + 8, zo + 8, 16, 16, &random);
//LOGI("Reading temp: 1\n"); //LOGI("Reading temp: 1\n");
float* temperatures = level->getBiomeSource()->getTemperatureBlock(/*NULL,*/ xo + 8, zo + 8, 16, 16); float* temperatures = level->getBiomeSource()->getTemperatureBlock(NULL, xo + 8, zo + 8, 16, 16);
for (int x = xo + 8; x < xo + 8 + 16; x++) for (int x = xo + 8; x < xo + 8 + 16; x++)
for (int z = zo + 8; z < zo + 8 + 16; z++) { for (int z = zo + 8; z < zo + 8 + 16; z++) {
int xp = x - (xo + 8); int xp = x - (xo + 8);

View File

@@ -1,6 +1,11 @@
#include "GrassTile.h" #include "GrassTile.h"
#include "../material/Material.h" #include "../material/Material.h"
#include "../../entity/item/ItemEntity.h" #include "../../entity/item/ItemEntity.h"
#include "../GrassColor.h"
#include "../Level.h"
#include "../LevelSource.h"
#include "../biome/BiomeSource.h"
#include "../../../client/Minecraft.h"
GrassTile::GrassTile(int id) GrassTile::GrassTile(int id)
: super(id, Material::dirt) : super(id, Material::dirt)
@@ -24,11 +29,18 @@ int GrassTile::getTexture( int face, int data ) {
} }
int GrassTile::getColor( LevelSource* level, int x, int y, int z ) { int GrassTile::getColor( LevelSource* level, int x, int y, int z ) {
//level.getBiomeSource().getBiomeBlock(x, z, 1, 1);
//float temp = level.getBiomeSource().temperatures[0];
//float rain = level.getBiomeSource().downfalls[0];
return 0x339933;//GrassColor.get(temp, rain); if(!GrassColor::useTint){
return 0x339933;
}
level->getBiomeSource()->getBiomeBlock(x, z, 1, 1);
float temp = level->getBiomeSource()->temperatures[0];
float rain = level->getBiomeSource()->downfalls[0];
// return 0x339933;//GrassColor.get(temp, rain); // we need to hook this up with OPTION_FOLIAGE_TINT
return GrassColor::get(temp, rain);
} }
void GrassTile::tick( Level* level, int x, int y, int z, Random* random ) { void GrassTile::tick( Level* level, int x, int y, int z, Random* random ) {

View File

@@ -14,6 +14,7 @@ class GrassTile: public Tile
{ {
typedef Tile super; typedef Tile super;
public: public:
static const int MIN_BRIGHTNESS = 4; static const int MIN_BRIGHTNESS = 4;
GrassTile(int id); GrassTile(int id);

View File

@@ -9,6 +9,8 @@
#include "../../item/Item.h" #include "../../item/Item.h"
#include "../../item/ItemInstance.h" #include "../../item/ItemInstance.h"
#include "../FoliageColor.h" #include "../FoliageColor.h"
#include "../LevelSource.h"
#include "../biome/BiomeSource.h"
class Entity; class Entity;
@@ -54,8 +56,16 @@ public:
if (data == BIRCH_LEAF) { if (data == BIRCH_LEAF) {
return FoliageColor::getBirchColor(); return FoliageColor::getBirchColor();
} }
if (!FoliageColor::useTint){
return FoliageColor::getDefaultColor();
}
return FoliageColor::getDefaultColor(); // return FoliageColor::getDefaultColor(); we need to hook this up with OPTION_FOLIAGE_TINT
level->getBiomeSource()->getBiomeBlock(x, z, 1, 1);
float temperature = level->getBiomeSource()->temperatures[0];
float rainfall = level->getBiomeSource()->downfalls[0];
return FoliageColor::get(temperature, rainfall);
} }
void onRemove(Level* level, int x, int y, int z) { void onRemove(Level* level, int x, int y, int z) {