summaryrefslogtreecommitdiffstats
path: root/src/BlockEntities
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2022-07-11 00:55:11 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2022-07-19 23:33:09 +0200
commitcd97aa83307ce33068082dc57deee8d922fec432 (patch)
tree7ea02bf81e102e80df32d527a085c3ecd3f66d44 /src/BlockEntities
parentClientHandle: fix incorrect position floor (diff)
downloadcuberite-Pickups.tar
cuberite-Pickups.tar.gz
cuberite-Pickups.tar.bz2
cuberite-Pickups.tar.lz
cuberite-Pickups.tar.xz
cuberite-Pickups.tar.zst
cuberite-Pickups.zip
Diffstat (limited to 'src/BlockEntities')
-rw-r--r--src/BlockEntities/DropSpenserEntity.cpp41
-rw-r--r--src/BlockEntities/JukeboxEntity.cpp2
2 files changed, 19 insertions, 24 deletions
diff --git a/src/BlockEntities/DropSpenserEntity.cpp b/src/BlockEntities/DropSpenserEntity.cpp
index b067e1081..7fe89fffc 100644
--- a/src/BlockEntities/DropSpenserEntity.cpp
+++ b/src/BlockEntities/DropSpenserEntity.cpp
@@ -197,30 +197,25 @@ void cDropSpenserEntity::DropFromSlot(cChunk & a_Chunk, int a_SlotNum)
auto Meta = a_Chunk.GetMeta(GetRelPos());
AddDropSpenserDir(dispCoord, Meta);
- cItems Pickups;
- Pickups.push_back(m_Contents.RemoveOneItem(a_SlotNum));
-
- const int PickupSpeed = GetRandomProvider().RandInt(2, 6); // At least 2, at most 6
- int PickupSpeedX = 0, PickupSpeedY = 0, PickupSpeedZ = 0;
- switch (Meta & E_META_DROPSPENSER_FACING_MASK)
+ const auto PickupSpeed = [Meta]() -> Vector3i
{
- case E_META_DROPSPENSER_FACING_YP: PickupSpeedY = PickupSpeed; break;
- case E_META_DROPSPENSER_FACING_YM: PickupSpeedY = -PickupSpeed; break;
- case E_META_DROPSPENSER_FACING_XM: PickupSpeedX = -PickupSpeed; break;
- case E_META_DROPSPENSER_FACING_XP: PickupSpeedX = PickupSpeed; break;
- case E_META_DROPSPENSER_FACING_ZM: PickupSpeedZ = -PickupSpeed; break;
- case E_META_DROPSPENSER_FACING_ZP: PickupSpeedZ = PickupSpeed; break;
- }
-
- double MicroX, MicroY, MicroZ;
- MicroX = dispCoord.x + 0.5;
- MicroY = dispCoord.y + 0.4; // Slightly less than half, to accomodate actual texture hole on DropSpenser
- MicroZ = dispCoord.z + 0.5;
+ const int PickupSpeed = GetRandomProvider().RandInt(2, 6); // At least 2, at most 6.
+ switch (Meta & E_META_DROPSPENSER_FACING_MASK)
+ {
+ case E_META_DROPSPENSER_FACING_YP: return { 0, PickupSpeed, 0 };
+ case E_META_DROPSPENSER_FACING_YM: return { 0, -PickupSpeed, 0 };
+ case E_META_DROPSPENSER_FACING_XM: return { -PickupSpeed, 0, 0 };
+ case E_META_DROPSPENSER_FACING_XP: return { PickupSpeed, 0, 0 };
+ case E_META_DROPSPENSER_FACING_ZM: return { 0, 0, -PickupSpeed };
+ case E_META_DROPSPENSER_FACING_ZP: return { 0, 0, PickupSpeed };
+ }
+ UNREACHABLE("Unsupported DropSpenser direction");
+ }();
+ // Where to spawn the pickup.
+ // Y offset is slightly less than half, to accomodate actual texture hole on DropSpenser.
+ const auto HolePosition = Vector3d(0.5, 0.4, 0.5) + dispCoord;
- m_World->SpawnItemPickups(Pickups, MicroX, MicroY, MicroZ, PickupSpeedX, PickupSpeedY, PickupSpeedZ);
+ auto Pickup = m_Contents.RemoveOneItem(a_SlotNum);
+ m_World->SpawnItemPickup(HolePosition, std::move(Pickup), PickupSpeed, 0_tick); // Spawn pickup with no collection delay.
}
-
-
-
-
diff --git a/src/BlockEntities/JukeboxEntity.cpp b/src/BlockEntities/JukeboxEntity.cpp
index 065f9cb46..895e59a8b 100644
--- a/src/BlockEntities/JukeboxEntity.cpp
+++ b/src/BlockEntities/JukeboxEntity.cpp
@@ -115,7 +115,7 @@ bool cJukeboxEntity::EjectRecord(void)
return false;
}
- m_World->SpawnItemPickups(cItem(static_cast<short>(m_Record)), Vector3d(0.5, 0.5, 0.5) + m_Pos, 10);
+ m_World->SpawnItemPickup(m_Pos.addedY(1), cItem(static_cast<short>(m_Record)), 10);
m_World->SetBlockMeta(m_Pos, E_META_JUKEBOX_OFF);
m_World->BroadcastSoundParticleEffect(EffectID::SFX_RANDOM_PLAY_MUSIC_DISC, GetPos(), 0);