aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/LightningBolt.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-04 03:56:03 -0600
commit42aec6dac53dffa6afe072560a7e1d4986112538 (patch)
tree0836426857391df1b6a83f6368a183f83ec9b104 /Minecraft.World/LightningBolt.cpp
parentc9d58eeac7c72f0b3038e084667b4d89a6249fce (diff)
parentef9b6fd500dfabd9463267b0dd9e29577eea8a2b (diff)
Merge branch 'main' into pr/win64-world-saves
# Conflicts: # Minecraft.Client/MinecraftServer.cpp # README.md
Diffstat (limited to 'Minecraft.World/LightningBolt.cpp')
-rw-r--r--Minecraft.World/LightningBolt.cpp69
1 files changed, 32 insertions, 37 deletions
diff --git a/Minecraft.World/LightningBolt.cpp b/Minecraft.World/LightningBolt.cpp
index 901bedf1..7f32c8ec 100644
--- a/Minecraft.World/LightningBolt.cpp
+++ b/Minecraft.World/LightningBolt.cpp
@@ -27,31 +27,28 @@ LightningBolt::LightningBolt(Level *level, double x, double y, double z) :
flashes = 1;
// 4J - added clientside check
- if( !level->isClientSide )
+ if( !level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK)&&level->difficulty >= 2 && level->hasChunksAt( Mth::floor(x), Mth::floor(y), Mth::floor(z), 10))
{
- if (level->difficulty >= 2 && level->hasChunksAt( Mth::floor(x), Mth::floor(y), Mth::floor(z), 10))
{
+ int xt = Mth::floor(x);
+ int yt = Mth::floor(y);
+ int zt = Mth::floor(z);
+ // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
+ if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
{
- int xt = Mth::floor(x);
- int yt = Mth::floor(y);
- int zt = Mth::floor(z);
- // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
- if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
- {
- if (level->getTile(xt, yt, zt) == 0 && Tile::fire->mayPlace(level, xt, yt, zt)) level->setTile(xt, yt, zt, Tile::fire_Id);
- }
+ if (level->getTile(xt, yt, zt) == 0 && Tile::fire->mayPlace(level, xt, yt, zt)) level->setTileAndUpdate(xt, yt, zt, Tile::fire_Id);
}
+ }
- for (int i = 0; i < 4; i++)
+ for (int i = 0; i < 4; i++)
+ {
+ int xt = Mth::floor(x) + random->nextInt(3) - 1;
+ int yt = Mth::floor(y) + random->nextInt(3) - 1;
+ int zt = Mth::floor(z) + random->nextInt(3) - 1;
+ // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
+ if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
{
- int xt = Mth::floor(x) + random->nextInt(3) - 1;
- int yt = Mth::floor(y) + random->nextInt(3) - 1;
- int zt = Mth::floor(z) + random->nextInt(3) - 1;
- // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
- if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
- {
- if (level->getTile(xt, yt, zt) == 0 && Tile::fire->mayPlace(level, xt, yt, zt)) level->setTile(xt, yt, zt, Tile::fire_Id);
- }
+ if (level->getTile(xt, yt, zt) == 0 && Tile::fire->mayPlace(level, xt, yt, zt)) level->setTileAndUpdate(xt, yt, zt, Tile::fire_Id);
}
}
}
@@ -79,21 +76,18 @@ void LightningBolt::tick()
{
flashes--;
life = 1;
- // 4J - added clientside check
- if( !level->isClientSide )
+
+ seed = random->nextLong();
+ if (!level->isClientSide && level->getGameRules()->getBoolean(GameRules::RULE_DOFIRETICK) && level->hasChunksAt( (int) floor(x), (int) floor(y), (int) floor(z), 10))
{
- seed = random->nextLong();
- if (level->hasChunksAt( (int) floor(x), (int) floor(y), (int) floor(z), 10))
+ int xt = (int) floor(x);
+ int yt = (int) floor(y);
+ int zt = (int) floor(z);
+
+ // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
+ if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
{
- int xt = (int) floor(x);
- int yt = (int) floor(y);
- int zt = (int) floor(z);
-
- // 4J added - don't go setting tiles if we aren't tracking them for network synchronisation
- if( MinecraftServer::getInstance()->getPlayers()->isTrackingTile(xt, yt, zt, level->dimension->id) )
- {
- if (level->getTile(xt, yt, zt) == 0 && Tile::fire->mayPlace(level, xt, yt, zt)) level->setTile(xt, yt, zt, Tile::fire_Id);
- }
+ if (level->getTile(xt, yt, zt) == 0 && Tile::fire->mayPlace(level, xt, yt, zt)) level->setTileAndUpdate(xt, yt, zt, Tile::fire_Id);
}
}
}
@@ -101,10 +95,13 @@ void LightningBolt::tick()
if (life >= 0)
{
- double r = 3;
- // 4J - added clientside check
- if( !level->isClientSide )
+ if (level->isClientSide)
+ {
+ level->skyFlashTime = 2;
+ }
+ else
{
+ double r = 3;
vector<shared_ptr<Entity> > *entities = level->getEntities(shared_from_this(), AABB::newTemp(x - r, y - r, z - r, x + r, y + 6 + r, z + r));
AUTO_VAR(itEnd, entities->end());
for (AUTO_VAR(it, entities->begin()); it != itEnd; it++)
@@ -113,8 +110,6 @@ void LightningBolt::tick()
e->thunderHit(this);
}
}
-
- level->lightningBoltTime = 2;
}
}