From 258318ab98771f03d0109d7dfba81daaed26a2a0 Mon Sep 17 00:00:00 2001 From: DrButcher Date: Sun, 3 May 2020 22:05:32 +0200 Subject: Buttons can now be triggered by arrows. (#4670) * Buttons can now be triggered by arrows. --- src/Entities/ArrowEntity.cpp | 5 +++++ src/Entities/Entity.h | 1 + 2 files changed, 6 insertions(+) (limited to 'src/Entities') diff --git a/src/Entities/ArrowEntity.cpp b/src/Entities/ArrowEntity.cpp index 17c915742..ebb8524f1 100644 --- a/src/Entities/ArrowEntity.cpp +++ b/src/Entities/ArrowEntity.cpp @@ -3,6 +3,7 @@ #include "Player.h" #include "ArrowEntity.h" #include "../Chunk.h" +#include "../Blocks/BlockButton.h" @@ -84,6 +85,10 @@ void cArrowEntity::OnHitSolidBlock(Vector3d a_HitPos, eBlockFace a_HitFace) // Broadcast arrow hit sound m_World->BroadcastSoundEffect("entity.arrow.hit", m_HitBlockPos, 0.5f, static_cast(0.75 + (static_cast((GetUniqueID() * 23) % 32)) / 64)); + // Trigger any buttons that were hit + // Wooden buttons will be depressed by the arrow + cBlockButtonHandler::OnArrowHit(*m_World, m_HitBlockPos, a_HitFace); + if ((m_World->GetBlock(m_HitBlockPos) == E_BLOCK_TNT) && IsOnFire()) { m_World->SetBlock(m_HitBlockPos, E_BLOCK_AIR, 0); diff --git a/src/Entities/Entity.h b/src/Entities/Entity.h index 9cb0f970a..15a9cc824 100644 --- a/src/Entities/Entity.h +++ b/src/Entities/Entity.h @@ -189,6 +189,7 @@ public: eEntityType GetEntityType(void) const { return m_EntityType; } + bool IsArrow (void) const { return IsA("cArrowEntity"); } bool IsEnderCrystal(void) const { return (m_EntityType == etEnderCrystal); } bool IsPlayer (void) const { return (m_EntityType == etPlayer); } bool IsPickup (void) const { return (m_EntityType == etPickup); } -- cgit v1.2.3