aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World
diff options
context:
space:
mode:
authorla <76826837+3UR@users.noreply.github.com>2026-03-10 07:01:17 +1000
committerGitHub <noreply@github.com>2026-03-09 16:01:17 -0500
commite9dba1fa5658b80833ab5b39b0e1028c33794c95 (patch)
treec8afaccb214411f8aa75af680236bf49524b4cc5 /Minecraft.World
parentfe65ec24f199c79352f0bab971e1ad8b5c611fd9 (diff)
Prevent TNT Minecart exploding with TNT disabled (#1067)
This set of changes was made to make the code better mimic TU20 based on its disassembly
Diffstat (limited to 'Minecraft.World')
-rw-r--r--Minecraft.World/MinecartTNT.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/Minecraft.World/MinecartTNT.cpp b/Minecraft.World/MinecartTNT.cpp
index 6e72d66b..18681aa4 100644
--- a/Minecraft.World/MinecartTNT.cpp
+++ b/Minecraft.World/MinecartTNT.cpp
@@ -64,28 +64,34 @@ void MinecartTNT::destroy(DamageSource *source)
double speedSqr = xd * xd + zd * zd;
- if (!source->isExplosion())
+ if (!app.GetGameHostOption(eGameHostOption_TNT) || !source->isExplosion())
{
- spawnAtLocation(std::make_shared<ItemInstance>(Tile::tnt, 1), 0);
+ spawnAtLocation( shared_ptr<ItemInstance>( new ItemInstance(Tile::tnt, 1) ), 0);
}
- if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f)
+ if (app.GetGameHostOption(eGameHostOption_TNT))
{
- explode(speedSqr);
+ if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f)
+ {
+ explode(speedSqr);
+ }
}
}
void MinecartTNT::explode(double speedSqr)
{
+ if (!app.GetGameHostOption(eGameHostOption_TNT))
+ {
+ remove();
+ return;
+ }
+
if (!level->isClientSide)
{
double speed = sqrt(speedSqr);
- if (speed > 5.0) speed = 5.0;
- if (app.GetGameHostOption(eGameHostOption_TNT))
- {
- level->explode(shared_from_this(), x, y, z, static_cast<float>(4 + random->nextDouble() * 1.5f * speed), true);
- remove();
- }
+ if (speed > 5) speed = 5;
+ level->explode(shared_from_this(), x, y, z, (float) (4 + random->nextDouble() * 1.5f * speed), true);
+ remove();
}
}
@@ -122,12 +128,15 @@ void MinecartTNT::handleEntityEvent(byte eventId)
void MinecartTNT::primeFuse()
{
- fuse = 80;
-
- if (!level->isClientSide)
+ if (app.GetGameHostOption(eGameHostOption_TNT))
{
- level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME);
- level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f);
+ fuse = 80;
+
+ if (!level->isClientSide)
+ {
+ level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME);
+ level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f);
+ }
}
}