summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHowaner <franzi.moos@googlemail.com>2014-03-08 12:24:33 +0100
committerHowaner <franzi.moos@googlemail.com>2014-03-08 12:24:33 +0100
commitb37966fd214fb048a415a33291a85ee8c263691c (patch)
tree12fc18f87b61607b051631acdb217ef35a07f7bb /src
parentAdd new tnt documentation (diff)
downloadcuberite-b37966fd214fb048a415a33291a85ee8c263691c.tar
cuberite-b37966fd214fb048a415a33291a85ee8c263691c.tar.gz
cuberite-b37966fd214fb048a415a33291a85ee8c263691c.tar.bz2
cuberite-b37966fd214fb048a415a33291a85ee8c263691c.tar.lz
cuberite-b37966fd214fb048a415a33291a85ee8c263691c.tar.xz
cuberite-b37966fd214fb048a415a33291a85ee8c263691c.tar.zst
cuberite-b37966fd214fb048a415a33291a85ee8c263691c.zip
Diffstat (limited to '')
-rw-r--r--src/BlockEntities/DispenserEntity.cpp2
-rw-r--r--src/Entities/TNTEntity.cpp12
-rw-r--r--src/Entities/TNTEntity.h10
-rw-r--r--src/Items/ItemLighter.h4
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator.cpp2
-rw-r--r--src/World.cpp4
-rw-r--r--src/World.h2
-rw-r--r--src/WorldStorage/NBTChunkSerializer.cpp2
-rw-r--r--src/WorldStorage/WSSAnvil.cpp3
9 files changed, 20 insertions, 21 deletions
diff --git a/src/BlockEntities/DispenserEntity.cpp b/src/BlockEntities/DispenserEntity.cpp
index 374f3d6e3..cbfbb1b6a 100644
--- a/src/BlockEntities/DispenserEntity.cpp
+++ b/src/BlockEntities/DispenserEntity.cpp
@@ -116,7 +116,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
double TNTX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
double TNTZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
- m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 4, 0); // 4 seconds fuse, no initial velocity
+ m_World->SpawnPrimedTNT(TNTX, DispY + 0.5, TNTZ, 80, 0); // 80 ticks fuse, no initial velocity
m_Contents.ChangeSlotCount(a_SlotNum, -1);
}
break;
diff --git a/src/Entities/TNTEntity.cpp b/src/Entities/TNTEntity.cpp
index 4f361403c..02f31f5bb 100644
--- a/src/Entities/TNTEntity.cpp
+++ b/src/Entities/TNTEntity.cpp
@@ -8,9 +8,9 @@
-cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec) :
+cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks) :
super(etTNT, a_X, a_Y, a_Z, 0.98, 0.98),
- m_FuseTicks(a_FuseTimeInSec)
+ m_FuseTicks(a_FuseTicks)
{
}
@@ -18,9 +18,9 @@ cTNTEntity::cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSe
-cTNTEntity::cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec) :
+cTNTEntity::cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks) :
super(etTNT, a_Pos.x, a_Pos.y, a_Pos.z, 0.98, 0.98),
- m_FuseTicks(a_FuseTimeInSec)
+ m_FuseTicks(a_FuseTicks)
{
}
@@ -56,8 +56,8 @@ void cTNTEntity::Tick(float a_Dt, cChunk & a_Chunk)
{
super::Tick(a_Dt, a_Chunk);
BroadcastMovementUpdate();
- float delta_time = a_Dt / 1000; // Convert miliseconds to seconds
- m_FuseTicks -= delta_time;
+
+ m_FuseTicks -= 1;
if (m_FuseTicks <= 0)
{
Explode();
diff --git a/src/Entities/TNTEntity.h b/src/Entities/TNTEntity.h
index 8f83f52d9..116f5a8cb 100644
--- a/src/Entities/TNTEntity.h
+++ b/src/Entities/TNTEntity.h
@@ -16,8 +16,8 @@ public:
// tolua_end
CLASS_PROTODEF(cTNTEntity);
- cTNTEntity(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec = 4);
- cTNTEntity(const Vector3d & a_Pos, double a_FuseTimeInSec = 4);
+ cTNTEntity(double a_X, double a_Y, double a_Z, int a_FuseTicks = 80);
+ cTNTEntity(const Vector3d & a_Pos, int a_FuseTicks = 80);
// cEntity overrides:
virtual void SpawnOn(cClientHandle & a_ClientHandle) override;
@@ -29,15 +29,15 @@ public:
void Explode(void);
/** Returns the fuse ticks until the tnt will explode */
- double GetFuseTicks(void) const { return m_FuseTicks; }
+ int GetFuseTicks(void) const { return m_FuseTicks; }
/** Set the fuse ticks until the tnt will explode */
- void SetFuseTicks(double a_FuseTicks) { m_FuseTicks = a_FuseTicks; }
+ void SetFuseTicks(int a_FuseTicks) { m_FuseTicks = a_FuseTicks; }
// tolua_end
protected:
- double m_FuseTicks; ///< How much time in seconds is left, while the tnt will explode
+ int m_FuseTicks; ///< How much ticks is left, while the tnt will explode
}; // tolua_export
diff --git a/src/Items/ItemLighter.h b/src/Items/ItemLighter.h
index cc7daeb08..18873e911 100644
--- a/src/Items/ItemLighter.h
+++ b/src/Items/ItemLighter.h
@@ -33,8 +33,8 @@ public:
case E_BLOCK_TNT:
{
// Activate the TNT:
- a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
- a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 4); // 4 seconds to boom
+ a_World->BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 1.0f, 1.0f);
+ a_World->SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
a_World->SetBlock(a_BlockX,a_BlockY,a_BlockZ, E_BLOCK_AIR, 0);
break;
}
diff --git a/src/Simulator/IncrementalRedstoneSimulator.cpp b/src/Simulator/IncrementalRedstoneSimulator.cpp
index f377b0aa7..ca2ef4b1a 100644
--- a/src/Simulator/IncrementalRedstoneSimulator.cpp
+++ b/src/Simulator/IncrementalRedstoneSimulator.cpp
@@ -838,7 +838,7 @@ void cIncrementalRedstoneSimulator::HandleTNT(int a_BlockX, int a_BlockY, int a_
if (AreCoordsPowered(a_BlockX, a_BlockY, a_BlockZ))
{
m_World.BroadcastSoundEffect("game.tnt.primed", a_BlockX * 8, a_BlockY * 8, a_BlockZ * 8, 0.5f, 0.6f);
- m_World.SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5, 4); // 4 seconds to boom
+ m_World.SpawnPrimedTNT(a_BlockX + 0.5, a_BlockY + 0.5, a_BlockZ + 0.5); // 80 ticks to boom
m_World.SetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
}
}
diff --git a/src/World.cpp b/src/World.cpp
index ecb278e85..ebc37f7b2 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -1725,10 +1725,10 @@ int cWorld::SpawnMinecart(double a_X, double a_Y, double a_Z, int a_MinecartType
-void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff)
+void cWorld::SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTicks, double a_InitialVelocityCoeff)
{
UNUSED(a_InitialVelocityCoeff);
- cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTimeInSec);
+ cTNTEntity * TNT = new cTNTEntity(a_X, a_Y, a_Z, a_FuseTicks);
TNT->Initialize(this);
// TODO: Add a bit of speed in horiz and vert axes, based on the a_InitialVelocityCoeff
}
diff --git a/src/World.h b/src/World.h
index e6c665785..517b6b4fa 100644
--- a/src/World.h
+++ b/src/World.h
@@ -445,7 +445,7 @@ public:
int SpawnExperienceOrb(double a_X, double a_Y, double a_Z, int a_Reward);
/** Spawns a new primed TNT entity at the specified block coords and specified fuse duration. Initial velocity is given based on the relative coefficient provided */
- void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, double a_FuseTimeInSec, double a_InitialVelocityCoeff = 1);
+ void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1);
// tolua_end
diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp
index 06b815333..17cf838c3 100644
--- a/src/WorldStorage/NBTChunkSerializer.cpp
+++ b/src/WorldStorage/NBTChunkSerializer.cpp
@@ -588,7 +588,7 @@ void cNBTChunkSerializer::AddTNTEntity(cTNTEntity * a_TNT)
{
m_Writer.BeginCompound("");
AddBasicEntity(a_TNT, "PrimedTnt");
- m_Writer.AddByte("Fuse", ((unsigned char)a_TNT->GetFuseTicks()) * 10);
+ m_Writer.AddByte("Fuse", (unsigned char)a_TNT->GetFuseTicks());
m_Writer.EndCompound();
}
diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp
index fa0c4dbd9..b52b74932 100644
--- a/src/WorldStorage/WSSAnvil.cpp
+++ b/src/WorldStorage/WSSAnvil.cpp
@@ -2184,8 +2184,7 @@ void cWSSAnvil::LoadTNTFromNBT(cEntityList & a_Entities, const cParsedNBT & a_NB
int FuseTicks = a_NBT.FindChildByName(a_TagIdx, "Fuse");
if (FuseTicks > 0)
{
- int MojangFuseTicks = (int) a_NBT.GetByte(FuseTicks);
- TNT->SetFuseTicks((double) MojangFuseTicks / 10);
+ TNT->SetFuseTicks((int) a_NBT.GetByte(FuseTicks));
}
a_Entities.push_back(TNT.release());