summaryrefslogtreecommitdiffstats
path: root/src/Entities/Minecart.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2019-10-11 11:02:53 +0200
committerMattes D <github@xoft.cz>2019-10-28 10:45:43 +0100
commit61904af626b036b6e4e045ca219b2a361aa45a6e (patch)
tree60b99ab37c9ec87ca96d403b3254a4da023cf6ac /src/Entities/Minecart.cpp
parentUpdate README.md (#4423) (diff)
downloadcuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.gz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.bz2
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.lz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.xz
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.tar.zst
cuberite-61904af626b036b6e4e045ca219b2a361aa45a6e.zip
Diffstat (limited to '')
-rw-r--r--src/Entities/Minecart.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp
index 9ff8c04b6..01d89ceb4 100644
--- a/src/Entities/Minecart.cpp
+++ b/src/Entities/Minecart.cpp
@@ -136,10 +136,9 @@ void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
return;
}
- int RelPosX = POSX_TOINT - a_Chunk.GetPosX() * cChunkDef::Width;
- int RelPosZ = POSZ_TOINT - a_Chunk.GetPosZ() * cChunkDef::Width;
- cChunk * Chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(RelPosX, RelPosZ);
- if (Chunk == nullptr)
+ auto relPos = a_Chunk.AbsoluteToRelative(GetPosition());
+ auto chunk = a_Chunk.GetRelNeighborChunkAdjustCoords(relPos);
+ if (chunk == nullptr)
{
// Inside an unloaded chunk, bail out all processing
return;
@@ -147,12 +146,12 @@ void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
BLOCKTYPE InsideType;
NIBBLETYPE InsideMeta;
- Chunk->GetBlockTypeMeta(RelPosX, PosY, RelPosZ, InsideType, InsideMeta);
+ chunk->GetBlockTypeMeta(relPos, InsideType, InsideMeta);
if (!IsBlockRail(InsideType))
{
// When a descending minecart hits a flat rail, it goes through the ground; check for this
- Chunk->GetBlockTypeMeta(RelPosX, PosY + 1, RelPosZ, InsideType, InsideMeta);
+ chunk->GetBlockTypeMeta(relPos.addedY(1), InsideType, InsideMeta);
if (IsBlockRail(InsideType))
{
// Push cart upwards
@@ -192,12 +191,12 @@ void cMinecart::HandlePhysics(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{
// Not on rail, default physics
SetPosY(floor(GetPosY()) + 0.35); // HandlePhysics overrides this if minecart can fall, else, it is to stop ground clipping minecart bottom when off-rail
- super::HandlePhysics(a_Dt, *Chunk);
+ super::HandlePhysics(a_Dt, *chunk);
}
if (m_bIsOnDetectorRail && !Vector3i(POSX_TOINT, POSY_TOINT, POSZ_TOINT).Equals(m_DetectorRailPosition))
{
- m_World->SetBlock(m_DetectorRailPosition.x, m_DetectorRailPosition.y, m_DetectorRailPosition.z, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07);
+ m_World->SetBlock(m_DetectorRailPosition, E_BLOCK_DETECTOR_RAIL, m_World->GetBlockMeta(m_DetectorRailPosition) & 0x07);
m_bIsOnDetectorRail = false;
}
else if (WasDetectorRail)