cCallbacks overrides:
| 45 | |
| 46 | // cCallbacks overrides: |
| 47 | virtual bool OnNextBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, char a_EntryFace) override |
| 48 | { |
| 49 | /* |
| 50 | // DEBUG: |
| 51 | LOGD("Hit block %d:%d at {%d, %d, %d} face %d, %s (%s)", |
| 52 | a_BlockType, a_BlockMeta, |
| 53 | a_BlockX, a_BlockY, a_BlockZ, a_EntryFace, |
| 54 | cBlockInfo::IsSolid(a_BlockType) ? "solid" : "non-solid", |
| 55 | ItemToString(cItem(a_BlockType, 1, a_BlockMeta)).c_str() |
| 56 | ); |
| 57 | */ |
| 58 | |
| 59 | if (cBlockInfo::IsSolid(a_BlockType)) |
| 60 | { |
| 61 | // The projectile hit a solid block |
| 62 | // Calculate the exact hit coords: |
| 63 | cBoundingBox bb(a_BlockX, a_BlockX + 1, a_BlockY, a_BlockY + 1, a_BlockZ, a_BlockZ + 1); |
| 64 | Vector3d Line1 = m_Projectile->GetPosition(); |
| 65 | Vector3d Line2 = Line1 + m_Projectile->GetSpeed(); |
| 66 | double LineCoeff = 0; |
| 67 | eBlockFace Face; |
| 68 | if (bb.CalcLineIntersection(Line1, Line2, LineCoeff, Face)) |
| 69 | { |
| 70 | if (cPluginManager::Get()->CallHookProjectileHitBlock(*m_Projectile)) |
| 71 | { |
| 72 | return false; |
| 73 | } |
| 74 | |
| 75 | Vector3d Intersection = Line1 + m_Projectile->GetSpeed() * LineCoeff; |
| 76 | m_Projectile->OnHitSolidBlock(Intersection, Face); |
| 77 | return true; |
| 78 | } |
| 79 | else |
| 80 | { |
| 81 | LOGD("WEIRD! block tracer reports a hit, but BBox tracer doesn't. Ignoring the hit."); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | // Convey some special effects from special blocks: |
| 86 | switch (a_BlockType) |
| 87 | { |
| 88 | case E_BLOCK_LAVA: |
| 89 | case E_BLOCK_STATIONARY_LAVA: |
| 90 | { |
| 91 | m_Projectile->StartBurning(30); |
| 92 | m_SlowdownCoeff = std::min(m_SlowdownCoeff, 0.9); // Slow down to 0.9* the speed each tick when moving through lava |
| 93 | break; |
| 94 | } |
| 95 | case E_BLOCK_WATER: |
| 96 | case E_BLOCK_STATIONARY_WATER: |
| 97 | { |
| 98 | m_Projectile->StopBurning(); |
| 99 | m_SlowdownCoeff = std::min(m_SlowdownCoeff, 0.8); // Slow down to 0.8* the speed each tick when moving through water |
| 100 | break; |
| 101 | } |
| 102 | } // switch (a_BlockType) |
| 103 | |
| 104 | // Continue tracing |
nothing calls this directly
no test coverage detected