MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks(vec3, vec31);
if (!worldObj.isRemote)
{
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX*2, motionY*2, motionZ*2).expand(2.0D, 2.0D, 2.0D));
double d0 = 0.0D;
for (int j = 0; j < list.size(); ++j)
{
Entity entity1 = (Entity)list.get(j);
if (entity1.canBeCollidedWith() && (!(entity1 instanceof EntityPlayer) || delayBeforeCanPickup == 0))
{
float f = 1.0F;
AxisAlignedBB axisalignedbb = entity1.boundingBox.expand(f, f, f);
MovingObjectPosition movingobjectposition1 = axisalignedbb.calculateIntercept(vec3, vec31);
if (movingobjectposition1 != null)
{
double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
if (d1 < d0 || d0 == 0.0D)
{
entity = entity1;
d0 = d1;
}
}
}
}
if (entity != null)
{
movingobjectposition = new MovingObjectPosition(entity);
}
}
if (movingobjectposition != null)
{
if (movingobjectposition.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ) == Blocks.portal)
{
setInPortal();
}
else
{
if (movingobjectposition.entityHit != null) {
movingobjectposition.entityHit.attackEntityFrom(DamageSource.magic, 2.0F);
if (!worldObj.isRemote) {
Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem());
if (item == null) {
item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem());
worldObj.spawnEntityInWorld(item);
item.motionX = motionX*0.25F;
item.motionY = motionY*0.25F;
item.motionZ = motionZ*0.25F;
}
else
{
item.motionX = motionX*0.25F;
item.motionY = motionY*0.25F;
item.motionZ = motionZ*0.25F;
}
}
setDead();
}
}
}
Vector3 vec3m = new Vector3(motionX, motionY, motionZ);
if (vec3m.mag() < 1.0F) {
if (!worldObj.isRemote) {
Entity item = getEntityItem().getItem().createEntity(worldObj, this, getEntityItem());
if (item == null) {
item = new EntityItem(worldObj, posX, posY, posZ, getEntityItem());
worldObj.spawnEntityInWorld(item);
item.motionX = motionX;
item.motionY = motionY;