use of net.minecraft.network.play.server.SPacketCollectItem in project Random-Things by lumien231.
the class EntityProjectedItem method onCollideWithPlayer.
/**
* Called by a player entity when they collide with an entity
*/
@Override
public void onCollideWithPlayer(EntityPlayer entityIn) {
if (!this.world.isRemote && this.canBePickedUp) {
ItemStack itemstack = this.getItem();
int i = itemstack.getCount();
if (i <= 0 || entityIn.inventory.addItemStackToInventory(itemstack)) {
if (!this.isSilent()) {
this.world.playSound((EntityPlayer) null, entityIn.posX, entityIn.posY, entityIn.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
}
entityIn.onItemPickup(this, i);
if (!this.world.isRemote) {
EntityTracker entitytracker = ((WorldServer) this.world).getEntityTracker();
entitytracker.sendToTracking(this, new SPacketCollectItem(this.getEntityId(), entityIn.getEntityId(), this.getItem().getCount()));
}
if (itemstack.getCount() <= 0) {
this.setDead();
}
entityIn.addStat(StatList.getObjectsPickedUpStats(itemstack.getItem()), i);
}
}
}
Aggregations