FIX: grass color | small improvements

This commit is contained in:
2026-07-26 20:43:02 +03:00
parent 7104ba93ae
commit 1f252ac4b3
16 changed files with 117 additions and 86 deletions

View File

@@ -224,7 +224,7 @@ void Mob::baseTick()
if (hurtTime > 0) hurtTime--;
if (invulnerableTime > 0) invulnerableTime--;
if (health <= 0) {
if (this->hasDied()) {
deathTime++;
if (deathTime > SharedConstants::TicksPerSecond) {
beforeRemove();
@@ -437,7 +437,8 @@ void Mob::setSize( float w, float h )
void Mob::heal( int heal )
{
if (health <= 0) return;
if (this->hasDied()) return;
health += heal;
if (health > 20) health = 20;
invulnerableTime = invulnerableDuration / 2;
@@ -447,7 +448,8 @@ bool Mob::hurt( Entity* source, int dmg )
{
if (level->isClientSide) return false;
noActionTime = 0;
if (health <= 0) return false;
if (this->hasDied()) return false;
this->walkAnimSpeed = 1.5f;
@@ -485,7 +487,7 @@ bool Mob::hurt( Entity* source, int dmg )
}
}
if (health <= 0) {
if (this->hasDied()) {
if (sound) level->playSound(this, getDeathSound(), getSoundVolume(), getVoicePitch());
die(source);
} else {
@@ -892,7 +894,7 @@ void Mob::newServerAiStep() {
bool Mob::isImmobile()
{
return health <= 0;
return this->hasDied();
}
void Mob::jumpFromGround()

View File

@@ -127,6 +127,8 @@ public:
virtual ItemInstance* getCarriedItem() {return NULL;}
virtual int getUseItemDuration() {return 0;}
virtual void swing();
inline bool hasDied() { return health <= 0; }
protected:
virtual void causeFallDamage(float distance);

View File

@@ -390,7 +390,7 @@ void Player::travel(float xa, float ya) {
/*protected*/
bool Player::isImmobile() {
return health <= 0 || isSleeping();
return hasDied() || isSleeping();
}
/*protected*/
@@ -447,8 +447,8 @@ void Player::aiStep() {
float tBob = (float) Mth::sqrt(xd * xd + zd * zd);
float tTilt = (float) Mth::atan(-yd * 0.2f) * 15.f;
if (tBob > 0.1f) tBob = 0.1f;
if (!onGround || health <= 0) tBob = 0;
if (onGround || health <= 0) tTilt = 0;
if (!onGround || hasDied()) tBob = 0;
if (onGround || hasDied()) tTilt = 0;
bob += (tBob - bob) * 0.4f;
tilt += (tTilt - tilt) * 0.8f;
@@ -518,14 +518,6 @@ bool Player::isCreativeModeAllowed() {
return true;
}
//void Player::drop() {
// //drop(inventory.removeItem(inventory.selected, 1), false);
//}
void Player::drop(ItemInstance* item) {
drop(item, false);
}
void Player::drop(ItemInstance* item, bool randomly) {
if (item == NULL || item->isNull())
return;
@@ -559,11 +551,6 @@ void Player::drop(ItemInstance* item, bool randomly) {
thrownItem->zd += Mth::sin(dir) * pow;
}
reallyDrop(thrownItem);
}
/*protected*/
void Player::reallyDrop(ItemEntity* thrownItem) {
level->addEntity(thrownItem);
}
@@ -680,7 +667,7 @@ bool Player::hurt(Entity* source, int dmg) {
if (abilities.invulnerable) return false;
noActionTime = 0;
if (health <= 0) return false;
if (hasDied()) return false;
if(isSleeping() && !level->isClientSide) {
stopSleepInBed(true, true, false);
}

View File

@@ -91,10 +91,7 @@ public:
void handleEntityEvent(char id);
virtual void take(Entity* e, int orgCount);
//void drop();
virtual void drop(ItemInstance* item);
virtual void drop(ItemInstance* item, bool randomly);
void reallyDrop(ItemEntity* thrownItem);
virtual void drop(ItemInstance* item, bool randomly = false);
bool canDestroy(Tile* tile);
float getDestroySpeed(Tile* tile);

View File

@@ -43,14 +43,16 @@ int TallGrass::getColor( int auxData ) {
int TallGrass::getColor( LevelSource* level, int x, int y, int z ) {
int d = level->getData(x, y, z);
if (d == DEAD_SHRUB); //return 0xffffff; // i removed this to make it accurate to beta 1.6.6 instead of early java release versions
level->getBiomeSource()->getBiomeBlock(x, z, 1, 1);
float temp = level->getBiomeSource()->temperatures[0]; // shredder added
float rain = level->getBiomeSource()->downfalls != nullptr ? level->getBiomeSource()->downfalls[0] : 0; // shredder added
if (!GrassColor::useTint && d == DEAD_SHRUB){
return 0xffffff;
}
// if (GrassColor::useTint){
// return GrassColor::get(temp, rain); @fixme @todo doesnt work properly
// }
if (GrassColor::useTint){
return GrassColor::get(temp, rain);
}
// @TODO port this function from beta 1.6.6 probably, for now im using biomesource to tint it directly above - shredder
//if (GrassColor::useTint){
//return level->getBiome(x, z)->getGrassColor();