mirror of
https://github.com/GabsPuNs/Project-Zenith-Main.git
synced 2026-05-26 04:34:41 +00:00
TU24
This commit is contained in:
@@ -915,25 +915,23 @@ LevelChunk *Level::getChunk(int x, int z)
|
||||
bool Level::setTileAndData(int x, int y, int z, int tile, int data, int updateFlags)
|
||||
{
|
||||
if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z >= MAX_LEVEL_SIZE)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
if (y < 0) return false;
|
||||
if (y >= maxBuildHeight) return false;
|
||||
|
||||
LevelChunk *c = getChunk(x >> 4, z >> 4);
|
||||
if (!c) return false;
|
||||
|
||||
int oldTile = 0;
|
||||
if ((updateFlags & Tile::UPDATE_NEIGHBORS) != 0)
|
||||
{
|
||||
oldTile = c->getTile(x & 15, y, z & 15);
|
||||
|
||||
}
|
||||
bool result;
|
||||
|
||||
#ifndef _CONTENT_PACKAGE
|
||||
int old = c->getTile(x & 15, y, z & 15);
|
||||
int olddata = c->getData( x & 15, y, z & 15);
|
||||
#endif
|
||||
|
||||
result = c->setTileAndData(x & 15, y, z & 15, tile, data);
|
||||
if( updateFlags != Tile::UPDATE_INVISIBLE_NO_LIGHT)
|
||||
{
|
||||
@@ -941,22 +939,21 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data, int updateFl
|
||||
PIXBeginNamedEvent(0,"Checking light %d %d %d",x,y,z);
|
||||
PIXBeginNamedEvent(0,"was %d, %d now %d, %d",old,olddata,tile,data);
|
||||
#endif
|
||||
Level::checkLight(x, y, z);
|
||||
|
||||
checkLight(x, y, z);
|
||||
PIXEndNamedEvent();
|
||||
PIXEndNamedEvent();
|
||||
}
|
||||
if (result)
|
||||
{
|
||||
if ((updateFlags & Tile::UPDATE_CLIENTS) != 0 && !(isClientSide && (updateFlags & Tile::UPDATE_INVISIBLE) != 0))
|
||||
{
|
||||
sendTileUpdated(x, y, z);
|
||||
|
||||
}
|
||||
if (!isClientSide && (updateFlags & Tile::UPDATE_NEIGHBORS) != 0)
|
||||
{
|
||||
tileUpdated(x, y, z, oldTile);
|
||||
Tile *tobj = Tile::tiles[tile];
|
||||
if (tobj != nullptr && tobj->hasAnalogOutputSignal())
|
||||
updateNeighbourForOutputSignal(x, y, z, tile);
|
||||
if (tobj != nullptr && tobj->hasAnalogOutputSignal()) updateNeighbourForOutputSignal(x, y, z, tile);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -972,12 +969,12 @@ Material *Level::getMaterial(int x, int y, int z)
|
||||
int Level::getData(int x, int y, int z)
|
||||
{
|
||||
if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z >= MAX_LEVEL_SIZE)
|
||||
return false;
|
||||
|
||||
if (y < 0) return false;
|
||||
if (y >= maxBuildHeight) return false;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if (y < 0) return 0;
|
||||
if (y >= maxBuildHeight) return 0;
|
||||
LevelChunk *c = getChunk(x >> 4, z >> 4);
|
||||
|
||||
x &= 15;
|
||||
z &= 15;
|
||||
return c->getData(x, y, z);
|
||||
@@ -986,14 +983,12 @@ int Level::getData(int x, int y, int z)
|
||||
bool Level::setData(int x, int y, int z, int data, int updateFlags, bool forceUpdate/*=false*/) // 4J added forceUpdate)
|
||||
{
|
||||
if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z >= MAX_LEVEL_SIZE)
|
||||
{
|
||||
return false;
|
||||
|
||||
}
|
||||
if (y < 0) return false;
|
||||
if (y >= maxBuildHeight) return false;
|
||||
|
||||
LevelChunk *c = getChunk(x >> 4, z >> 4);
|
||||
if (!c) return false;
|
||||
|
||||
int cx = x & 15;
|
||||
int cz = z & 15;
|
||||
// 4J - have changed _sendTileData to encode a bitfield of which bits are important to be sent. This will be zero where the original flag was false, and non-zero where the original
|
||||
@@ -1335,18 +1330,15 @@ int Level::getBrightness(LightLayer::variety layer, int x, int y, int z)
|
||||
int ix = xc + (chunkSourceXZSize/2);
|
||||
int iz = zc + (chunkSourceXZSize/2);
|
||||
|
||||
if( ( ix < 0 ) || ( ix >= chunkSourceXZSize) ||
|
||||
( iz < 0 ) || ( iz >= chunkSourceXZSize ) )
|
||||
return 0;
|
||||
|
||||
if( ( ix < 0 ) || ( ix >= chunkSourceXZSize ) ) return 0;
|
||||
if( ( iz < 0 ) || ( iz >= chunkSourceXZSize ) ) return 0;
|
||||
int idx = ix * chunkSourceXZSize + iz;
|
||||
LevelChunk *c = chunkSourceCache[idx];
|
||||
|
||||
if( c == nullptr ) return (int)layer;
|
||||
|
||||
// Removed in TU25
|
||||
// if (y < 0) y = 0;
|
||||
// if (y >= maxBuildHeight) y = maxBuildHeight - 1;
|
||||
if (y < 0) y = 0;
|
||||
if (y >= maxBuildHeight) y = maxBuildHeight - 1;
|
||||
|
||||
return c->getBrightness(layer, x & 15, y, z & 15);
|
||||
}
|
||||
@@ -1412,14 +1404,13 @@ void Level::getNeighbourBrightnesses(int *brightnesses, LightLayer::variety laye
|
||||
void Level::setBrightness(LightLayer::variety layer, int x, int y, int z, int brightness, bool noUpdateOnClient/*=false*/) // 4J added noUpdateOnClient
|
||||
{
|
||||
if (x < -MAX_LEVEL_SIZE || z < -MAX_LEVEL_SIZE || x >= MAX_LEVEL_SIZE || z >= MAX_LEVEL_SIZE)
|
||||
{
|
||||
return;
|
||||
|
||||
// Removed in TU25
|
||||
// if (y < 0) return;
|
||||
// if (y >= maxBuildHeight) return;
|
||||
|
||||
}
|
||||
if (y < 0) return;
|
||||
if (y >= maxBuildHeight) return;
|
||||
if (!hasChunk(x >> 4, z >> 4)) return;
|
||||
LevelChunk *c = getChunk(x >> 4, z >> 4);
|
||||
if (!c) return;
|
||||
|
||||
c->setBrightness(layer, x & 15, y, z & 15, brightness);
|
||||
|
||||
@@ -2030,6 +2021,8 @@ float Level::getSkyDarken(float a)
|
||||
return br * 0.8f + 0.2f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vec3 *Level::getSkyColor(shared_ptr<Entity> source, float a)
|
||||
{
|
||||
float td = getTimeOfDay(a);
|
||||
@@ -2159,14 +2152,11 @@ Vec3 *Level::getCloudColor(float a)
|
||||
return Vec3::newTemp(r, g, b);
|
||||
}
|
||||
|
||||
Vec3 *Level::getFogColor(shared_ptr<Entity> source, float a)
|
||||
{
|
||||
int x = Mth::floor(source->x);
|
||||
int z = Mth::floor(source->z);
|
||||
Biome *biome = getBiome(x, z);
|
||||
|
||||
Vec3 *Level::getFogColor(float a)
|
||||
{
|
||||
float td = getTimeOfDay(a);
|
||||
return biome->getFogColor(td, a);
|
||||
return dimension->getFogColor(td, a);
|
||||
}
|
||||
|
||||
|
||||
@@ -3313,8 +3303,6 @@ void Level::buildAndPrepareChunksToPoll()
|
||||
|
||||
void Level::tickClientSideTiles(int xo, int zo, LevelChunk *lc)
|
||||
{
|
||||
if (app.GetGameSettings(0,eGameSetting_CaveSounds) == 0) return;
|
||||
|
||||
//lc->tick(); // 4J - brought this lighting update forward from 1.8.2
|
||||
|
||||
if (delayUntilNextMoodSound == 0 && !isClientSide)
|
||||
@@ -3412,9 +3400,7 @@ bool Level::shouldSnow(int x, int y, int z)
|
||||
|
||||
void Level::checkLight(int x, int y, int z, bool force, bool rootOnlyEmissive) // 4J added force, rootOnlyEmissive parameters
|
||||
{
|
||||
if (!dimension->hasCeiling)
|
||||
checkLight(LightLayer::Sky, x, y, z, force, false);
|
||||
|
||||
if (!dimension->hasCeiling) checkLight(LightLayer::Sky, x, y, z, force, false);
|
||||
checkLight(LightLayer::Block, x, y, z, force, rootOnlyEmissive);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user