diff options
author | Samuel Barney <samjbarney@gmail.com> | 2013-10-14 17:42:43 +0200 |
---|---|---|
committer | Samuel Barney <samjbarney@gmail.com> | 2013-10-14 17:42:43 +0200 |
commit | 5df5176f8d1793b44c7e2353cb46ca0966be1bdd (patch) | |
tree | 95343394cd9902ceaf885f379342c593392e9c16 /source/Entities/Minecart.cpp | |
parent | Mobs no longer spawn up in the air. (diff) | |
parent | APIDump: Documented HOOK_HANDSHAKE. (diff) | |
download | cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.gz cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.bz2 cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.lz cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.xz cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.tar.zst cuberite-5df5176f8d1793b44c7e2353cb46ca0966be1bdd.zip |
Diffstat (limited to 'source/Entities/Minecart.cpp')
-rw-r--r-- | source/Entities/Minecart.cpp | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/source/Entities/Minecart.cpp b/source/Entities/Minecart.cpp index 95bad6570..f75e23d8b 100644 --- a/source/Entities/Minecart.cpp +++ b/source/Entities/Minecart.cpp @@ -17,7 +17,8 @@ cMinecart::cMinecart(ePayload a_Payload, double a_X, double a_Y, double a_Z) : super(etMinecart, a_X, a_Y, a_Z, 0.98, 0.7), - m_Payload(a_Payload) + m_Payload(a_Payload), + m_LastDamage(0) { SetMass(20.f); SetMaxHealth(6); @@ -357,11 +358,51 @@ void cMinecart::HandleRailPhysics(float a_Dt, cChunk & a_Chunk) void cMinecart::DoTakeDamage(TakeDamageInfo & TDI) { + m_LastDamage = TDI.FinalDamage; super::DoTakeDamage(TDI); + m_World->BroadcastEntityMetadata(*this); + if (GetHealth() <= 0) { Destroy(true); + + cItems Drops; + switch (m_Payload) + { + case mpNone: + { + Drops.push_back(cItem(E_ITEM_MINECART, 1, 0)); + break; + } + case mpChest: + { + Drops.push_back(cItem(E_ITEM_CHEST_MINECART, 1, 0)); + break; + } + case mpFurnace: + { + Drops.push_back(cItem(E_ITEM_FURNACE_MINECART, 1, 0)); + break; + } + case mpTNT: + { + Drops.push_back(cItem(E_ITEM_MINECART_WITH_TNT, 1, 0)); + break; + } + case mpHopper: + { + Drops.push_back(cItem(E_ITEM_MINECART_WITH_HOPPER, 1, 0)); + break; + } + default: + { + ASSERT(!"Unhandled minecart type when spawning pickup!"); + return; + } + } + + m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ()); } } @@ -447,7 +488,8 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player) // cMinecartWithFurnace: cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) : - super(mpFurnace, a_X, a_Y, a_Z) + super(mpFurnace, a_X, a_Y, a_Z), + m_IsFueled(false) { } @@ -457,8 +499,16 @@ cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) : void cMinecartWithFurnace::OnRightClicked(cPlayer & a_Player) { - // Try to power the furnace with whatever the player is holding - // TODO + if (a_Player.GetEquippedItem().m_ItemType == E_ITEM_COAL) + { + if (!a_Player.IsGameModeCreative()) + { + a_Player.GetInventory().RemoveOneEquippedItem(); + } + + m_IsFueled = true; + m_World->BroadcastEntityMetadata(*this); + } } |