mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-03-25 14:21:55 +02:00
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
This commit is contained in:
@@ -64,29 +64,35 @@ 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 (app.GetGameHostOption(eGameHostOption_TNT))
|
||||
{
|
||||
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);
|
||||
if (speed > 5) speed = 5;
|
||||
level->explode(shared_from_this(), x, y, z, (float) (4 + random->nextDouble() * 1.5f * speed), true);
|
||||
remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MinecartTNT::causeFallDamage(float distance)
|
||||
@@ -122,6 +128,8 @@ void MinecartTNT::handleEntityEvent(byte eventId)
|
||||
|
||||
void MinecartTNT::primeFuse()
|
||||
{
|
||||
if (app.GetGameHostOption(eGameHostOption_TNT))
|
||||
{
|
||||
fuse = 80;
|
||||
|
||||
if (!level->isClientSide)
|
||||
@@ -129,6 +137,7 @@ void MinecartTNT::primeFuse()
|
||||
level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME);
|
||||
level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int MinecartTNT::getFuse()
|
||||
|
||||
Reference in New Issue
Block a user