MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / dropItem

Method dropItem

source/game/StarPlayer.cpp:749–764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

747}
748
749void Player::dropItem() {
750 if (!world())
751 return;
752 if (!canUseTool())
753 return;
754
755 Vec2F throwDirection = world()->geometry().diff(aimPosition(), position());
756 for (auto& throwSlot : {m_inventory->primaryHeldSlot(), m_inventory->secondaryHeldSlot()}) {
757 if (throwSlot) {
758 if (auto drop = m_inventory->takeSlot(*throwSlot)) {
759 world()->addEntity(ItemDrop::throwDrop(drop, position(), velocity(), throwDirection));
760 break;
761 }
762 }
763 }
764}
765
766Maybe<Json> Player::receiveMessage(ConnectionId fromConnection, String const& message, JsonArray const& args) {
767 bool localMessage = fromConnection == world()->connection();

Callers 1

updateRunningMethod · 0.80

Calls 6

primaryHeldSlotMethod · 0.80
secondaryHeldSlotMethod · 0.80
takeSlotMethod · 0.80
diffMethod · 0.45
geometryMethod · 0.45
addEntityMethod · 0.45

Tested by

no test coverage detected