@@ -151,29 +151,6 @@ bool ItemInstance::isStackedByData()
151151 return getItem ()->isStackedByData ();
152152}
153153
154- bool ItemInstance::matches (ItemInstance* other) const
155- {
156- return this ->getAuxValue () == other->getAuxValue () &&
157- this ->m_count == other->m_count &&
158- this ->m_itemID == other->m_itemID ;
159- }
160-
161- bool ItemInstance::matches (ItemInstance* a1, ItemInstance* a2)
162- {
163- if (a1 == a2 && a1 == nullptr )
164- return true ;
165-
166- if (a1 == nullptr || a2 == nullptr )
167- return false ;
168-
169- return a1->matches (a2);
170- }
171-
172- int ItemInstance::getAttackDamage (Entity *pEnt)
173- {
174- return getItem ()->getAttackDamage (pEnt);
175- }
176-
177154void ItemInstance::mineBlock (const TilePos& pos, Facing::Name face)
178155{
179156 return getItem ()->mineBlock (this , pos, face);
@@ -212,18 +189,54 @@ bool ItemInstance::useOn(Player* player, Level* level, const TilePos& pos, Facin
212189 return getItem ()->useOn (this , player, level, pos, face);
213190}
214191
192+ int ItemInstance::getAttackDamage (Entity* pEnt)
193+ {
194+ return getItem ()->getAttackDamage (pEnt);
195+ }
196+
215197bool ItemInstance::isNull () const
216198{
217199 // 0.9.2
218200 if (m_itemID <= 0 ) // m_field_10, assuming this is m_itemID
219201 return true ;
220202
221- if (m_auxValue != 0 )
222- return false ;
223- if (m_count != 0 )
224- return false ;
225- if (m_popTime != 0 )
203+ if (m_auxValue != 0 ||
204+ m_count != 0 ||
205+ m_popTime != 0 )
206+ {
226207 return false ;
208+ }
227209
228210 return true ; // isNull
229211}
212+
213+ bool ItemInstance::isNull (const ItemInstance* item)
214+ {
215+ return item == nullptr || item->isNull ();
216+ }
217+
218+ bool ItemInstance::matches (const ItemInstance* a1, const ItemInstance* a2)
219+ {
220+ if (a1 == a2 && a1 == nullptr )
221+ return true ;
222+
223+ if (a1 == nullptr || a2 == nullptr )
224+ return false ;
225+
226+ return a1 == a2;
227+ }
228+
229+ bool ItemInstance::operator ==(const ItemInstance& other) const
230+ {
231+ return this ->getAuxValue () == other.getAuxValue () &&
232+ this ->m_count == other.m_count &&
233+ this ->m_itemID == other.m_itemID ;
234+ }
235+
236+ bool ItemInstance::operator !=(const ItemInstance& other) const
237+ {
238+ // doing this is likely more efficient than inverting the result of == after the fact
239+ return this ->getAuxValue () != other.getAuxValue () ||
240+ this ->m_count != other.m_count ||
241+ this ->m_itemID != other.m_itemID ;
242+ }
0 commit comments