mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-09 00:24:15 +00: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;
|
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)
|
if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f)
|
||||||
{
|
{
|
||||||
explode(speedSqr);
|
explode(speedSqr);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartTNT::explode(double speedSqr)
|
void MinecartTNT::explode(double speedSqr)
|
||||||
{
|
{
|
||||||
|
if (!app.GetGameHostOption(eGameHostOption_TNT))
|
||||||
|
{
|
||||||
|
remove();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!level->isClientSide)
|
if (!level->isClientSide)
|
||||||
{
|
{
|
||||||
double speed = sqrt(speedSqr);
|
double speed = sqrt(speedSqr);
|
||||||
if (speed > 5.0) speed = 5.0;
|
if (speed > 5) speed = 5;
|
||||||
if (app.GetGameHostOption(eGameHostOption_TNT))
|
level->explode(shared_from_this(), x, y, z, (float) (4 + random->nextDouble() * 1.5f * speed), true);
|
||||||
{
|
|
||||||
level->explode(shared_from_this(), x, y, z, static_cast<float>(4 + random->nextDouble() * 1.5f * speed), true);
|
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MinecartTNT::causeFallDamage(float distance)
|
void MinecartTNT::causeFallDamage(float distance)
|
||||||
@@ -122,6 +128,8 @@ void MinecartTNT::handleEntityEvent(byte eventId)
|
|||||||
|
|
||||||
void MinecartTNT::primeFuse()
|
void MinecartTNT::primeFuse()
|
||||||
{
|
{
|
||||||
|
if (app.GetGameHostOption(eGameHostOption_TNT))
|
||||||
|
{
|
||||||
fuse = 80;
|
fuse = 80;
|
||||||
|
|
||||||
if (!level->isClientSide)
|
if (!level->isClientSide)
|
||||||
@@ -129,6 +137,7 @@ void MinecartTNT::primeFuse()
|
|||||||
level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME);
|
level->broadcastEntityEvent(shared_from_this(), EVENT_PRIME);
|
||||||
level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f);
|
level->playEntitySound(shared_from_this(), eSoundType_RANDOM_FUSE, 1, 1.0f);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int MinecartTNT::getFuse()
|
int MinecartTNT::getFuse()
|
||||||
|
|||||||
Reference in New Issue
Block a user