Skip to content

Commit

Permalink
Add sound to the collector
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Jul 2, 2018
1 parent 2d0000f commit 5a3a485
Showing 1 changed file with 4 additions and 0 deletions.
Expand Up @@ -61,12 +61,14 @@ public void collect(EnumFacing facing) {

// collect items from world
AxisAlignedBB aabb = new AxisAlignedBB(offset.getX(), offset.getY(), offset.getZ(), offset.getX()+1, offset.getY()+1, offset.getZ()+1);
boolean collected = false;
for(EntityItem entity : world.getEntitiesWithinAABB(EntityItem.class, aabb)) {
ItemStack insert = entity.getItem();
// no need to simulate, if successful we have to modify the stack regardless
ItemStack remainder = ItemHandlerHelper.insertItemStacked(itemHandler, insert, false);
// if the stack changed, we were successful
if(remainder.getCount() < insert.getCount()) {
collected = true;
// empty means item is gone
if(remainder.isEmpty()) {
entity.setDead();
Expand All @@ -75,6 +77,8 @@ public void collect(EnumFacing facing) {
}
}
}
// play sound. Plays dispenser dispense if success and dispenser fail if not
world.playEvent(collected ? 1000 : 1001, pos, 0);
}

/*
Expand Down

0 comments on commit 5a3a485

Please sign in to comment.