MCPcopy Create free account
hub / github.com/cuberite/cuberite / EmptyLiquidBucket

Method EmptyLiquidBucket

src/BlockEntities/DispenserEntity.cpp:186–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184
185
186bool cDispenserEntity::EmptyLiquidBucket(BLOCKTYPE a_BlockInFront, int a_SlotNum)
187{
188 if (
189 (a_BlockInFront != E_BLOCK_AIR) &&
190 !IsBlockLiquid(a_BlockInFront) &&
191 !cFluidSimulator::CanWashAway(a_BlockInFront)
192 )
193 {
194 // Not a suitable block in front
195 return false;
196 }
197
198 cItem EmptyBucket(E_ITEM_BUCKET, 1);
199 if (m_Contents.GetSlot(a_SlotNum).m_ItemCount == 1)
200 {
201 // Change the single full bucket present into a single empty bucket
202 m_Contents.SetSlot(a_SlotNum, EmptyBucket);
203 return true;
204 }
205
206 // There are full buckets stacked at this slot, check if we can fit in the empty bucket
207 if (m_Contents.HowManyCanFit(EmptyBucket) < 1)
208 {
209 // The empty bucket wouldn't fit into m_Contents
210 return false;
211 }
212
213 // The empty bucket fits in, remove one full bucket and add the empty one
214 m_Contents.ChangeSlotCount(a_SlotNum, -1);
215 m_Contents.AddItem(EmptyBucket);
216 return true;
217}
218
219
220

Callers

nothing calls this directly

Calls 6

IsBlockLiquidFunction · 0.85
GetSlotMethod · 0.45
SetSlotMethod · 0.45
HowManyCanFitMethod · 0.45
ChangeSlotCountMethod · 0.45
AddItemMethod · 0.45

Tested by

no test coverage detected